#include "net/cert_net/cert_net_fetcher_url_request.h"
#include <memory>
#include <tuple>
#include <utility>
#include "base/check_op.h"
#include "base/containers/extend.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/not_fatal_until.h"
#include "base/numerics/safe_math.h"
#include "base/ranges/algorithm.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "net/base/io_buffer.h"
#include "net/base/isolation_info.h"
#include "net/base/load_flags.h"
#include "net/cert/cert_net_fetcher.h"
#include "net/cookies/site_for_cookies.h"
#include "net/dns/public/secure_dns_policy.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/redirect_info.h"
#include "net/url_request/url_request_context.h"
#include "url/origin.h"
namespace net {
namespace {
const int kReadBufferSizeInBytes = …;
const int kMaxResponseSizeInBytesForCrl = …;
const int kMaxResponseSizeInBytesForAia = …;
const int kTimeoutSeconds = …;
class Job;
struct JobToRequestParamsComparator;
struct JobComparator { … };
JobSet;
}
class CertNetFetcherURLRequest::AsyncCertNetFetcherURLRequest { … };
namespace {
Error CanFetchUrl(const GURL& url) { … }
base::TimeDelta GetTimeout(int timeout_milliseconds) { … }
size_t GetMaxResponseBytes(int max_response_bytes,
size_t default_max_response_bytes) { … }
enum HttpMethod { … };
}
class CertNetFetcherURLRequest::RequestCore
: public base::RefCountedThreadSafe<RequestCore> { … };
struct CertNetFetcherURLRequest::RequestParams { … };
CertNetFetcherURLRequest::RequestParams::RequestParams() = default;
bool CertNetFetcherURLRequest::RequestParams::operator<(
const RequestParams& other) const { … }
namespace {
class Job : public URLRequest::Delegate { … };
}
void CertNetFetcherURLRequest::RequestCore::CancelJob() { … }
void CertNetFetcherURLRequest::RequestCore::SignalImmediateError() { … }
namespace {
Job::Job(
std::unique_ptr<CertNetFetcherURLRequest::RequestParams> request_params,
CertNetFetcherURLRequest::AsyncCertNetFetcherURLRequest* parent)
: … { … }
Job::~Job() { … }
void Job::AttachRequest(
scoped_refptr<CertNetFetcherURLRequest::RequestCore> request) { … }
void Job::DetachRequest(CertNetFetcherURLRequest::RequestCore* request) { … }
void Job::StartURLRequest(URLRequestContext* context) { … }
void Job::Cancel() { … }
void Job::OnReceivedRedirect(URLRequest* request,
const RedirectInfo& redirect_info,
bool* defer_redirect) { … }
void Job::OnResponseStarted(URLRequest* request, int net_error) { … }
void Job::OnReadCompleted(URLRequest* request, int bytes_read) { … }
void Job::Stop() { … }
void Job::ReadBody(URLRequest* request) { … }
bool Job::ConsumeBytesRead(URLRequest* request, int num_bytes) { … }
void Job::OnUrlRequestCompleted(int net_error) { … }
void Job::OnJobCompleted(Error error) { … }
void Job::CompleteAndClearRequests(Error error) { … }
void Job::FailRequest(Error error) { … }
}
CertNetFetcherURLRequest::AsyncCertNetFetcherURLRequest::
AsyncCertNetFetcherURLRequest(URLRequestContext* context)
: … { … }
CertNetFetcherURLRequest::AsyncCertNetFetcherURLRequest::
~AsyncCertNetFetcherURLRequest() { … }
bool JobComparator::operator()(const Job* job1, const Job* job2) const { … }
void CertNetFetcherURLRequest::AsyncCertNetFetcherURLRequest::Fetch(
std::unique_ptr<RequestParams> request_params,
scoped_refptr<RequestCore> request) { … }
void CertNetFetcherURLRequest::AsyncCertNetFetcherURLRequest::Shutdown() { … }
namespace {
struct JobToRequestParamsComparator { … };
}
Job* CertNetFetcherURLRequest::AsyncCertNetFetcherURLRequest::FindJob(
const RequestParams& params) { … }
std::unique_ptr<Job>
CertNetFetcherURLRequest::AsyncCertNetFetcherURLRequest::RemoveJob(Job* job) { … }
namespace {
class CertNetFetcherRequestImpl : public CertNetFetcher::Request { … };
}
CertNetFetcherURLRequest::CertNetFetcherURLRequest()
: … { … }
CertNetFetcherURLRequest::~CertNetFetcherURLRequest() { … }
void CertNetFetcherURLRequest::SetURLRequestContext(
URLRequestContext* context) { … }
base::TimeDelta CertNetFetcherURLRequest::GetDefaultTimeoutForTesting() { … }
void CertNetFetcherURLRequest::Shutdown() { … }
std::unique_ptr<CertNetFetcher::Request>
CertNetFetcherURLRequest::FetchCaIssuers(const GURL& url,
int timeout_milliseconds,
int max_response_bytes) { … }
std::unique_ptr<CertNetFetcher::Request> CertNetFetcherURLRequest::FetchCrl(
const GURL& url,
int timeout_milliseconds,
int max_response_bytes) { … }
std::unique_ptr<CertNetFetcher::Request> CertNetFetcherURLRequest::FetchOcsp(
const GURL& url,
int timeout_milliseconds,
int max_response_bytes) { … }
void CertNetFetcherURLRequest::DoFetchOnNetworkSequence(
std::unique_ptr<RequestParams> request_params,
scoped_refptr<RequestCore> request) { … }
std::unique_ptr<CertNetFetcherURLRequest::Request>
CertNetFetcherURLRequest::DoFetch(
std::unique_ptr<RequestParams> request_params) { … }
}