#include "components/policy/core/common/cloud/external_policy_data_fetcher.h"
#include <string_view>
#include <utility>
#include "base/check_op.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.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/cpp/simple_url_loader_stream_consumer.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
namespace policy {
class ExternalPolicyDataFetcher::Job
: public network::SimpleURLLoaderStreamConsumer { … };
ExternalPolicyDataFetcher::Job::Job(
std::unique_ptr<network::PendingSharedURLLoaderFactory>
pending_url_loader_factory,
base::WeakPtr<ExternalPolicyDataFetcher> fetcher,
scoped_refptr<base::SequencedTaskRunner> fetcher_task_runner,
ExternalPolicyDataFetcher::FetchCallback callback)
: … { … }
void ExternalPolicyDataFetcher::Job::Start(
const GURL& url,
int64_t max_size) { … }
void ExternalPolicyDataFetcher::Job::Cancel() { … }
void ExternalPolicyDataFetcher::Job::OnResponseStarted(
const GURL& ,
const network::mojom::URLResponseHead& response_head) { … }
void ExternalPolicyDataFetcher::Job::OnDataReceived(
std::string_view string_piece,
base::OnceClosure resume) { … }
void ExternalPolicyDataFetcher::Job::OnComplete(bool ) { … }
void ExternalPolicyDataFetcher::Job::OnRetry(base::OnceClosure start_retry) { … }
void ExternalPolicyDataFetcher::Job::ReportFinished(
Result result,
std::unique_ptr<std::string> data) { … }
ExternalPolicyDataFetcher::ExternalPolicyDataFetcher(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
scoped_refptr<base::SequencedTaskRunner> task_runner)
: … { … }
ExternalPolicyDataFetcher::~ExternalPolicyDataFetcher() { … }
ExternalPolicyDataFetcher::Job* ExternalPolicyDataFetcher::StartJob(
const GURL& url,
int64_t max_size,
FetchCallback callback) { … }
void ExternalPolicyDataFetcher::CancelJob(Job* job) { … }
void ExternalPolicyDataFetcher::OnJobFinished(
FetchCallback callback,
Job* job,
Result result,
std::unique_ptr<std::string> data) { … }
}