#include "components/optimization_guide/core/model_execution/model_execution_fetcher.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "components/optimization_guide/core/access_token_helper.h"
#include "components/optimization_guide/core/model_execution/feature_keys.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "components/optimization_guide/core/optimization_guide_logger.h"
#include "components/variations/net/variations_http_headers.h"
#include "google_apis/gaia/gaia_constants.h"
#include "net/base/url_util.h"
#include "net/http/http_response_headers.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/url_response_head.mojom.h"
namespace optimization_guide {
namespace {
constexpr char kGoogleAPITypeName[] = …;
net::NetworkTrafficAnnotationTag GetNetworkTrafficAnnotation(
ModelBasedCapabilityKey feature) { … }
void RecordRequestStatusHistogram(ModelBasedCapabilityKey feature,
FetcherRequestStatus status) { … }
}
ModelExecutionError;
ModelExecutionFetcher::ModelExecutionFetcher(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const GURL& optimization_guide_service_url,
OptimizationGuideLogger* optimization_guide_logger)
: … { … }
ModelExecutionFetcher::~ModelExecutionFetcher() { … }
void ModelExecutionFetcher::ExecuteModel(
ModelBasedCapabilityKey feature,
signin::IdentityManager* identity_manager,
const google::protobuf::MessageLite& request_metadata,
ModelExecuteResponseCallback callback) { … }
void ModelExecutionFetcher::OnAccessTokenReceived(
const std::string& serialized_request,
const std::string& access_token) { … }
void ModelExecutionFetcher::OnURLLoadComplete(
std::unique_ptr<std::string> response_body) { … }
}