[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" |
hajimehoshi | 8156e7c | 2016-09-29 06:17:52 | [diff] [blame] | 20 | #include "base/memory/memory_coordinator_client.h" |
maksim.sisov | 0adf859 | 2016-07-15 06:25:56 | [diff] [blame] | 21 | #include "base/memory/memory_pressure_monitor.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 22 | #include "base/memory/ref_counted.h" |
| 23 | #include "base/memory/weak_ptr.h" |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 24 | #include "base/threading/thread_checker.h" |
mmenke | 0d700dd8 | 2017-05-26 20:36:11 | [diff] [blame] | 25 | #include "net/base/host_mapping_rules.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 26 | #include "net/base/host_port_pair.h" |
| 27 | #include "net/base/net_export.h" |
| 28 | #include "net/dns/host_resolver.h" |
| 29 | #include "net/http/http_auth_cache.h" |
| 30 | #include "net/http/http_stream_factory.h" |
rch | 675757b | 2016-07-29 16:40:11 | [diff] [blame] | 31 | #include "net/quic/chromium/quic_stream_factory.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 32 | #include "net/socket/next_proto.h" |
bnc | 8f8f7d30 | 2017-04-24 18:08:06 | [diff] [blame] | 33 | #include "net/spdy/chromium/spdy_session_pool.h" |
| 34 | #include "net/spdy/core/spdy_protocol.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 35 | #include "net/ssl/ssl_client_auth_cache.h" |
| 36 | |
| 37 | namespace base { |
| 38 | class Value; |
xunjieli | 9f8c5fb5 | 2016-12-07 22:59:33 | [diff] [blame] | 39 | namespace trace_event { |
| 40 | class ProcessMemoryDump; |
| 41 | } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | namespace net { |
| 45 | |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 46 | class CTPolicyEnforcer; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 47 | class CertVerifier; |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 48 | class ChannelIDService; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 49 | class ClientSocketFactory; |
| 50 | class ClientSocketPoolManager; |
| 51 | class CTVerifier; |
| 52 | class HostResolver; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 53 | class HttpAuthHandlerFactory; |
| 54 | class HttpNetworkSessionPeer; |
| 55 | class HttpProxyClientSocketPool; |
| 56 | class HttpResponseBodyDrainer; |
| 57 | class HttpServerProperties; |
| 58 | class NetLog; |
tbansal | 16196a1e | 2017-06-09 01:50:09 | [diff] [blame] | 59 | class NetworkQualityProvider; |
rdsmith | 1d343be5 | 2016-10-21 20:37:50 | [diff] [blame] | 60 | class NetworkThrottleManager; |
bengr | 39e40610 | 2014-09-10 23:04:46 | [diff] [blame] | 61 | class ProxyDelegate; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 62 | class ProxyService; |
| 63 | class QuicClock; |
| 64 | class QuicCryptoClientStreamFactory; |
tbansal | ba8f411 | 2015-09-03 21:57:19 | [diff] [blame] | 65 | class SocketPerformanceWatcherFactory; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 66 | class SOCKSClientSocketPool; |
| 67 | class SSLClientSocketPool; |
| 68 | class SSLConfigService; |
| 69 | class TransportClientSocketPool; |
| 70 | class TransportSecurityState; |
| 71 | |
bnc | 3171a243 | 2016-12-28 18:40:26 | [diff] [blame] | 72 | // Specifies the maximum HPACK dynamic table size the server is allowed to set. |
| 73 | const uint32_t kSpdyMaxHeaderTableSize = 64 * 1024; |
| 74 | |
| 75 | // Specifies the maximum concurrent streams server could send (via push). |
| 76 | const uint32_t kSpdyMaxConcurrentPushedStreams = 1000; |
| 77 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 78 | // This class holds session objects used by HttpNetworkTransaction objects. |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 79 | class NET_EXPORT HttpNetworkSession : public base::MemoryCoordinatorClient { |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 80 | public: |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 81 | // Self-contained structure with all the simple configuration options |
| 82 | // supported by the HttpNetworkSession. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 83 | struct NET_EXPORT Params { |
| 84 | Params(); |
vmpstr | acd23b7 | 2016-02-26 21:08:55 | [diff] [blame] | 85 | Params(const Params& other); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 86 | ~Params(); |
| 87 | |
Matt Menke | 53c5976 | 2017-09-14 16:38:12 | [diff] [blame] | 88 | enum class TcpFastOpenMode { |
| 89 | DISABLED, |
| 90 | // If true, TCP fast open will be used for all HTTPS connections. |
| 91 | ENABLED_FOR_SSL_ONLY, |
| 92 | // TCP fast open will be used for all HTTP/HTTPS connections. |
| 93 | // TODO(mmenke): With 0-RTT session resumption, does this option make |
| 94 | // sense? |
| 95 | ENABLED_FOR_ALL, |
| 96 | }; |
| 97 | |
zhongyi | d7dd2db1 | 2017-04-14 17:01:25 | [diff] [blame] | 98 | bool enable_server_push_cancellation; |
mmenke | 0d700dd8 | 2017-05-26 20:36:11 | [diff] [blame] | 99 | HostMappingRules host_mapping_rules; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 100 | bool ignore_certificate_errors; |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 101 | uint16_t testing_fixed_http_port; |
| 102 | uint16_t testing_fixed_https_port; |
Matt Menke | 53c5976 | 2017-09-14 16:38:12 | [diff] [blame] | 103 | TcpFastOpenMode tcp_fast_open_mode; |
rch | 1546ccd | 2017-04-20 02:14:23 | [diff] [blame] | 104 | bool enable_user_alternate_protocol_ports; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 105 | |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 106 | // Use SPDY ping frames to test for connection health after idle. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 107 | bool enable_spdy_ping_based_connection_checking; |
bnc | 3f0118e | 2016-02-02 15:42:22 | [diff] [blame] | 108 | bool enable_http2; |
bnc | 8f0f3b6 | 2015-04-08 04:37:23 | [diff] [blame] | 109 | size_t spdy_session_max_recv_window_size; |
bnc | 3171a243 | 2016-12-28 18:40:26 | [diff] [blame] | 110 | // HTTP/2 connection settings. |
| 111 | // Unknown settings will still be sent to the server. |
| 112 | SettingsMap http2_settings; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 113 | // Source of time for SPDY connections. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 114 | SpdySessionPool::TimeFunc time_func; |
bnc | a86731e | 2017-04-17 12:31:28 | [diff] [blame] | 115 | // Whether to enable HTTP/2 Alt-Svc entries. |
| 116 | bool enable_http2_alternative_service; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 117 | |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 118 | // Enables QUIC support. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 119 | bool enable_quic; |
rch | 1546ccd | 2017-04-20 02:14:23 | [diff] [blame] | 120 | |
| 121 | // QUIC runtime configuration options. |
| 122 | |
| 123 | // Versions of QUIC which may be used. |
Michael Warres | 74ee3ce | 2017-10-09 15:26:37 | [diff] [blame] | 124 | QuicTransportVersionVector quic_supported_versions; |
rch | 1546ccd | 2017-04-20 02:14:23 | [diff] [blame] | 125 | // User agent description to send in the QUIC handshake. |
| 126 | std::string quic_user_agent_id; |
| 127 | // Limit on the size of QUIC packets. |
| 128 | size_t quic_max_packet_length; |
rch | 1546ccd | 2017-04-20 02:14:23 | [diff] [blame] | 129 | // Maximum number of server configs that are to be stored in |
| 130 | // HttpServerProperties, instead of the disk cache. |
| 131 | size_t quic_max_server_configs_stored_in_properties; |
| 132 | // QUIC will be used for all connections in this set. |
| 133 | std::set<HostPortPair> origins_to_force_quic_on; |
| 134 | // Set of QUIC tags to send in the handshake's connection options. |
| 135 | QuicTagVector quic_connection_options; |
Yixin Wang | 46a425f | 2017-08-10 23:02:20 | [diff] [blame] | 136 | // Set of QUIC tags to send in the handshake's connection options that only |
| 137 | // affect the client. |
| 138 | QuicTagVector quic_client_connection_options; |
rch | 1546ccd | 2017-04-20 02:14:23 | [diff] [blame] | 139 | |
| 140 | // Active QUIC experiments |
| 141 | |
rch | 9ecde09b | 2017-04-08 00:18:23 | [diff] [blame] | 142 | // Marks a QUIC server broken when a connection blackholes after the |
| 143 | // handshake is confirmed. |
| 144 | bool mark_quic_broken_when_network_blackholes; |
rch | 2f2991c | 2017-04-13 19:28:17 | [diff] [blame] | 145 | // Retry requests which fail with QUIC_PROTOCOL_ERROR, and mark QUIC |
| 146 | // broken if the retry succeeds. |
| 147 | bool retry_without_alt_svc_on_quic_errors; |
Yixin Wang | a9afead | 2017-10-19 20:23:10 | [diff] [blame] | 148 | // If true, alt-svc headers advertising QUIC in IETF format will be |
| 149 | // supported. |
| 150 | bool support_ietf_format_quic_altsvc; |
Jana Iyengar | 903dec2 | 2017-11-28 00:44:23 | [diff] [blame^] | 151 | // If true, all QUIC sessions are closed when any local IP address changes. |
| 152 | bool quic_close_sessions_on_ip_change; |
zhongyi | 6ba0f425 | 2016-08-23 05:20:04 | [diff] [blame] | 153 | // Specifies QUIC idle connection state lifetime. |
rtenneti | 41c0999 | 2015-11-30 18:24:01 | [diff] [blame] | 154 | int quic_idle_connection_timeout_seconds; |
zhongyi | dd1439f6 | 2016-09-02 02:02:26 | [diff] [blame] | 155 | // Specifies the reduced ping timeout subsequent connections should use when |
| 156 | // a connection was timed out with open streams. |
| 157 | int quic_reduced_ping_timeout_seconds; |
Yixin Wang | 469da56 | 2017-11-15 21:34:58 | [diff] [blame] | 158 | // Maximum time the session can be alive before crypto handshake is |
| 159 | // finished. |
| 160 | int quic_max_time_before_crypto_handshake_seconds; |
| 161 | // Maximum idle time before the crypto handshake has completed. |
| 162 | int quic_max_idle_time_before_crypto_handshake_seconds; |
Zhongyi Shi | 1a605d2 | 2017-09-29 20:09:48 | [diff] [blame] | 163 | // If true, QUIC will attempt to explicitly use default network for sockets. |
| 164 | bool quic_connect_using_default_network; |
jri | d36ada6 | 2016-02-06 02:42:08 | [diff] [blame] | 165 | // If true, active QUIC sessions may be migrated onto a new network when |
| 166 | // the platform indicates that the default network is changing. |
jri | 7e63664 | 2016-01-14 06:57:08 | [diff] [blame] | 167 | bool quic_migrate_sessions_on_network_change; |
Zhongyi Shi | 6479562 | 2017-11-20 02:21:49 | [diff] [blame] | 168 | // If true, connection migration v2 will be used to migrate existing |
| 169 | // sessions to network when the platform indicates that the default network |
| 170 | // is changing. |
| 171 | bool quic_migrate_sessions_on_network_change_v2; |
jri | d36ada6 | 2016-02-06 02:42:08 | [diff] [blame] | 172 | // If true, active QUIC sessions experiencing poor connectivity may be |
| 173 | // migrated onto a new network. |
| 174 | bool quic_migrate_sessions_early; |
jri | 217455a1 | 2016-07-13 20:15:09 | [diff] [blame] | 175 | // If true, allows migration of QUIC connections to a server-specified |
| 176 | // alternate server address. |
| 177 | bool quic_allow_server_migration; |
Ryan Hamilton | c84473f | 2017-11-23 03:18:34 | [diff] [blame] | 178 | // If true, allows QUIC to use alternative services with a different |
| 179 | // hostname from the origin. |
| 180 | bool quic_allow_remote_alt_svc; |
xunjieli | 888c2992 | 2016-03-18 21:05:09 | [diff] [blame] | 181 | // If true, bidirectional streams over QUIC will be disabled. |
| 182 | bool quic_disable_bidirectional_streams; |
ckrasic | da193a8 | 2016-07-09 00:39:36 | [diff] [blame] | 183 | // If true, enable force HOL blocking. For measurement purposes. |
| 184 | bool quic_force_hol_blocking; |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 185 | // If true, race cert verification with host resolution. |
| 186 | bool quic_race_cert_verification; |
rch | d6163f3 | 2017-01-30 23:50:38 | [diff] [blame] | 187 | // If true, estimate the initial RTT for QUIC connections based on network. |
| 188 | bool quic_estimate_initial_rtt; |
Yixin Wang | 10f477ed | 2017-11-21 04:20:20 | [diff] [blame] | 189 | // If non-empty, QUIC will only be spoken to hosts in this list. |
| 190 | base::flat_set<std::string> quic_host_whitelist; |
xunjieli | 888c2992 | 2016-03-18 21:05:09 | [diff] [blame] | 191 | |
nharper | b7441ef | 2016-01-25 23:54:14 | [diff] [blame] | 192 | // Enable support for Token Binding. |
| 193 | bool enable_token_binding; |
mmenke | a7da6da | 2016-09-01 21:56:52 | [diff] [blame] | 194 | |
| 195 | // Enable HTTP/0.9 for HTTP/HTTPS on ports other than the default one for |
| 196 | // each protocol. |
| 197 | bool http_09_on_non_default_ports_enabled; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 198 | }; |
| 199 | |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 200 | // Structure with pointers to the dependencies of the HttpNetworkSession. |
| 201 | // These objects must all outlive the HttpNetworkSession. |
| 202 | struct NET_EXPORT Context { |
| 203 | Context(); |
| 204 | Context(const Context& other); |
| 205 | ~Context(); |
| 206 | |
| 207 | ClientSocketFactory* client_socket_factory; |
| 208 | HostResolver* host_resolver; |
| 209 | CertVerifier* cert_verifier; |
| 210 | ChannelIDService* channel_id_service; |
| 211 | TransportSecurityState* transport_security_state; |
| 212 | CTVerifier* cert_transparency_verifier; |
| 213 | CTPolicyEnforcer* ct_policy_enforcer; |
| 214 | ProxyService* proxy_service; |
| 215 | SSLConfigService* ssl_config_service; |
| 216 | HttpAuthHandlerFactory* http_auth_handler_factory; |
| 217 | HttpServerProperties* http_server_properties; |
| 218 | NetLog* net_log; |
| 219 | SocketPerformanceWatcherFactory* socket_performance_watcher_factory; |
tbansal | 16196a1e | 2017-06-09 01:50:09 | [diff] [blame] | 220 | NetworkQualityProvider* network_quality_provider; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 221 | |
| 222 | // Source of time for QUIC connections. |
| 223 | QuicClock* quic_clock; |
| 224 | // Source of entropy for QUIC connections. |
| 225 | QuicRandom* quic_random; |
| 226 | // Optional factory to use for creating QuicCryptoClientStreams. |
| 227 | QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory; |
| 228 | |
| 229 | ProxyDelegate* proxy_delegate; |
| 230 | }; |
| 231 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 232 | enum SocketPoolType { |
| 233 | NORMAL_SOCKET_POOL, |
| 234 | WEBSOCKET_SOCKET_POOL, |
| 235 | NUM_SOCKET_POOL_TYPES |
| 236 | }; |
| 237 | |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 238 | HttpNetworkSession(const Params& params, const Context& context); |
hajimehoshi | 8156e7c | 2016-09-29 06:17:52 | [diff] [blame] | 239 | ~HttpNetworkSession() override; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 240 | |
| 241 | HttpAuthCache* http_auth_cache() { return &http_auth_cache_; } |
| 242 | SSLClientAuthCache* ssl_client_auth_cache() { |
| 243 | return &ssl_client_auth_cache_; |
| 244 | } |
| 245 | |
avi | fceb32f6 | 2016-10-07 16:30:52 | [diff] [blame] | 246 | void AddResponseDrainer(std::unique_ptr<HttpResponseBodyDrainer> drainer); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 247 | |
avi | fceb32f6 | 2016-10-07 16:30:52 | [diff] [blame] | 248 | // Removes the drainer from the session. Does not dispose of it. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 249 | void RemoveResponseDrainer(HttpResponseBodyDrainer* drainer); |
| 250 | |
| 251 | TransportClientSocketPool* GetTransportSocketPool(SocketPoolType pool_type); |
| 252 | SSLClientSocketPool* GetSSLSocketPool(SocketPoolType pool_type); |
| 253 | SOCKSClientSocketPool* GetSocketPoolForSOCKSProxy( |
| 254 | SocketPoolType pool_type, |
| 255 | const HostPortPair& socks_proxy); |
| 256 | HttpProxyClientSocketPool* GetSocketPoolForHTTPProxy( |
| 257 | SocketPoolType pool_type, |
| 258 | const HostPortPair& http_proxy); |
| 259 | SSLClientSocketPool* GetSocketPoolForSSLWithProxy( |
| 260 | SocketPoolType pool_type, |
| 261 | const HostPortPair& proxy_server); |
| 262 | |
| 263 | CertVerifier* cert_verifier() { return cert_verifier_; } |
| 264 | ProxyService* proxy_service() { return proxy_service_; } |
| 265 | SSLConfigService* ssl_config_service() { return ssl_config_service_.get(); } |
| 266 | SpdySessionPool* spdy_session_pool() { return &spdy_session_pool_; } |
| 267 | QuicStreamFactory* quic_stream_factory() { return &quic_stream_factory_; } |
| 268 | HttpAuthHandlerFactory* http_auth_handler_factory() { |
| 269 | return http_auth_handler_factory_; |
| 270 | } |
bnc | 525e175a | 2016-06-20 12:36:40 | [diff] [blame] | 271 | HttpServerProperties* http_server_properties() { |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 272 | return http_server_properties_; |
| 273 | } |
| 274 | HttpStreamFactory* http_stream_factory() { |
| 275 | return http_stream_factory_.get(); |
| 276 | } |
| 277 | HttpStreamFactory* http_stream_factory_for_websocket() { |
| 278 | return http_stream_factory_for_websocket_.get(); |
| 279 | } |
rdsmith | 1d343be5 | 2016-10-21 20:37:50 | [diff] [blame] | 280 | NetworkThrottleManager* throttler() { |
| 281 | return network_stream_throttler_.get(); |
| 282 | } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 283 | NetLog* net_log() { |
| 284 | return net_log_; |
| 285 | } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 286 | |
payal.pandey | 62a40029 | 2015-05-28 09:29:54 | [diff] [blame] | 287 | // Creates a Value summary of the state of the socket pools. |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 288 | std::unique_ptr<base::Value> SocketPoolInfoToValue() const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 289 | |
payal.pandey | 91cb231 | 2015-05-27 07:41:51 | [diff] [blame] | 290 | // Creates a Value summary of the state of the SPDY sessions. |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 291 | std::unique_ptr<base::Value> SpdySessionPoolInfoToValue() const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 292 | |
| 293 | // Creates a Value summary of the state of the QUIC sessions and |
payal.pandey | a18956a | 2015-05-27 05:57:55 | [diff] [blame] | 294 | // configuration. |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 295 | std::unique_ptr<base::Value> QuicInfoToValue() const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 296 | |
| 297 | void CloseAllConnections(); |
| 298 | void CloseIdleConnections(); |
| 299 | |
| 300 | // Returns the original Params used to construct this session. |
| 301 | const Params& params() const { return params_; } |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 302 | // Returns the original Context used to construct this session. |
| 303 | const Context& context() const { return context_; } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 304 | |
bnc | 3472afd | 2016-11-17 15:27:21 | [diff] [blame] | 305 | bool IsProtocolEnabled(NextProto protocol) const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 306 | |
zhongyi | af25754 | 2016-12-19 03:36:01 | [diff] [blame] | 307 | void SetServerPushDelegate(std::unique_ptr<ServerPushDelegate> push_delegate); |
| 308 | |
bnc | 1f29537 | 2015-10-21 23:24:22 | [diff] [blame] | 309 | // Populates |*alpn_protos| with protocols to be used with ALPN. |
| 310 | void GetAlpnProtos(NextProtoVector* alpn_protos) const; |
| 311 | |
nharper | 8cdb0fb | 2016-04-22 21:34:59 | [diff] [blame] | 312 | // Populates |server_config| and |proxy_config| based on this session and |
| 313 | // |request|. |
| 314 | void GetSSLConfig(const HttpRequestInfo& request, |
| 315 | SSLConfig* server_config, |
| 316 | SSLConfig* proxy_config) const; |
| 317 | |
xunjieli | 9f8c5fb5 | 2016-12-07 22:59:33 | [diff] [blame] | 318 | // Dumps memory allocation stats. |parent_dump_absolute_name| is the name |
| 319 | // used by the parent MemoryAllocatorDump in the memory dump hierarchy. |
| 320 | void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd, |
| 321 | const std::string& parent_absolute_name) const; |
| 322 | |
pmarko | 6ab8be24 | 2017-01-11 11:02:55 | [diff] [blame] | 323 | // Evaluates if QUIC is enabled for new streams. |
| 324 | bool IsQuicEnabled() const; |
| 325 | |
| 326 | // Disable QUIC for new streams. |
| 327 | void DisableQuic(); |
| 328 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 329 | private: |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 330 | friend class HttpNetworkSessionPeer; |
| 331 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 332 | ClientSocketPoolManager* GetSocketPoolManager(SocketPoolType pool_type); |
| 333 | |
maksim.sisov | 0adf859 | 2016-07-15 06:25:56 | [diff] [blame] | 334 | // Flush sockets on low memory notifications callback. |
| 335 | void OnMemoryPressure( |
| 336 | base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
| 337 | |
hajimehoshi | 8156e7c | 2016-09-29 06:17:52 | [diff] [blame] | 338 | // base::MemoryCoordinatorClient implementation: |
bashi | 56b23f30 | 2017-02-09 01:24:57 | [diff] [blame] | 339 | void OnPurgeMemory() override; |
hajimehoshi | 8156e7c | 2016-09-29 06:17:52 | [diff] [blame] | 340 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 341 | NetLog* const net_log_; |
bnc | 525e175a | 2016-06-20 12:36:40 | [diff] [blame] | 342 | HttpServerProperties* const http_server_properties_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 343 | CertVerifier* const cert_verifier_; |
| 344 | HttpAuthHandlerFactory* const http_auth_handler_factory_; |
| 345 | |
| 346 | // Not const since it's modified by HttpNetworkSessionPeer for testing. |
| 347 | ProxyService* proxy_service_; |
| 348 | const scoped_refptr<SSLConfigService> ssl_config_service_; |
| 349 | |
| 350 | HttpAuthCache http_auth_cache_; |
| 351 | SSLClientAuthCache ssl_client_auth_cache_; |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 352 | std::unique_ptr<ClientSocketPoolManager> normal_socket_pool_manager_; |
| 353 | std::unique_ptr<ClientSocketPoolManager> websocket_socket_pool_manager_; |
zhongyi | af25754 | 2016-12-19 03:36:01 | [diff] [blame] | 354 | std::unique_ptr<ServerPushDelegate> push_delegate_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 355 | QuicStreamFactory quic_stream_factory_; |
| 356 | SpdySessionPool spdy_session_pool_; |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 357 | std::unique_ptr<HttpStreamFactory> http_stream_factory_; |
| 358 | std::unique_ptr<HttpStreamFactory> http_stream_factory_for_websocket_; |
avi | fceb32f6 | 2016-10-07 16:30:52 | [diff] [blame] | 359 | std::map<HttpResponseBodyDrainer*, std::unique_ptr<HttpResponseBodyDrainer>> |
| 360 | response_drainers_; |
rdsmith | 1d343be5 | 2016-10-21 20:37:50 | [diff] [blame] | 361 | std::unique_ptr<NetworkThrottleManager> network_stream_throttler_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 362 | |
bnc | 0d23cf4 | 2014-12-11 14:09:46 | [diff] [blame] | 363 | NextProtoVector next_protos_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 364 | |
| 365 | Params params_; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 366 | Context context_; |
maksim.sisov | 0adf859 | 2016-07-15 06:25:56 | [diff] [blame] | 367 | |
| 368 | std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 369 | |
| 370 | THREAD_CHECKER(thread_checker_); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 371 | }; |
| 372 | |
| 373 | } // namespace net |
| 374 | |
| 375 | #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_ |