#include "net/http/http_proxy_connect_job.h"
#include <algorithm>
#include <memory>
#include <optional>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/task/single_thread_task_runner.h"
#include "base/values.h"
#include "build/build_config.h"
#include "http_proxy_client_socket.h"
#include "net/base/features.h"
#include "net/base/host_port_pair.h"
#include "net/base/http_user_agent_settings.h"
#include "net/base/net_errors.h"
#include "net/base/proxy_chain.h"
#include "net/base/session_usage.h"
#include "net/dns/public/secure_dns_policy.h"
#include "net/log/net_log_source_type.h"
#include "net/log/net_log_with_source.h"
#include "net/nqe/network_quality_estimator.h"
#include "net/quic/quic_context.h"
#include "net/quic/quic_http_utils.h"
#include "net/quic/quic_proxy_client_socket.h"
#include "net/quic/quic_session_key.h"
#include "net/quic/quic_session_pool.h"
#include "net/socket/client_socket_handle.h"
#include "net/socket/next_proto.h"
#include "net/socket/ssl_client_socket.h"
#include "net/socket/ssl_connect_job.h"
#include "net/socket/transport_client_socket_pool.h"
#include "net/socket/transport_connect_job.h"
#include "net/spdy/spdy_proxy_client_socket.h"
#include "net/spdy/spdy_session.h"
#include "net/spdy/spdy_session_pool.h"
#include "net/spdy/spdy_stream.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "url/gurl.h"
#include "url/scheme_host_port.h"
namespace net {
namespace {
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
constexpr base::TimeDelta kHttpProxyConnectJobTunnelTimeout = base::Seconds(10);
#else
constexpr base::TimeDelta kHttpProxyConnectJobTunnelTimeout = …;
#endif
class HttpProxyTimeoutExperiments { … };
HttpProxyTimeoutExperiments* GetProxyTimeoutExperiments() { … }
GURL MakeProxyUrl(const HttpProxySocketParams& params) { … }
}
HttpProxySocketParams::HttpProxySocketParams(
ConnectJobParams nested_params,
const HostPortPair& endpoint,
const ProxyChain& proxy_chain,
size_t proxy_chain_index,
bool tunnel,
const NetworkTrafficAnnotationTag traffic_annotation,
const NetworkAnonymizationKey& network_anonymization_key,
SecureDnsPolicy secure_dns_policy)
: … { … }
HttpProxySocketParams::HttpProxySocketParams(
SSLConfig quic_ssl_config,
const HostPortPair& endpoint,
const ProxyChain& proxy_chain,
size_t proxy_chain_index,
bool tunnel,
const NetworkTrafficAnnotationTag traffic_annotation,
const NetworkAnonymizationKey& network_anonymization_key,
SecureDnsPolicy secure_dns_policy)
: … { … }
HttpProxySocketParams::HttpProxySocketParams(
std::optional<ConnectJobParams> nested_params,
std::optional<SSLConfig> quic_ssl_config,
const HostPortPair& endpoint,
const ProxyChain& proxy_chain,
size_t proxy_chain_index,
bool tunnel,
const NetworkTrafficAnnotationTag traffic_annotation,
const NetworkAnonymizationKey& network_anonymization_key,
SecureDnsPolicy secure_dns_policy)
: … { … }
HttpProxySocketParams::~HttpProxySocketParams() = default;
std::unique_ptr<HttpProxyConnectJob> HttpProxyConnectJob::Factory::Create(
RequestPriority priority,
const SocketTag& socket_tag,
const CommonConnectJobParams* common_connect_job_params,
scoped_refptr<HttpProxySocketParams> params,
ConnectJob::Delegate* delegate,
const NetLogWithSource* net_log) { … }
HttpProxyConnectJob::HttpProxyConnectJob(
RequestPriority priority,
const SocketTag& socket_tag,
const CommonConnectJobParams* common_connect_job_params,
scoped_refptr<HttpProxySocketParams> params,
ConnectJob::Delegate* delegate,
const NetLogWithSource* net_log)
: … { … }
HttpProxyConnectJob::~HttpProxyConnectJob() = default;
const RequestPriority HttpProxyConnectJob::kH2QuicTunnelPriority = …;
LoadState HttpProxyConnectJob::GetLoadState() const { … }
bool HttpProxyConnectJob::HasEstablishedConnection() const { … }
ResolveErrorInfo HttpProxyConnectJob::GetResolveErrorInfo() const { … }
bool HttpProxyConnectJob::IsSSLError() const { … }
scoped_refptr<SSLCertRequestInfo> HttpProxyConnectJob::GetCertRequestInfo() { … }
void HttpProxyConnectJob::OnConnectJobComplete(int result, ConnectJob* job) { … }
void HttpProxyConnectJob::OnNeedsProxyAuth(
const HttpResponseInfo& response,
HttpAuthController* auth_controller,
base::OnceClosure restart_with_auth_callback,
ConnectJob* job) { … }
base::TimeDelta HttpProxyConnectJob::AlternateNestedConnectionTimeout(
const HttpProxySocketParams& params,
const NetworkQualityEstimator* network_quality_estimator) { … }
base::TimeDelta HttpProxyConnectJob::TunnelTimeoutForTesting() { … }
void HttpProxyConnectJob::UpdateFieldTrialParametersForTesting() { … }
int HttpProxyConnectJob::ConnectInternal() { … }
ProxyServer::Scheme HttpProxyConnectJob::GetProxyServerScheme() const { … }
void HttpProxyConnectJob::OnIOComplete(int result) { … }
void HttpProxyConnectJob::RestartWithAuthCredentials() { … }
int HttpProxyConnectJob::DoLoop(int result) { … }
int HttpProxyConnectJob::DoBeginConnect() { … }
int HttpProxyConnectJob::DoTransportConnect() { … }
int HttpProxyConnectJob::DoTransportConnectComplete(int result) { … }
int HttpProxyConnectJob::DoHttpProxyConnect() { … }
int HttpProxyConnectJob::DoHttpProxyConnectComplete(int result) { … }
int HttpProxyConnectJob::DoSpdyProxyCreateStream() { … }
int HttpProxyConnectJob::DoSpdyProxyCreateStreamComplete(int result) { … }
int HttpProxyConnectJob::DoQuicProxyCreateSession() { … }
int HttpProxyConnectJob::DoQuicProxyCreateStream(int result) { … }
int HttpProxyConnectJob::DoQuicProxyCreateStreamComplete(int result) { … }
int HttpProxyConnectJob::DoRestartWithAuth() { … }
int HttpProxyConnectJob::DoRestartWithAuthComplete(int result) { … }
void HttpProxyConnectJob::ChangePriorityInternal(RequestPriority priority) { … }
void HttpProxyConnectJob::OnTimedOutInternal() { … }
void HttpProxyConnectJob::OnAuthChallenge() { … }
std::string HttpProxyConnectJob::GetUserAgent() const { … }
SpdySessionKey HttpProxyConnectJob::CreateSpdySessionKey() const { … }
}