#include "components/cronet/url_request_context_config.h"
#include <memory>
#include <type_traits>
#include <utility>
#include "base/containers/contains.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/task/sequenced_task_runner.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/cronet/stale_host_resolver.h"
#include "net/base/address_family.h"
#include "net/cert/caching_cert_verifier.h"
#include "net/cert/cert_verifier.h"
#include "net/cert/cert_verify_proc.h"
#include "net/cert/multi_threaded_cert_verifier.h"
#include "net/dns/context_host_resolver.h"
#include "net/dns/host_resolver.h"
#include "net/dns/mapped_host_resolver.h"
#include "net/http/http_network_session.h"
#include "net/http/http_server_properties.h"
#include "net/log/net_log.h"
#include "net/nqe/network_quality_estimator_params.h"
#include "net/quic/set_quic_flag.h"
#include "net/socket/ssl_client_socket.h"
#include "net/ssl/ssl_key_logger_impl.h"
#include "net/third_party/quiche/src/quiche/quic/core/quic_packets.h"
#include "net/third_party/quiche/src/quiche/quic/core/quic_tag.h"
#include "net/url_request/url_request_context_builder.h"
#include "url/origin.h"
#if BUILDFLAG(ENABLE_REPORTING)
#include "net/reporting/reporting_policy.h"
#endif
namespace cronet {
namespace {
const base::FilePath::CharType kDiskCacheDirectoryName[] = …);
const char kQuicFieldTrialName[] = …;
const char kQuicConnectionOptions[] = …;
const char kQuicClientConnectionOptions[] = …;
const char kQuicStoreServerConfigsInProperties[] = …;
const char kQuicMaxServerConfigsStoredInProperties[] = …;
const char kQuicIdleConnectionTimeoutSeconds[] = …;
const char kQuicMaxTimeBeforeCryptoHandshakeSeconds[] = …;
const char kQuicMaxIdleTimeBeforeCryptoHandshakeSeconds[] = …;
const char kQuicCloseSessionsOnIpChange[] = …;
const char kQuicGoAwaySessionsOnIpChange[] = …;
const char kQuicAllowServerMigration[] = …;
const char kQuicMigrateSessionsOnNetworkChangeV2[] = …;
const char kQuicMigrateIdleSessions[] = …;
const char kQuicRetransmittableOnWireTimeoutMilliseconds[] = …;
const char kQuicIdleSessionMigrationPeriodSeconds[] = …;
const char kQuicMaxTimeOnNonDefaultNetworkSeconds[] = …;
const char kQuicMaxMigrationsToNonDefaultNetworkOnWriteError[] = …;
const char kQuicMaxMigrationsToNonDefaultNetworkOnPathDegrading[] = …;
const char kQuicMigrateSessionsEarlyV2[] = …;
const char kQuicRetryOnAlternateNetworkBeforeHandshake[] = …;
const char kQuicHostWhitelist[] = …;
const char kQuicVersion[] = …;
const char kQuicFlags[] = …;
const char kRetryWithoutAltSvcOnQuicErrors[] = …;
const char kInitialDelayForBrokenAlternativeServiceSeconds[] = …;
const char kExponentialBackoffOnInitialDelay[] = …;
const char kDelayMainJobWithAvailableSpdySession[] = …;
const char kAsyncDnsFieldTrialName[] = …;
const char kAsyncDnsEnable[] = …;
const char kStaleDnsFieldTrialName[] = …;
const char kStaleDnsEnable[] = …;
const char kStaleDnsDelayMs[] = …;
const char kStaleDnsMaxExpiredTimeMs[] = …;
const char kStaleDnsMaxStaleUses[] = …;
const char kStaleDnsAllowOtherNetwork[] = …;
const char kStaleDnsPersist[] = …;
const char kStaleDnsPersistTimer[] = …;
const char kStaleDnsUseStaleOnNameNotResolved[] = …;
const char kHostResolverRulesFieldTrialName[] = …;
const char kHostResolverRules[] = …;
const char kNetworkQualityEstimatorFieldTrialName[] = …;
const char kNetworkErrorLoggingFieldTrialName[] = …;
const char kNetworkErrorLoggingEnable[] = …;
const char kNetworkErrorLoggingPreloadedReportToHeaders[] = …;
const char kNetworkErrorLoggingPreloadedNELHeaders[] = …;
const char kNetworkErrorLoggingOrigin[] = …;
const char kNetworkErrorLoggingValue[] = …;
const char kDisableIPv6OnWifi[] = …;
const char kSSLKeyLogFile[] = …;
const char kAllowPortMigration[] = …;
const char kDisableTlsZeroRtt[] = …;
const char kSpdyGoAwayOnIpChange[] = …;
const char kBidiStreamDetectBrokenConnection[] = …;
const char kUseDnsHttpsSvcbFieldTrialName[] = …;
const char kUseDnsHttpsSvcbUseAlpn[] = …;
std::string SerializeJFVHeader(const base::Value& value) { … }
std::vector<URLRequestContextConfig::PreloadedNelAndReportingHeader>
ParseNetworkErrorLoggingHeaders(
const base::Value::List& preloaded_headers_config) { … }
template <typename T, typename F>
auto map(std::optional<T> maybe, F&& f) { … }
}
URLRequestContextConfig::QuicHint::QuicHint(const std::string& host,
int port,
int alternate_port)
: … { … }
URLRequestContextConfig::QuicHint::~QuicHint() { … }
URLRequestContextConfig::Pkp::Pkp(const std::string& host,
bool include_subdomains,
const base::Time& expiration_date)
: … { … }
URLRequestContextConfig::Pkp::~Pkp() { … }
URLRequestContextConfig::PreloadedNelAndReportingHeader::
PreloadedNelAndReportingHeader(const url::Origin& origin, std::string value)
: … { … }
URLRequestContextConfig::PreloadedNelAndReportingHeader::
~PreloadedNelAndReportingHeader() = default;
URLRequestContextConfig::URLRequestContextConfig(
bool enable_quic,
bool enable_spdy,
bool enable_brotli,
HttpCacheType http_cache,
int http_cache_max_size,
bool load_disable_cache,
const std::string& storage_path,
const std::string& accept_language,
const std::string& user_agent,
base::Value::Dict experimental_options,
std::unique_ptr<net::CertVerifier> mock_cert_verifier,
bool enable_network_quality_estimator,
bool bypass_public_key_pinning_for_local_trust_anchors,
std::optional<int> network_thread_priority)
: … { … }
URLRequestContextConfig::~URLRequestContextConfig() { … }
std::unique_ptr<URLRequestContextConfig>
URLRequestContextConfig::CreateURLRequestContextConfig(
bool enable_quic,
bool enable_spdy,
bool enable_brotli,
HttpCacheType http_cache,
int http_cache_max_size,
bool load_disable_cache,
const std::string& storage_path,
const std::string& accept_language,
const std::string& user_agent,
const std::string& unparsed_experimental_options,
std::unique_ptr<net::CertVerifier> mock_cert_verifier,
bool enable_network_quality_estimator,
bool bypass_public_key_pinning_for_local_trust_anchors,
std::optional<int> network_thread_priority) { … }
std::optional<base::Value::Dict>
URLRequestContextConfig::ParseExperimentalOptions(
std::string unparsed_experimental_options) { … }
void URLRequestContextConfig::SetContextConfigExperimentalOptions() { … }
void URLRequestContextConfig::SetContextBuilderExperimentalOptions(
net::URLRequestContextBuilder* context_builder,
net::HttpNetworkSessionParams* session_params,
net::QuicParams* quic_params,
net::handles::NetworkHandle bound_network) { … }
void URLRequestContextConfig::ConfigureURLRequestContextBuilder(
net::URLRequestContextBuilder* context_builder,
net::handles::NetworkHandle bound_network) { … }
URLRequestContextConfigBuilder::URLRequestContextConfigBuilder() { … }
URLRequestContextConfigBuilder::~URLRequestContextConfigBuilder() { … }
std::unique_ptr<URLRequestContextConfig>
URLRequestContextConfigBuilder::Build() { … }
}