#include "components/cronet/cronet_context.h"
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include <limits>
#include <map>
#include <memory>
#include <set>
#include <utility>
#include "base/base64.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/message_loop/message_pump_type.h"
#include "base/metrics/statistics_recorder.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/cronet/cronet_global_state.h"
#include "components/cronet/cronet_prefs_manager.h"
#include "components/cronet/host_cache_persistence_manager.h"
#include "components/cronet/url_request_context_config.h"
#include "net/base/ip_address.h"
#include "net/base/load_flags.h"
#include "net/base/logging_network_change_observer.h"
#include "net/base/net_errors.h"
#include "net/base/network_delegate_impl.h"
#include "net/base/network_isolation_key.h"
#include "net/base/url_util.h"
#include "net/cert/caching_cert_verifier.h"
#include "net/cert/cert_verifier.h"
#include "net/cert/x509_certificate.h"
#include "net/cookies/cookie_inclusion_status.h"
#include "net/cookies/cookie_monster.h"
#include "net/cookies/cookie_setting_override.h"
#include "net/first_party_sets/first_party_set_metadata.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/transport_security_state.h"
#include "net/log/file_net_log_observer.h"
#include "net/log/net_log_util.h"
#include "net/net_buildflags.h"
#include "net/nqe/network_quality_estimator_params.h"
#include "net/proxy_resolution/proxy_config_service_fixed.h"
#include "net/proxy_resolution/proxy_resolution_service.h"
#include "net/third_party/quiche/src/quiche/quic/core/quic_versions.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_interceptor.h"
#if BUILDFLAG(ENABLE_REPORTING)
#include "net/network_error_logging/network_error_logging_service.h"
#include "net/reporting/reporting_service.h"
#endif
namespace {
class NetLogWithNetworkChangeEvents { … };
static base::LazyInstance<NetLogWithNetworkChangeEvents>::Leaky g_net_log = …;
class BasicNetworkDelegate : public net::NetworkDelegateImpl { … };
void SetQuicHint(net::URLRequestContext* context,
const cronet::URLRequestContextConfig::QuicHint* quic_hint) { … }
bool IsNetworkNoLongerConnected(net::handles::NetworkHandle network) { … }
}
namespace cronet {
CronetContext::CronetContext(
std::unique_ptr<URLRequestContextConfig> context_config,
std::unique_ptr<Callback> callback,
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner)
: … { … }
CronetContext::~CronetContext() { … }
CronetContext::NetworkTasks::NetworkTasks(
std::unique_ptr<URLRequestContextConfig> context_config,
std::unique_ptr<CronetContext::Callback> callback)
: … { … }
CronetContext::NetworkTasks::~NetworkTasks() { … }
void CronetContext::InitRequestContextOnInitThread() { … }
void CronetContext::NetworkTasks::ConfigureNetworkQualityEstimatorForTesting(
bool use_local_host_requests,
bool use_smaller_responses,
bool disable_offline_check) { … }
void CronetContext::ConfigureNetworkQualityEstimatorForTesting(
bool use_local_host_requests,
bool use_smaller_responses,
bool disable_offline_check) { … }
bool CronetContext::URLRequestContextExistsForTesting(
net::handles::NetworkHandle network) { … }
void CronetContext::NetworkTasks::ProvideRTTObservations(bool should) { … }
void CronetContext::ProvideRTTObservations(bool should) { … }
void CronetContext::NetworkTasks::ProvideThroughputObservations(bool should) { … }
void CronetContext::ProvideThroughputObservations(bool should) { … }
void CronetContext::NetworkTasks::SpawnNetworkBoundURLRequestContextForTesting(
net::handles::NetworkHandle network) { … }
bool CronetContext::NetworkTasks::URLRequestContextExistsForTesting(
net::handles::NetworkHandle network) { … }
std::unique_ptr<net::URLRequestContext>
CronetContext::NetworkTasks::BuildDefaultURLRequestContext(
std::unique_ptr<net::ProxyConfigService> proxy_config_service) { … }
std::unique_ptr<net::URLRequestContext>
CronetContext::NetworkTasks::BuildNetworkBoundURLRequestContext(
net::handles::NetworkHandle network) { … }
void CronetContext::NetworkTasks::SetSharedURLRequestContextBuilderConfig(
net::URLRequestContextBuilder* context_builder) { … }
void CronetContext::NetworkTasks::SetSharedURLRequestContextConfig(
net::URLRequestContext* context) { … }
void CronetContext::NetworkTasks::Initialize(
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
scoped_refptr<base::SequencedTaskRunner> file_task_runner,
std::unique_ptr<net::ProxyConfigService> proxy_config_service) { … }
net::URLRequestContext* CronetContext::NetworkTasks::GetURLRequestContext(
net::handles::NetworkHandle network) { … }
void CronetContext::NetworkTasks::MaybeDestroyURLRequestContext(
net::handles::NetworkHandle network) { … }
class CronetContext::ContextGetter : public net::URLRequestContextGetter { … };
net::URLRequestContextGetter* CronetContext::CreateURLRequestContextGetter() { … }
net::URLRequestContext* CronetContext::GetURLRequestContext(
net::handles::NetworkHandle network) { … }
void CronetContext::PostTaskToNetworkThread(const base::Location& posted_from,
base::OnceClosure callback) { … }
void CronetContext::NetworkTasks::RunTaskAfterContextInit(
base::OnceClosure task_to_run_after_context_init) { … }
bool CronetContext::IsOnNetworkThread() const { … }
scoped_refptr<base::SingleThreadTaskRunner>
CronetContext::GetNetworkTaskRunner() const { … }
bool CronetContext::StartNetLogToFile(const std::string& file_name,
bool log_all) { … }
void CronetContext::StartNetLogToDisk(const std::string& dir_name,
bool log_all,
int max_size) { … }
void CronetContext::StopNetLog() { … }
void CronetContext::FlushWritePropertiesForTesting() { … }
void CronetContext::MaybeDestroyURLRequestContext(
net::handles::NetworkHandle network) { … }
int CronetContext::default_load_flags() const { … }
base::Thread* CronetContext::GetFileThread() { … }
void CronetContext::NetworkTasks::OnEffectiveConnectionTypeChanged(
net::EffectiveConnectionType effective_connection_type) { … }
void CronetContext::NetworkTasks::OnRTTOrThroughputEstimatesComputed(
base::TimeDelta http_rtt,
base::TimeDelta transport_rtt,
int32_t downstream_throughput_kbps) { … }
void CronetContext::NetworkTasks::OnRTTObservation(
int32_t rtt_ms,
const base::TimeTicks& timestamp,
net::NetworkQualityObservationSource source) { … }
void CronetContext::NetworkTasks::OnThroughputObservation(
int32_t throughput_kbps,
const base::TimeTicks& timestamp,
net::NetworkQualityObservationSource source) { … }
void CronetContext::NetworkTasks::OnNetworkDisconnected(
net::handles::NetworkHandle network) { … }
void CronetContext::NetworkTasks::OnNetworkConnected(
net::handles::NetworkHandle network) { … }
void CronetContext::NetworkTasks::OnNetworkSoonToDisconnect(
net::handles::NetworkHandle network) { … }
void CronetContext::NetworkTasks::OnNetworkMadeDefault(
net::handles::NetworkHandle network) { … }
void CronetContext::NetworkTasks::StartNetLog(const base::FilePath& file_path,
bool include_socket_bytes) { … }
void CronetContext::NetworkTasks::StartNetLogToBoundedFile(
const std::string& dir_path,
bool include_socket_bytes,
int size) { … }
void CronetContext::NetworkTasks::StopNetLog() { … }
void CronetContext::NetworkTasks::StopNetLogCompleted() { … }
base::Value CronetContext::NetworkTasks::GetNetLogInfo() const { … }
}