#include "components/permissions/prediction_service/prediction_service.h"
#include <cmath>
#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/memory/scoped_refptr.h"
#include "base/no_destructor.h"
#include "base/notreached.h"
#include "components/permissions/features.h"
#include "components/permissions/prediction_service/prediction_common.h"
#include "components/permissions/prediction_service/prediction_request_features.h"
#include "components/permissions/prediction_service/prediction_service_messages.pb.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/fetch_api.mojom-shared.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
namespace {
constexpr base::TimeDelta kURLLookupTimeout = …;
net::NetworkTrafficAnnotationTag GetTrafficAnnotationTag() { … }
}
namespace permissions {
PredictionService::PredictionService(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory)
: … { … }
PredictionService::~PredictionService() = default;
void PredictionService::StartLookup(const PredictionRequestFeatures& entity,
LookupRequestCallback request_callback,
LookupResponseCallback response_callback) { … }
const GURL PredictionService::GetPredictionServiceUrl(
bool recalculate_for_testing) { … }
std::unique_ptr<network::ResourceRequest>
PredictionService::GetResourceRequest() { … }
void PredictionService::SendRequestInternal(
std::unique_ptr<network::ResourceRequest> request,
const std::string& request_data,
const PredictionRequestFeatures& entity,
LookupResponseCallback response_callback) { … }
void PredictionService::OnURLLoaderComplete(
const PredictionRequestFeatures& entity,
network::SimpleURLLoader* loader,
base::TimeTicks request_start_time,
std::unique_ptr<std::string> response_body) { … }
std::unique_ptr<GeneratePredictionsResponse>
PredictionService::CreatePredictionsResponse(network::SimpleURLLoader* loader,
const std::string* response_body) { … }
}