#include "net/spdy/spdy_session_pool.h"
#include <set>
#include <utility>
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "base/task/single_thread_task_runner.h"
#include "base/types/expected.h"
#include "base/values.h"
#include "build/build_config.h"
#include "net/base/features.h"
#include "net/base/ip_endpoint.h"
#include "net/base/trace_constants.h"
#include "net/base/tracing.h"
#include "net/dns/host_resolver.h"
#include "net/dns/public/host_resolver_source.h"
#include "net/http/http_network_session.h"
#include "net/http/http_server_properties.h"
#include "net/http/http_stream_request.h"
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_source.h"
#include "net/log/net_log_with_source.h"
#include "net/socket/stream_socket_handle.h"
#include "net/spdy/spdy_session.h"
#include "net/third_party/quiche/src/quiche/http2/hpack/hpack_constants.h"
#include "net/third_party/quiche/src/quiche/http2/hpack/hpack_static_table.h"
namespace net {
namespace {
enum SpdySessionGetTypes { … };
}
SpdySessionPool::SpdySessionRequest::Delegate::Delegate() = default;
SpdySessionPool::SpdySessionRequest::Delegate::~Delegate() = default;
SpdySessionPool::SpdySessionRequest::SpdySessionRequest(
const SpdySessionKey& key,
bool enable_ip_based_pooling,
bool is_websocket,
bool is_blocking_request_for_session,
Delegate* delegate,
SpdySessionPool* spdy_session_pool)
: … { … }
SpdySessionPool::SpdySessionRequest::~SpdySessionRequest() { … }
void SpdySessionPool::SpdySessionRequest::OnRemovedFromPool() { … }
SpdySessionPool::SpdySessionPool(
HostResolver* resolver,
SSLClientContext* ssl_client_context,
HttpServerProperties* http_server_properties,
TransportSecurityState* transport_security_state,
const quic::ParsedQuicVersionVector& quic_supported_versions,
bool enable_ping_based_connection_checking,
bool is_http2_enabled,
bool is_quic_enabled,
size_t session_max_recv_window_size,
int session_max_queued_capped_frames,
const spdy::SettingsMap& initial_settings,
bool enable_http2_settings_grease,
const std::optional<GreasedHttp2Frame>& greased_http2_frame,
bool http2_end_stream_with_data_frame,
bool enable_priority_update,
bool go_away_on_ip_change,
SpdySessionPool::TimeFunc time_func,
NetworkQualityEstimator* network_quality_estimator,
bool cleanup_sessions_on_ip_address_changed)
: … { … }
SpdySessionPool::~SpdySessionPool() { … }
int SpdySessionPool::CreateAvailableSessionFromSocketHandle(
const SpdySessionKey& key,
std::unique_ptr<StreamSocketHandle> stream_socket_handle,
const NetLogWithSource& net_log,
base::WeakPtr<SpdySession>* session) { … }
base::expected<base::WeakPtr<SpdySession>, int>
SpdySessionPool::CreateAvailableSessionFromSocket(
const SpdySessionKey& key,
std::unique_ptr<StreamSocket> socket_stream,
const LoadTimingInfo::ConnectTiming& connect_timing,
const NetLogWithSource& net_log) { … }
base::WeakPtr<SpdySession> SpdySessionPool::FindAvailableSession(
const SpdySessionKey& key,
bool enable_ip_based_pooling,
bool is_websocket,
const NetLogWithSource& net_log) { … }
base::WeakPtr<SpdySession>
SpdySessionPool::FindMatchingIpSessionForServiceEndpoint(
const SpdySessionKey& key,
const ServiceEndpoint& service_endpoint,
const std::set<std::string>& dns_aliases) { … }
bool SpdySessionPool::HasAvailableSession(const SpdySessionKey& key,
bool is_websocket) const { … }
base::WeakPtr<SpdySession> SpdySessionPool::RequestSession(
const SpdySessionKey& key,
bool enable_ip_based_pooling,
bool is_websocket,
const NetLogWithSource& net_log,
base::RepeatingClosure on_blocking_request_destroyed_callback,
SpdySessionRequest::Delegate* delegate,
std::unique_ptr<SpdySessionRequest>* spdy_session_request,
bool* is_blocking_request_for_session) { … }
OnHostResolutionCallbackResult SpdySessionPool::OnHostResolutionComplete(
const SpdySessionKey& key,
bool is_websocket,
const std::vector<HostResolverEndpointResult>& endpoint_results,
const std::set<std::string>& aliases) { … }
void SpdySessionPool::MakeSessionUnavailable(
const base::WeakPtr<SpdySession>& available_session) { … }
void SpdySessionPool::RemoveUnavailableSession(
const base::WeakPtr<SpdySession>& unavailable_session) { … }
void SpdySessionPool::CloseCurrentSessions(Error error) { … }
void SpdySessionPool::CloseCurrentIdleSessions(const std::string& description) { … }
void SpdySessionPool::CloseAllSessions() { … }
void SpdySessionPool::MakeCurrentSessionsGoingAway(Error error) { … }
std::unique_ptr<base::Value> SpdySessionPool::SpdySessionPoolInfoToValue()
const { … }
void SpdySessionPool::OnIPAddressChanged() { … }
void SpdySessionPool::OnSSLConfigChanged(
SSLClientContext::SSLConfigChangeType change_type) { … }
void SpdySessionPool::OnSSLConfigForServersChanged(
const base::flat_set<HostPortPair>& servers) { … }
std::set<std::string> SpdySessionPool::GetDnsAliasesForSessionKey(
const SpdySessionKey& key) const { … }
void SpdySessionPool::RemoveRequestForSpdySession(SpdySessionRequest* request) { … }
SpdySessionPool::RequestInfoForKey::RequestInfoForKey() = default;
SpdySessionPool::RequestInfoForKey::~RequestInfoForKey() = default;
bool SpdySessionPool::IsSessionAvailable(
const base::WeakPtr<SpdySession>& session) const { … }
void SpdySessionPool::MapKeyToAvailableSession(
const SpdySessionKey& key,
const base::WeakPtr<SpdySession>& session,
std::set<std::string> dns_aliases) { … }
SpdySessionPool::AvailableSessionMap::iterator
SpdySessionPool::LookupAvailableSessionByKey(
const SpdySessionKey& key) { … }
void SpdySessionPool::UnmapKey(const SpdySessionKey& key) { … }
void SpdySessionPool::RemoveAliases(const SpdySessionKey& key) { … }
SpdySessionPool::WeakSessionList SpdySessionPool::GetCurrentSessions() const { … }
void SpdySessionPool::CloseCurrentSessionsHelper(Error error,
const std::string& description,
bool idle_only) { … }
std::unique_ptr<SpdySession> SpdySessionPool::CreateSession(
const SpdySessionKey& key,
NetLog* net_log) { … }
base::expected<base::WeakPtr<SpdySession>, int> SpdySessionPool::InsertSession(
const SpdySessionKey& key,
std::unique_ptr<SpdySession> new_session,
const NetLogWithSource& source_net_log,
std::set<std::string> dns_aliases,
bool perform_post_insertion_checks) { … }
void SpdySessionPool::UpdatePendingRequests(const SpdySessionKey& key) { … }
void SpdySessionPool::RemoveRequestInternal(
SpdySessionRequestMap::iterator request_map_iterator,
RequestSet::iterator request_set_iterator) { … }
base::WeakPtr<SpdySession> SpdySessionPool::FindMatchingIpSession(
const SpdySessionKey& key,
const std::vector<IPEndPoint> ip_endpoints,
const std::set<std::string>& dns_aliases) { … }
}