[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef NET_HTTP_HTTP_NETWORK_SESSION_H_ |
| 6 | #define NET_HTTP_HTTP_NETWORK_SESSION_H_ |
| 7 | |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | #include <stdint.h> |
| 10 | |
avi | fceb32f6 | 2016-10-07 16:30:52 | [diff] [blame] | 11 | #include <map> |
| 12 | #include <memory> |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 13 | #include <set> |
| 14 | #include <string> |
rch | 74da0e1a | 2016-01-14 02:49:32 | [diff] [blame] | 15 | #include <unordered_set> |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 16 | #include <vector> |
| 17 | |
maksim.sisov | 0adf859 | 2016-07-15 06:25:56 | [diff] [blame] | 18 | #include "base/bind.h" |
Yixin Wang | 10f477ed | 2017-11-21 04:20:20 | [diff] [blame] | 19 | #include "base/containers/flat_set.h" |
maksim.sisov | 0adf859 | 2016-07-15 06:25:56 | [diff] [blame] | 20 | #include "base/memory/memory_pressure_monitor.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 21 | #include "base/memory/ref_counted.h" |
| 22 | #include "base/memory/weak_ptr.h" |
Bence Béky | 6a070bcd | 2018-09-06 15:02:43 | [diff] [blame] | 23 | #include "base/optional.h" |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 24 | #include "base/threading/thread_checker.h" |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 25 | #include "build/buildflag.h" |
mmenke | 0d700dd8 | 2017-05-26 20:36:11 | [diff] [blame] | 26 | #include "net/base/host_mapping_rules.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 27 | #include "net/base/host_port_pair.h" |
| 28 | #include "net/base/net_export.h" |
| 29 | #include "net/dns/host_resolver.h" |
| 30 | #include "net/http/http_auth_cache.h" |
| 31 | #include "net/http/http_stream_factory.h" |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 32 | #include "net/net_buildflags.h" |
Ryan Hamilton | a3ee93a7 | 2018-08-01 22:03:08 | [diff] [blame] | 33 | #include "net/quic/quic_stream_factory.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 34 | #include "net/socket/next_proto.h" |
Bence Béky | 33a4e43 | 2018-12-03 16:17:23 | [diff] [blame] | 35 | #include "net/socket/websocket_endpoint_lock_manager.h" |
Bence Béky | 94658bf | 2018-05-11 19:22:58 | [diff] [blame] | 36 | #include "net/spdy/spdy_session_pool.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 37 | #include "net/ssl/ssl_client_auth_cache.h" |
Ryan Hamilton | 2e003eea | 2018-05-02 00:24:29 | [diff] [blame] | 38 | #include "net/third_party/spdy/core/spdy_protocol.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 39 | |
| 40 | namespace base { |
| 41 | class Value; |
xunjieli | 9f8c5fb5 | 2016-12-07 22:59:33 | [diff] [blame] | 42 | namespace trace_event { |
| 43 | class ProcessMemoryDump; |
| 44 | } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 45 | } |
| 46 | |
Bence Béky | 33a4e43 | 2018-12-03 16:17:23 | [diff] [blame] | 47 | namespace quic { |
| 48 | class QuicClock; |
| 49 | } // namespace quic |
| 50 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 51 | namespace net { |
| 52 | |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 53 | class CTPolicyEnforcer; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 54 | class CertVerifier; |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 55 | class ChannelIDService; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 56 | class ClientSocketFactory; |
| 57 | class ClientSocketPoolManager; |
| 58 | class CTVerifier; |
| 59 | class HostResolver; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 60 | class HttpAuthHandlerFactory; |
| 61 | class HttpNetworkSessionPeer; |
| 62 | class HttpProxyClientSocketPool; |
| 63 | class HttpResponseBodyDrainer; |
| 64 | class HttpServerProperties; |
| 65 | class NetLog; |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 66 | #if BUILDFLAG(ENABLE_REPORTING) |
| 67 | class NetworkErrorLoggingService; |
| 68 | #endif |
Tarun Bansal | ed2b20b64 | 2018-10-15 19:51:32 | [diff] [blame] | 69 | class NetworkQualityEstimator; |
Wojciech Dzierżanowski | 1f82356 | 2019-01-18 11:26:00 | [diff] [blame^] | 70 | class ProxyDelegate; |
Lily Houghton | 8c2f97d | 2018-01-22 05:06:59 | [diff] [blame] | 71 | class ProxyResolutionService; |
Matt Menke | e8648fa | 2019-01-17 16:47:07 | [diff] [blame] | 72 | class ProxyServer; |
| 73 | class QuicCryptoClientStreamFactory; |
Douglas Creager | 134b52e | 2018-11-09 18:00:14 | [diff] [blame] | 74 | #if BUILDFLAG(ENABLE_REPORTING) |
| 75 | class ReportingService; |
| 76 | #endif |
tbansal | ba8f411 | 2015-09-03 21:57:19 | [diff] [blame] | 77 | class SocketPerformanceWatcherFactory; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 78 | class SOCKSClientSocketPool; |
| 79 | class SSLClientSocketPool; |
| 80 | class SSLConfigService; |
| 81 | class TransportClientSocketPool; |
| 82 | class TransportSecurityState; |
| 83 | |
bnc | 3171a243 | 2016-12-28 18:40:26 | [diff] [blame] | 84 | // Specifies the maximum HPACK dynamic table size the server is allowed to set. |
| 85 | const uint32_t kSpdyMaxHeaderTableSize = 64 * 1024; |
| 86 | |
| 87 | // Specifies the maximum concurrent streams server could send (via push). |
| 88 | const uint32_t kSpdyMaxConcurrentPushedStreams = 1000; |
| 89 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 90 | // This class holds session objects used by HttpNetworkTransaction objects. |
Takashi Sakamoto | 420ec97c | 2018-09-26 09:27:59 | [diff] [blame] | 91 | class NET_EXPORT HttpNetworkSession { |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 92 | public: |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 93 | // Self-contained structure with all the simple configuration options |
| 94 | // supported by the HttpNetworkSession. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 95 | struct NET_EXPORT Params { |
| 96 | Params(); |
vmpstr | acd23b7 | 2016-02-26 21:08:55 | [diff] [blame] | 97 | Params(const Params& other); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 98 | ~Params(); |
| 99 | |
zhongyi | d7dd2db1 | 2017-04-14 17:01:25 | [diff] [blame] | 100 | bool enable_server_push_cancellation; |
mmenke | 0d700dd8 | 2017-05-26 20:36:11 | [diff] [blame] | 101 | HostMappingRules host_mapping_rules; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 102 | bool ignore_certificate_errors; |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 103 | uint16_t testing_fixed_http_port; |
| 104 | uint16_t testing_fixed_https_port; |
rch | 1546ccd | 2017-04-20 02:14:23 | [diff] [blame] | 105 | bool enable_user_alternate_protocol_ports; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 106 | |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 107 | // Use SPDY ping frames to test for connection health after idle. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 108 | bool enable_spdy_ping_based_connection_checking; |
bnc | 3f0118e | 2016-02-02 15:42:22 | [diff] [blame] | 109 | bool enable_http2; |
bnc | 8f0f3b6 | 2015-04-08 04:37:23 | [diff] [blame] | 110 | size_t spdy_session_max_recv_window_size; |
bnc | 3171a243 | 2016-12-28 18:40:26 | [diff] [blame] | 111 | // HTTP/2 connection settings. |
| 112 | // Unknown settings will still be sent to the server. |
Bence Béky | 6a070bcd | 2018-09-06 15:02:43 | [diff] [blame] | 113 | // Might contain unknown setting identifiers from a predefined set that |
| 114 | // servers are supposed to ignore, see |
| 115 | // https://tools.ietf.org/html/draft-bishop-httpbis-grease-00. |
| 116 | // The same setting will be sent on every connection to prevent the retry |
| 117 | // logic from hiding broken servers. |
Ryan Hamilton | 0239aac | 2018-05-19 00:03:13 | [diff] [blame] | 118 | spdy::SettingsMap http2_settings; |
Bence Béky | 6a070bcd | 2018-09-06 15:02:43 | [diff] [blame] | 119 | // If set, an HTTP/2 frame with a reserved frame type will be sent after |
| 120 | // every HEADERS and SETTINGS frame. See |
| 121 | // https://tools.ietf.org/html/draft-bishop-httpbis-grease-00. |
| 122 | // The same frame will be sent out on all connections to prevent the retry |
| 123 | // logic from hiding broken servers. |
| 124 | base::Optional<SpdySessionPool::GreasedHttp2Frame> greased_http2_frame; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 125 | // Source of time for SPDY connections. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 126 | SpdySessionPool::TimeFunc time_func; |
bnc | a86731e | 2017-04-17 12:31:28 | [diff] [blame] | 127 | // Whether to enable HTTP/2 Alt-Svc entries. |
| 128 | bool enable_http2_alternative_service; |
Bence Béky | 58b42322 | 2018-01-24 15:16:54 | [diff] [blame] | 129 | // Whether to enable Websocket over HTTP/2. |
| 130 | bool enable_websocket_over_http2; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 131 | |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 132 | // Enables QUIC support. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 133 | bool enable_quic; |
rch | 1546ccd | 2017-04-20 02:14:23 | [diff] [blame] | 134 | |
Ryan Hamilton | 4cbcbf1 | 2018-12-15 05:16:14 | [diff] [blame] | 135 | // If true, HTTPS URLs can be sent to QUIC proxies. |
| 136 | bool enable_quic_proxies_for_https_urls; |
| 137 | |
rch | 1546ccd | 2017-04-20 02:14:23 | [diff] [blame] | 138 | // QUIC runtime configuration options. |
| 139 | |
| 140 | // Versions of QUIC which may be used. |
Ryan Hamilton | 8d9ee76e | 2018-05-29 23:52:52 | [diff] [blame] | 141 | quic::QuicTransportVersionVector quic_supported_versions; |
rch | 1546ccd | 2017-04-20 02:14:23 | [diff] [blame] | 142 | // User agent description to send in the QUIC handshake. |
| 143 | std::string quic_user_agent_id; |
| 144 | // Limit on the size of QUIC packets. |
| 145 | size_t quic_max_packet_length; |
rch | 1546ccd | 2017-04-20 02:14:23 | [diff] [blame] | 146 | // Maximum number of server configs that are to be stored in |
| 147 | // HttpServerProperties, instead of the disk cache. |
| 148 | size_t quic_max_server_configs_stored_in_properties; |
| 149 | // QUIC will be used for all connections in this set. |
| 150 | std::set<HostPortPair> origins_to_force_quic_on; |
| 151 | // Set of QUIC tags to send in the handshake's connection options. |
Ryan Hamilton | 8d9ee76e | 2018-05-29 23:52:52 | [diff] [blame] | 152 | quic::QuicTagVector quic_connection_options; |
Yixin Wang | 46a425f | 2017-08-10 23:02:20 | [diff] [blame] | 153 | // Set of QUIC tags to send in the handshake's connection options that only |
| 154 | // affect the client. |
Ryan Hamilton | 8d9ee76e | 2018-05-29 23:52:52 | [diff] [blame] | 155 | quic::QuicTagVector quic_client_connection_options; |
kapishnikov | 7f8dd1e | 2018-01-24 06:10:49 | [diff] [blame] | 156 | // Enables experimental optimization for receiving data in UDPSocket. |
| 157 | bool quic_enable_socket_recv_optimization; |
rch | 1546ccd | 2017-04-20 02:14:23 | [diff] [blame] | 158 | |
| 159 | // Active QUIC experiments |
| 160 | |
rch | 9ecde09b | 2017-04-08 00:18:23 | [diff] [blame] | 161 | // Marks a QUIC server broken when a connection blackholes after the |
| 162 | // handshake is confirmed. |
| 163 | bool mark_quic_broken_when_network_blackholes; |
rch | 2f2991c | 2017-04-13 19:28:17 | [diff] [blame] | 164 | // Retry requests which fail with QUIC_PROTOCOL_ERROR, and mark QUIC |
| 165 | // broken if the retry succeeds. |
| 166 | bool retry_without_alt_svc_on_quic_errors; |
Yixin Wang | a9afead | 2017-10-19 20:23:10 | [diff] [blame] | 167 | // If true, alt-svc headers advertising QUIC in IETF format will be |
| 168 | // supported. |
| 169 | bool support_ietf_format_quic_altsvc; |
Jana Iyengar | 903dec2 | 2017-11-28 00:44:23 | [diff] [blame] | 170 | // If true, all QUIC sessions are closed when any local IP address changes. |
| 171 | bool quic_close_sessions_on_ip_change; |
Zhongyi Shi | 63574b7 | 2018-06-01 20:22:25 | [diff] [blame] | 172 | // If true, all QUIC sessions are marked as goaway when any local IP address |
| 173 | // changes. |
| 174 | bool quic_goaway_sessions_on_ip_change; |
zhongyi | 6ba0f425 | 2016-08-23 05:20:04 | [diff] [blame] | 175 | // Specifies QUIC idle connection state lifetime. |
rtenneti | 41c0999 | 2015-11-30 18:24:01 | [diff] [blame] | 176 | int quic_idle_connection_timeout_seconds; |
zhongyi | dd1439f6 | 2016-09-02 02:02:26 | [diff] [blame] | 177 | // Specifies the reduced ping timeout subsequent connections should use when |
| 178 | // a connection was timed out with open streams. |
| 179 | int quic_reduced_ping_timeout_seconds; |
Yixin Wang | 469da56 | 2017-11-15 21:34:58 | [diff] [blame] | 180 | // Maximum time the session can be alive before crypto handshake is |
| 181 | // finished. |
| 182 | int quic_max_time_before_crypto_handshake_seconds; |
| 183 | // Maximum idle time before the crypto handshake has completed. |
| 184 | int quic_max_idle_time_before_crypto_handshake_seconds; |
Zhongyi Shi | 6479562 | 2017-11-20 02:21:49 | [diff] [blame] | 185 | // If true, connection migration v2 will be used to migrate existing |
| 186 | // sessions to network when the platform indicates that the default network |
| 187 | // is changing. |
| 188 | bool quic_migrate_sessions_on_network_change_v2; |
Zhongyi Shi | f4683a3 | 2017-12-01 00:03:28 | [diff] [blame] | 189 | // If true, connection migration v2 may be used to migrate active QUIC |
| 190 | // sessions to alternative network if current network connectivity is poor. |
| 191 | bool quic_migrate_sessions_early_v2; |
Zhongyi Shi | 8de4383 | 2018-08-15 23:40:00 | [diff] [blame] | 192 | // If true, a new connection may be kicked off on an alternate network when |
| 193 | // a connection fails on the default network before handshake is confirmed. |
| 194 | bool quic_retry_on_alternate_network_before_handshake; |
Renjie | a0cb4a2c | 2018-09-26 23:37:30 | [diff] [blame] | 195 | // If true, the quic stream factory may race connection from stale dns |
| 196 | // result with the original dns resolution |
| 197 | bool quic_race_stale_dns_on_connection; |
Renjie | a5722ccf | 2018-08-10 00:18:49 | [diff] [blame] | 198 | // If true, the quic session may mark itself as GOAWAY on path degrading. |
| 199 | bool quic_go_away_on_path_degrading; |
Zhongyi Shi | 8b1e43f | 2017-12-13 20:46:30 | [diff] [blame] | 200 | // Maximum time the session could be on the non-default network before |
| 201 | // migrates back to default network. Defaults to |
| 202 | // kMaxTimeOnNonDefaultNetwork. |
Zhongyi Shi | 73f23ca87 | 2017-12-13 18:37:13 | [diff] [blame] | 203 | base::TimeDelta quic_max_time_on_non_default_network; |
Zhongyi Shi | ee76076 | 2018-08-01 00:54:29 | [diff] [blame] | 204 | // Maximum number of migrations to the non-default network on write error |
| 205 | // per network for each session. |
| 206 | int quic_max_migrations_to_non_default_network_on_write_error; |
Zhongyi Shi | 8b1e43f | 2017-12-13 20:46:30 | [diff] [blame] | 207 | // Maximum number of migrations to the non-default network on path |
| 208 | // degrading per network for each session. |
| 209 | int quic_max_migrations_to_non_default_network_on_path_degrading; |
jri | 217455a1 | 2016-07-13 20:15:09 | [diff] [blame] | 210 | // If true, allows migration of QUIC connections to a server-specified |
| 211 | // alternate server address. |
| 212 | bool quic_allow_server_migration; |
Ryan Hamilton | c84473f | 2017-11-23 03:18:34 | [diff] [blame] | 213 | // If true, allows QUIC to use alternative services with a different |
| 214 | // hostname from the origin. |
| 215 | bool quic_allow_remote_alt_svc; |
xunjieli | 888c2992 | 2016-03-18 21:05:09 | [diff] [blame] | 216 | // If true, bidirectional streams over QUIC will be disabled. |
| 217 | bool quic_disable_bidirectional_streams; |
ckrasic | da193a8 | 2016-07-09 00:39:36 | [diff] [blame] | 218 | // If true, enable force HOL blocking. For measurement purposes. |
| 219 | bool quic_force_hol_blocking; |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 220 | // If true, race cert verification with host resolution. |
| 221 | bool quic_race_cert_verification; |
rch | d6163f3 | 2017-01-30 23:50:38 | [diff] [blame] | 222 | // If true, estimate the initial RTT for QUIC connections based on network. |
| 223 | bool quic_estimate_initial_rtt; |
Yixin Wang | 079ad54 | 2018-01-11 04:06:05 | [diff] [blame] | 224 | // If true, client headers will include HTTP/2 stream dependency info |
| 225 | // derived from the request priority. |
| 226 | bool quic_headers_include_h2_stream_dependency; |
Yixin Wang | 10f477ed | 2017-11-21 04:20:20 | [diff] [blame] | 227 | // If non-empty, QUIC will only be spoken to hosts in this list. |
| 228 | base::flat_set<std::string> quic_host_whitelist; |
xunjieli | 888c2992 | 2016-03-18 21:05:09 | [diff] [blame] | 229 | |
Nick Harper | 1e5757d4 | 2018-05-02 23:08:57 | [diff] [blame] | 230 | // Enable Channel ID. Channel ID is being deprecated. |
| 231 | bool enable_channel_id; |
mmenke | a7da6da | 2016-09-01 21:56:52 | [diff] [blame] | 232 | |
| 233 | // Enable HTTP/0.9 for HTTP/HTTPS on ports other than the default one for |
| 234 | // each protocol. |
| 235 | bool http_09_on_non_default_ports_enabled; |
yucliu | 48f235d | 2018-01-11 00:59:55 | [diff] [blame] | 236 | |
| 237 | // If true, idle sockets won't be closed when memory pressure happens. |
| 238 | bool disable_idle_sockets_close_on_memory_pressure; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 239 | }; |
| 240 | |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 241 | // Structure with pointers to the dependencies of the HttpNetworkSession. |
| 242 | // These objects must all outlive the HttpNetworkSession. |
| 243 | struct NET_EXPORT Context { |
| 244 | Context(); |
| 245 | Context(const Context& other); |
| 246 | ~Context(); |
| 247 | |
| 248 | ClientSocketFactory* client_socket_factory; |
| 249 | HostResolver* host_resolver; |
| 250 | CertVerifier* cert_verifier; |
| 251 | ChannelIDService* channel_id_service; |
| 252 | TransportSecurityState* transport_security_state; |
| 253 | CTVerifier* cert_transparency_verifier; |
| 254 | CTPolicyEnforcer* ct_policy_enforcer; |
Lily Houghton | 8c2f97d | 2018-01-22 05:06:59 | [diff] [blame] | 255 | ProxyResolutionService* proxy_resolution_service; |
Wojciech Dzierżanowski | 1f82356 | 2019-01-18 11:26:00 | [diff] [blame^] | 256 | ProxyDelegate* proxy_delegate; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 257 | SSLConfigService* ssl_config_service; |
| 258 | HttpAuthHandlerFactory* http_auth_handler_factory; |
| 259 | HttpServerProperties* http_server_properties; |
| 260 | NetLog* net_log; |
| 261 | SocketPerformanceWatcherFactory* socket_performance_watcher_factory; |
Tarun Bansal | ed2b20b64 | 2018-10-15 19:51:32 | [diff] [blame] | 262 | NetworkQualityEstimator* network_quality_estimator; |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 263 | #if BUILDFLAG(ENABLE_REPORTING) |
Douglas Creager | 134b52e | 2018-11-09 18:00:14 | [diff] [blame] | 264 | ReportingService* reporting_service; |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 265 | NetworkErrorLoggingService* network_error_logging_service; |
| 266 | #endif |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 267 | |
| 268 | // Source of time for QUIC connections. |
Ryan Hamilton | 8d9ee76e | 2018-05-29 23:52:52 | [diff] [blame] | 269 | quic::QuicClock* quic_clock; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 270 | // Source of entropy for QUIC connections. |
Ryan Hamilton | 8d9ee76e | 2018-05-29 23:52:52 | [diff] [blame] | 271 | quic::QuicRandom* quic_random; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 272 | // Optional factory to use for creating QuicCryptoClientStreams. |
| 273 | QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 274 | }; |
| 275 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 276 | enum SocketPoolType { |
| 277 | NORMAL_SOCKET_POOL, |
| 278 | WEBSOCKET_SOCKET_POOL, |
| 279 | NUM_SOCKET_POOL_TYPES |
| 280 | }; |
| 281 | |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 282 | HttpNetworkSession(const Params& params, const Context& context); |
Takashi Sakamoto | 420ec97c | 2018-09-26 09:27:59 | [diff] [blame] | 283 | ~HttpNetworkSession(); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 284 | |
| 285 | HttpAuthCache* http_auth_cache() { return &http_auth_cache_; } |
| 286 | SSLClientAuthCache* ssl_client_auth_cache() { |
| 287 | return &ssl_client_auth_cache_; |
| 288 | } |
| 289 | |
avi | fceb32f6 | 2016-10-07 16:30:52 | [diff] [blame] | 290 | void AddResponseDrainer(std::unique_ptr<HttpResponseBodyDrainer> drainer); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 291 | |
avi | fceb32f6 | 2016-10-07 16:30:52 | [diff] [blame] | 292 | // Removes the drainer from the session. Does not dispose of it. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 293 | void RemoveResponseDrainer(HttpResponseBodyDrainer* drainer); |
| 294 | |
| 295 | TransportClientSocketPool* GetTransportSocketPool(SocketPoolType pool_type); |
| 296 | SSLClientSocketPool* GetSSLSocketPool(SocketPoolType pool_type); |
| 297 | SOCKSClientSocketPool* GetSocketPoolForSOCKSProxy( |
| 298 | SocketPoolType pool_type, |
Matt Menke | e8648fa | 2019-01-17 16:47:07 | [diff] [blame] | 299 | const ProxyServer& socks_proxy); |
| 300 | HttpProxyClientSocketPool* GetSocketPoolForHTTPLikeProxy( |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 301 | SocketPoolType pool_type, |
Matt Menke | e8648fa | 2019-01-17 16:47:07 | [diff] [blame] | 302 | const ProxyServer& http_proxy); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 303 | SSLClientSocketPool* GetSocketPoolForSSLWithProxy( |
| 304 | SocketPoolType pool_type, |
Matt Menke | e8648fa | 2019-01-17 16:47:07 | [diff] [blame] | 305 | const ProxyServer& proxy_server); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 306 | |
| 307 | CertVerifier* cert_verifier() { return cert_verifier_; } |
Lily Houghton | 8c2f97d | 2018-01-22 05:06:59 | [diff] [blame] | 308 | ProxyResolutionService* proxy_resolution_service() { |
| 309 | return proxy_resolution_service_; |
| 310 | } |
Ryan Sleevi | b8449e0 | 2018-07-15 04:31:07 | [diff] [blame] | 311 | SSLConfigService* ssl_config_service() { return ssl_config_service_; } |
Bence Béky | da280c6 | 2018-04-12 15:08:37 | [diff] [blame] | 312 | WebSocketEndpointLockManager* websocket_endpoint_lock_manager() { |
Bence Béky | 33a4e43 | 2018-12-03 16:17:23 | [diff] [blame] | 313 | return &websocket_endpoint_lock_manager_; |
Bence Béky | da280c6 | 2018-04-12 15:08:37 | [diff] [blame] | 314 | } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 315 | SpdySessionPool* spdy_session_pool() { return &spdy_session_pool_; } |
| 316 | QuicStreamFactory* quic_stream_factory() { return &quic_stream_factory_; } |
| 317 | HttpAuthHandlerFactory* http_auth_handler_factory() { |
| 318 | return http_auth_handler_factory_; |
| 319 | } |
bnc | 525e175a | 2016-06-20 12:36:40 | [diff] [blame] | 320 | HttpServerProperties* http_server_properties() { |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 321 | return http_server_properties_; |
| 322 | } |
| 323 | HttpStreamFactory* http_stream_factory() { |
| 324 | return http_stream_factory_.get(); |
| 325 | } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 326 | NetLog* net_log() { |
| 327 | return net_log_; |
| 328 | } |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 329 | #if BUILDFLAG(ENABLE_REPORTING) |
Douglas Creager | 134b52e | 2018-11-09 18:00:14 | [diff] [blame] | 330 | ReportingService* reporting_service() const { return reporting_service_; } |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 331 | NetworkErrorLoggingService* network_error_logging_service() const { |
| 332 | return network_error_logging_service_; |
| 333 | } |
| 334 | #endif |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 335 | |
payal.pandey | 62a40029 | 2015-05-28 09:29:54 | [diff] [blame] | 336 | // Creates a Value summary of the state of the socket pools. |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 337 | std::unique_ptr<base::Value> SocketPoolInfoToValue() const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 338 | |
payal.pandey | 91cb231 | 2015-05-27 07:41:51 | [diff] [blame] | 339 | // Creates a Value summary of the state of the SPDY sessions. |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 340 | std::unique_ptr<base::Value> SpdySessionPoolInfoToValue() const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 341 | |
| 342 | // Creates a Value summary of the state of the QUIC sessions and |
payal.pandey | a18956a | 2015-05-27 05:57:55 | [diff] [blame] | 343 | // configuration. |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 344 | std::unique_ptr<base::Value> QuicInfoToValue() const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 345 | |
| 346 | void CloseAllConnections(); |
| 347 | void CloseIdleConnections(); |
| 348 | |
| 349 | // Returns the original Params used to construct this session. |
| 350 | const Params& params() const { return params_; } |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 351 | // Returns the original Context used to construct this session. |
| 352 | const Context& context() const { return context_; } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 353 | |
bnc | 3472afd | 2016-11-17 15:27:21 | [diff] [blame] | 354 | bool IsProtocolEnabled(NextProto protocol) const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 355 | |
zhongyi | af25754 | 2016-12-19 03:36:01 | [diff] [blame] | 356 | void SetServerPushDelegate(std::unique_ptr<ServerPushDelegate> push_delegate); |
| 357 | |
bnc | 1f29537 | 2015-10-21 23:24:22 | [diff] [blame] | 358 | // Populates |*alpn_protos| with protocols to be used with ALPN. |
| 359 | void GetAlpnProtos(NextProtoVector* alpn_protos) const; |
| 360 | |
nharper | 8cdb0fb | 2016-04-22 21:34:59 | [diff] [blame] | 361 | // Populates |server_config| and |proxy_config| based on this session and |
| 362 | // |request|. |
| 363 | void GetSSLConfig(const HttpRequestInfo& request, |
| 364 | SSLConfig* server_config, |
| 365 | SSLConfig* proxy_config) const; |
| 366 | |
xunjieli | 9f8c5fb5 | 2016-12-07 22:59:33 | [diff] [blame] | 367 | // Dumps memory allocation stats. |parent_dump_absolute_name| is the name |
| 368 | // used by the parent MemoryAllocatorDump in the memory dump hierarchy. |
| 369 | void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd, |
| 370 | const std::string& parent_absolute_name) const; |
| 371 | |
pmarko | 6ab8be24 | 2017-01-11 11:02:55 | [diff] [blame] | 372 | // Evaluates if QUIC is enabled for new streams. |
| 373 | bool IsQuicEnabled() const; |
| 374 | |
| 375 | // Disable QUIC for new streams. |
| 376 | void DisableQuic(); |
| 377 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 378 | private: |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 379 | friend class HttpNetworkSessionPeer; |
| 380 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 381 | ClientSocketPoolManager* GetSocketPoolManager(SocketPoolType pool_type); |
| 382 | |
maksim.sisov | 0adf859 | 2016-07-15 06:25:56 | [diff] [blame] | 383 | // Flush sockets on low memory notifications callback. |
| 384 | void OnMemoryPressure( |
| 385 | base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
| 386 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 387 | NetLog* const net_log_; |
bnc | 525e175a | 2016-06-20 12:36:40 | [diff] [blame] | 388 | HttpServerProperties* const http_server_properties_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 389 | CertVerifier* const cert_verifier_; |
| 390 | HttpAuthHandlerFactory* const http_auth_handler_factory_; |
| 391 | |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 392 | #if BUILDFLAG(ENABLE_REPORTING) |
Douglas Creager | 134b52e | 2018-11-09 18:00:14 | [diff] [blame] | 393 | ReportingService* const reporting_service_; |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 394 | NetworkErrorLoggingService* const network_error_logging_service_; |
| 395 | #endif |
Bence Béky | bf1c67f2 | 2018-04-12 09:26:26 | [diff] [blame] | 396 | ProxyResolutionService* const proxy_resolution_service_; |
Ryan Sleevi | b8449e0 | 2018-07-15 04:31:07 | [diff] [blame] | 397 | SSLConfigService* const ssl_config_service_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 398 | |
| 399 | HttpAuthCache http_auth_cache_; |
| 400 | SSLClientAuthCache ssl_client_auth_cache_; |
Bence Béky | 33a4e43 | 2018-12-03 16:17:23 | [diff] [blame] | 401 | WebSocketEndpointLockManager websocket_endpoint_lock_manager_; |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 402 | std::unique_ptr<ClientSocketPoolManager> normal_socket_pool_manager_; |
| 403 | std::unique_ptr<ClientSocketPoolManager> websocket_socket_pool_manager_; |
zhongyi | af25754 | 2016-12-19 03:36:01 | [diff] [blame] | 404 | std::unique_ptr<ServerPushDelegate> push_delegate_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 405 | QuicStreamFactory quic_stream_factory_; |
| 406 | SpdySessionPool spdy_session_pool_; |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 407 | std::unique_ptr<HttpStreamFactory> http_stream_factory_; |
avi | fceb32f6 | 2016-10-07 16:30:52 | [diff] [blame] | 408 | std::map<HttpResponseBodyDrainer*, std::unique_ptr<HttpResponseBodyDrainer>> |
| 409 | response_drainers_; |
bnc | 0d23cf4 | 2014-12-11 14:09:46 | [diff] [blame] | 410 | NextProtoVector next_protos_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 411 | |
| 412 | Params params_; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 413 | Context context_; |
maksim.sisov | 0adf859 | 2016-07-15 06:25:56 | [diff] [blame] | 414 | |
| 415 | std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 416 | |
| 417 | THREAD_CHECKER(thread_checker_); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 418 | }; |
| 419 | |
| 420 | } // namespace net |
| 421 | |
| 422 | #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_ |