#include "components/policy/core/common/cloud/external_policy_data_updater.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/task/sequenced_task_runner.h"
#include "components/policy/core/common/cloud/external_policy_data_fetcher.h"
#include "components/policy/core/common/policy_logger.h"
#include "crypto/sha2.h"
#include "net/base/backoff_entry.h"
#include "url/gurl.h"
namespace policy {
namespace {
const net::BackoffEntry::Policy kRetrySoonPolicy = …;
const net::BackoffEntry::Policy kRetryLaterPolicy = …;
const net::BackoffEntry::Policy kRetryMuchLaterPolicy = …;
const int kMaxLimitedRetries = …;
}
class ExternalPolicyDataUpdater::FetchJob final { … };
ExternalPolicyDataUpdater::Request::Request() = default;
ExternalPolicyDataUpdater::Request::Request(const std::string& url,
const std::string& hash,
int64_t max_size)
: … { … }
bool ExternalPolicyDataUpdater::Request::operator==(
const Request& other) const { … }
ExternalPolicyDataUpdater::FetchJob::FetchJob(
ExternalPolicyDataUpdater* updater,
const std::string& key,
const ExternalPolicyDataUpdater::Request& request,
const ExternalPolicyDataUpdater::FetchSuccessCallback& callback)
: … { … }
ExternalPolicyDataUpdater::FetchJob::~FetchJob() { … }
const std::string& ExternalPolicyDataUpdater::FetchJob::key() const { … }
const ExternalPolicyDataUpdater::Request&
ExternalPolicyDataUpdater::FetchJob::request() const { … }
void ExternalPolicyDataUpdater::FetchJob::Start() { … }
void ExternalPolicyDataUpdater::FetchJob::OnFetchFinished(
ExternalPolicyDataFetcher::Result result,
std::unique_ptr<std::string> data) { … }
void ExternalPolicyDataUpdater::FetchJob::OnFailed(net::BackoffEntry* entry) { … }
void ExternalPolicyDataUpdater::FetchJob::Reschedule() { … }
ExternalPolicyDataUpdater::ExternalPolicyDataUpdater(
scoped_refptr<base::SequencedTaskRunner> task_runner,
std::unique_ptr<ExternalPolicyDataFetcher> external_policy_data_fetcher,
size_t max_parallel_fetches)
: … { … }
ExternalPolicyDataUpdater::~ExternalPolicyDataUpdater() { … }
void ExternalPolicyDataUpdater::FetchExternalData(
const std::string& key,
const Request& request,
const FetchSuccessCallback& callback) { … }
void ExternalPolicyDataUpdater::CancelExternalDataFetch(
const std::string& key) { … }
void ExternalPolicyDataUpdater::StartNextJobs() { … }
void ExternalPolicyDataUpdater::ScheduleJob(FetchJob* job) { … }
void ExternalPolicyDataUpdater::OnJobSucceeded(FetchJob* job) { … }
void ExternalPolicyDataUpdater::OnJobFailed(FetchJob* job) { … }
}