#include "net/http/http_stream_pool_attempt_manager.h"
#include <memory>
#include <utility>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/notreached.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "net/base/completion_once_callback.h"
#include "net/base/host_port_pair.h"
#include "net/base/load_states.h"
#include "net/base/load_timing_info.h"
#include "net/base/net_errors.h"
#include "net/base/request_priority.h"
#include "net/dns/host_resolver.h"
#include "net/http/http_network_session.h"
#include "net/http/http_stream_key.h"
#include "net/http/http_stream_pool_group.h"
#include "net/http/http_stream_pool_handle.h"
#include "net/http/http_stream_pool_job.h"
#include "net/http/http_stream_pool_quic_task.h"
#include "net/log/net_log_with_source.h"
#include "net/quic/quic_http_stream.h"
#include "net/quic/quic_session_alias_key.h"
#include "net/socket/connection_attempts.h"
#include "net/socket/stream_attempt.h"
#include "net/socket/stream_socket_handle.h"
#include "net/socket/tcp_stream_attempt.h"
#include "net/socket/tls_stream_attempt.h"
#include "net/spdy/spdy_http_stream.h"
#include "net/spdy/spdy_session.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "net/third_party/quiche/src/quiche/quic/core/quic_versions.h"
namespace net {
namespace {
StreamSocketHandle::SocketReuseType GetReuseTypeFromIdleStreamSocket(
const StreamSocket& stream_socket) { … }
}
struct HttpStreamPool::AttemptManager::InFlightAttempt { … };
struct HttpStreamPool::AttemptManager::PreconnectEntry { … };
HttpStreamPool::AttemptManager::AttemptManager(Group* group, NetLog* net_log)
: … { … }
HttpStreamPool::AttemptManager::~AttemptManager() { … }
std::unique_ptr<HttpStreamPool::Job> HttpStreamPool::AttemptManager::StartJob(
Job::Delegate* delegate,
RequestPriority priority,
const std::vector<SSLConfig::CertAndStatus>& allowed_bad_certs,
bool enable_ip_based_pooling,
bool enable_alternative_services,
quic::ParsedQuicVersion quic_version,
const NetLogWithSource& net_log) { … }
int HttpStreamPool::AttemptManager::Preconnect(
size_t num_streams,
quic::ParsedQuicVersion quic_version,
CompletionOnceCallback callback) { … }
void HttpStreamPool::AttemptManager::OnServiceEndpointsUpdated() { … }
void HttpStreamPool::AttemptManager::OnServiceEndpointRequestFinished(int rv) { … }
int HttpStreamPool::AttemptManager::WaitForSSLConfigReady(
CompletionOnceCallback callback) { … }
SSLConfig HttpStreamPool::AttemptManager::GetSSLConfig() { … }
void HttpStreamPool::AttemptManager::ProcessPendingJob() { … }
void HttpStreamPool::AttemptManager::CancelInFlightAttempts() { … }
void HttpStreamPool::AttemptManager::OnJobComplete(Job* job) { … }
void HttpStreamPool::AttemptManager::CancelJobs(int error) { … }
size_t HttpStreamPool::AttemptManager::PendingJobCount() const { … }
size_t HttpStreamPool::AttemptManager::PendingPreconnectCount() const { … }
const HttpStreamKey& HttpStreamPool::AttemptManager::stream_key() const { … }
const SpdySessionKey& HttpStreamPool::AttemptManager::spdy_session_key() const { … }
const QuicSessionKey& HttpStreamPool::AttemptManager::quic_session_key() const { … }
HttpNetworkSession* HttpStreamPool::AttemptManager::http_network_session() { … }
SpdySessionPool* HttpStreamPool::AttemptManager::spdy_session_pool() { … }
QuicSessionPool* HttpStreamPool::AttemptManager::quic_session_pool() { … }
HttpStreamPool* HttpStreamPool::AttemptManager::pool() { … }
const HttpStreamPool* HttpStreamPool::AttemptManager::pool() const { … }
const NetLogWithSource& HttpStreamPool::AttemptManager::net_log() { … }
bool HttpStreamPool::AttemptManager::UsingTls() const { … }
bool HttpStreamPool::AttemptManager::RequiresHTTP11() { … }
LoadState HttpStreamPool::AttemptManager::GetLoadState() const { … }
RequestPriority HttpStreamPool::AttemptManager::GetPriority() const { … }
bool HttpStreamPool::AttemptManager::IsStalledByPoolLimit() { … }
void HttpStreamPool::AttemptManager::OnRequiredHttp11() { … }
void HttpStreamPool::AttemptManager::OnQuicTaskComplete(int rv) { … }
base::Value::Dict HttpStreamPool::AttemptManager::GetInfoAsValue() { … }
void HttpStreamPool::AttemptManager::StartInternal(RequestPriority priority) { … }
void HttpStreamPool::AttemptManager::ResolveServiceEndpoint(
RequestPriority initial_priority) { … }
void HttpStreamPool::AttemptManager::
MaybeChangeServiceEndpointRequestPriority() { … }
void HttpStreamPool::AttemptManager::ProcessServiceEndpointChanges() { … }
bool HttpStreamPool::AttemptManager::
CanUseExistingSessionAfterEndpointChanges() { … }
void HttpStreamPool::AttemptManager::MaybeRunStreamAttemptDelayTimer() { … }
void HttpStreamPool::AttemptManager::MaybeCalculateSSLConfig() { … }
void HttpStreamPool::AttemptManager::MaybeAttemptQuic() { … }
void HttpStreamPool::AttemptManager::MaybeAttemptConnection(
std::optional<size_t> max_attempts) { … }
bool HttpStreamPool::AttemptManager::IsConnectionAttemptReady() { … }
HttpStreamPool::AttemptManager::CanAttemptResult
HttpStreamPool::AttemptManager::CanAttemptConnection() { … }
bool HttpStreamPool::AttemptManager::ShouldThrottleAttemptForSpdy() { … }
size_t HttpStreamPool::AttemptManager::PendingCountInternal(
size_t pending_count) const { … }
std::optional<IPEndPoint>
HttpStreamPool::AttemptManager::GetIPEndPointToAttempt() { … }
std::optional<IPEndPoint>
HttpStreamPool::AttemptManager::FindPreferredIPEndpoint(
const std::vector<IPEndPoint>& ip_endpoints) { … }
HttpStreamPool::AttemptManager::FailureKind
HttpStreamPool::AttemptManager::DetermineFailureKind() { … }
void HttpStreamPool::AttemptManager::NotifyFailure() { … }
void HttpStreamPool::AttemptManager::NotifyJobOfFailure() { … }
void HttpStreamPool::AttemptManager::NotifyPreconnectsComplete(int rv) { … }
void HttpStreamPool::AttemptManager::ProcessPreconnectsAfterAttemptComplete(
int rv) { … }
void HttpStreamPool::AttemptManager::CreateTextBasedStreamAndNotify(
std::unique_ptr<StreamSocket> stream_socket,
StreamSocketHandle::SocketReuseType reuse_type,
LoadTimingInfo::ConnectTiming connect_timing) { … }
void HttpStreamPool::AttemptManager::CreateSpdyStreamAndNotify() { … }
void HttpStreamPool::AttemptManager::CreateQuicStreamAndNotify() { … }
void HttpStreamPool::AttemptManager::NotifyStreamReady(
std::unique_ptr<HttpStream> stream,
NextProto negotiated_protocol) { … }
void HttpStreamPool::AttemptManager::HandleSpdySessionReady() { … }
void HttpStreamPool::AttemptManager::HandleQuicSessionReady() { … }
HttpStreamPool::Job* HttpStreamPool::AttemptManager::ExtractFirstJobToNotify() { … }
void HttpStreamPool::AttemptManager::SetJobPriority(Job* job,
RequestPriority priority) { … }
void HttpStreamPool::AttemptManager::OnInFlightAttemptComplete(
InFlightAttempt* raw_attempt,
int rv) { … }
void HttpStreamPool::AttemptManager::OnInFlightAttemptTcpHandshakeComplete(
InFlightAttempt* raw_attempt,
int rv) { … }
void HttpStreamPool::AttemptManager::OnInFlightAttemptSlow(
InFlightAttempt* raw_attempt) { … }
void HttpStreamPool::AttemptManager::HandleAttemptFailure(
std::unique_ptr<InFlightAttempt> in_flight_attempt,
int rv) { … }
void HttpStreamPool::AttemptManager::OnSpdyThrottleDelayPassed() { … }
base::TimeDelta HttpStreamPool::AttemptManager::GetStreamAttemptDelay() { … }
void HttpStreamPool::AttemptManager::UpdateStreamAttemptState() { … }
void HttpStreamPool::AttemptManager::OnStreamAttemptDelayPassed() { … }
bool HttpStreamPool::AttemptManager::CanUseQuic() { … }
bool HttpStreamPool::AttemptManager::CanUseExistingQuicSession() { … }
void HttpStreamPool::AttemptManager::MaybeComplete() { … }
}