#include "chrome/browser/optimization_guide/prediction/prediction_model_download_client.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros_local.h"
#include "base/task/sequenced_task_runner.h"
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service.h"
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h"
#include "components/download/public/background_service/download_metadata.h"
#include "components/optimization_guide/core/prediction_manager.h"
#include "components/optimization_guide/core/prediction_model_download_manager.h"
#include "services/network/public/cpp/resource_request_body.h"
namespace optimization_guide {
namespace {
std::optional<proto::OptimizationTarget> ParseOptimizationTarget(
const download::DownloadParams::CustomData& custom_data) { … }
}
PredictionModelDownloadClient::PredictionModelDownloadClient(Profile* profile)
: … { … }
PredictionModelDownloadClient::~PredictionModelDownloadClient() = default;
PredictionModelDownloadManager*
PredictionModelDownloadClient::GetPredictionModelDownloadManager() { … }
void PredictionModelDownloadClient::OnServiceInitialized(
bool state_lost,
const std::vector<download::DownloadMetaData>& downloads) { … }
void PredictionModelDownloadClient::OnServiceUnavailable() { … }
void PredictionModelDownloadClient::OnDownloadStarted(
const std::string& guid,
const std::vector<GURL>& url_chain,
const scoped_refptr<const net::HttpResponseHeaders>& headers) { … }
void PredictionModelDownloadClient::OnDownloadFailed(
const std::string& guid,
const download::CompletionInfo& completion_info,
download::Client::FailureReason reason) { … }
void PredictionModelDownloadClient::OnDownloadSucceeded(
const std::string& guid,
const download::CompletionInfo& completion_info) { … }
bool PredictionModelDownloadClient::CanServiceRemoveDownloadedFile(
const std::string& guid,
bool force_delete) { … }
void PredictionModelDownloadClient::GetUploadData(
const std::string& guid,
download::GetUploadDataCallback callback) { … }
}