[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" |
hajimehoshi | 8156e7c | 2016-09-29 06:17:52 | [diff] [blame] | 19 | #include "base/memory/memory_coordinator_client.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" |
| 23 | #include "base/threading/non_thread_safe.h" |
| 24 | #include "net/base/host_port_pair.h" |
| 25 | #include "net/base/net_export.h" |
| 26 | #include "net/dns/host_resolver.h" |
| 27 | #include "net/http/http_auth_cache.h" |
| 28 | #include "net/http/http_stream_factory.h" |
rch | 675757b | 2016-07-29 16:40:11 | [diff] [blame] | 29 | #include "net/quic/chromium/quic_stream_factory.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 30 | #include "net/socket/next_proto.h" |
bnc | 3171a243 | 2016-12-28 18:40:26 | [diff] [blame] | 31 | #include "net/spdy/spdy_protocol.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 32 | #include "net/spdy/spdy_session_pool.h" |
| 33 | #include "net/ssl/ssl_client_auth_cache.h" |
| 34 | |
| 35 | namespace base { |
| 36 | class Value; |
xunjieli | 9f8c5fb5 | 2016-12-07 22:59:33 | [diff] [blame] | 37 | namespace trace_event { |
| 38 | class ProcessMemoryDump; |
| 39 | } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | namespace net { |
| 43 | |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 44 | class CTPolicyEnforcer; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 45 | class CertVerifier; |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 46 | class ChannelIDService; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 47 | class ClientSocketFactory; |
| 48 | class ClientSocketPoolManager; |
| 49 | class CTVerifier; |
| 50 | class HostResolver; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 51 | class HttpAuthHandlerFactory; |
| 52 | class HttpNetworkSessionPeer; |
| 53 | class HttpProxyClientSocketPool; |
| 54 | class HttpResponseBodyDrainer; |
| 55 | class HttpServerProperties; |
| 56 | class NetLog; |
rdsmith | 1d343be5 | 2016-10-21 20:37:50 | [diff] [blame] | 57 | class NetworkThrottleManager; |
bengr | 39e40610 | 2014-09-10 23:04:46 | [diff] [blame] | 58 | class ProxyDelegate; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 59 | class ProxyService; |
| 60 | class QuicClock; |
| 61 | class QuicCryptoClientStreamFactory; |
tbansal | ba8f411 | 2015-09-03 21:57:19 | [diff] [blame] | 62 | class SocketPerformanceWatcherFactory; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 63 | class SOCKSClientSocketPool; |
| 64 | class SSLClientSocketPool; |
| 65 | class SSLConfigService; |
| 66 | class TransportClientSocketPool; |
| 67 | class TransportSecurityState; |
| 68 | |
bnc | 3171a243 | 2016-12-28 18:40:26 | [diff] [blame] | 69 | // Specifies the maximum HPACK dynamic table size the server is allowed to set. |
| 70 | const uint32_t kSpdyMaxHeaderTableSize = 64 * 1024; |
| 71 | |
| 72 | // Specifies the maximum concurrent streams server could send (via push). |
| 73 | const uint32_t kSpdyMaxConcurrentPushedStreams = 1000; |
| 74 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 75 | // This class holds session objects used by HttpNetworkTransaction objects. |
| 76 | class NET_EXPORT HttpNetworkSession |
hajimehoshi | 8156e7c | 2016-09-29 06:17:52 | [diff] [blame] | 77 | : NON_EXPORTED_BASE(public base::NonThreadSafe), |
| 78 | public base::MemoryCoordinatorClient { |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 79 | public: |
| 80 | struct NET_EXPORT Params { |
| 81 | Params(); |
vmpstr | acd23b7 | 2016-02-26 21:08:55 | [diff] [blame] | 82 | Params(const Params& other); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 83 | ~Params(); |
| 84 | |
| 85 | ClientSocketFactory* client_socket_factory; |
| 86 | HostResolver* host_resolver; |
| 87 | CertVerifier* cert_verifier; |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 88 | ChannelIDService* channel_id_service; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 89 | TransportSecurityState* transport_security_state; |
| 90 | CTVerifier* cert_transparency_verifier; |
rsleevi | d6de830 | 2016-06-21 01:33:20 | [diff] [blame] | 91 | CTPolicyEnforcer* ct_policy_enforcer; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 92 | ProxyService* proxy_service; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 93 | SSLConfigService* ssl_config_service; |
| 94 | HttpAuthHandlerFactory* http_auth_handler_factory; |
bnc | 525e175a | 2016-06-20 12:36:40 | [diff] [blame] | 95 | HttpServerProperties* http_server_properties; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 96 | NetLog* net_log; |
| 97 | HostMappingRules* host_mapping_rules; |
tbansal | ba8f411 | 2015-09-03 21:57:19 | [diff] [blame] | 98 | SocketPerformanceWatcherFactory* socket_performance_watcher_factory; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 99 | bool ignore_certificate_errors; |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 100 | uint16_t testing_fixed_http_port; |
| 101 | uint16_t testing_fixed_https_port; |
jri | f9b4bec | 2014-09-15 15:46:54 | [diff] [blame] | 102 | bool enable_tcp_fast_open_for_ssl; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 103 | |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 104 | // Use SPDY ping frames to test for connection health after idle. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 105 | bool enable_spdy_ping_based_connection_checking; |
bnc | 3f0118e | 2016-02-02 15:42:22 | [diff] [blame] | 106 | bool enable_http2; |
bnc | 8f0f3b6 | 2015-04-08 04:37:23 | [diff] [blame] | 107 | size_t spdy_session_max_recv_window_size; |
bnc | 3171a243 | 2016-12-28 18:40:26 | [diff] [blame] | 108 | // HTTP/2 connection settings. |
| 109 | // Unknown settings will still be sent to the server. |
| 110 | SettingsMap http2_settings; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 111 | // Source of time for SPDY connections. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 112 | SpdySessionPool::TimeFunc time_func; |
bnc | a8681534 | 2016-06-27 12:27:48 | [diff] [blame] | 113 | // Whether to enable HTTP/2 Alt-Svc entries with hostname different than |
| 114 | // that of the origin. |
| 115 | bool enable_http2_alternative_service_with_different_host; |
| 116 | // Whether to enable QUIC Alt-Svc entries with hostname different than that |
| 117 | // of the origin. |
| 118 | bool enable_quic_alternative_service_with_different_host; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 119 | |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 120 | // Enables QUIC support. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 121 | bool enable_quic; |
rch | 9ecde09b | 2017-04-08 00:18:23 | [diff] [blame^] | 122 | // Marks a QUIC server broken when a connection blackholes after the |
| 123 | // handshake is confirmed. |
| 124 | bool mark_quic_broken_when_network_blackholes; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 125 | // Disables QUIC's 0-RTT behavior. |
jri | 2b966f2 | 2014-09-02 22:25:36 | [diff] [blame] | 126 | bool quic_always_require_handshake_confirmation; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 127 | // Disables QUIC connection pooling. |
jri | 584002d1 | 2014-09-09 00:51:28 | [diff] [blame] | 128 | bool quic_disable_connection_pooling; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 129 | // If not zero, the task to load QUIC server configs from the disk cache |
| 130 | // will timeout after this value multiplied by the smoothed RTT for the |
| 131 | // server. |
rtenneti | 2912825c | 2015-01-06 01:19:46 | [diff] [blame] | 132 | float quic_load_server_info_timeout_srtt_multiplier; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 133 | // Causes QUIC to race reading the server config from disk with |
| 134 | // sending an inchoate CHLO. |
rtenneti | 4f80997 | 2015-02-11 19:38:34 | [diff] [blame] | 135 | bool quic_enable_connection_racing; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 136 | // Use non-blocking IO for UDP sockets. |
qyearsley | 3257b7de | 2015-02-28 06:59:03 | [diff] [blame] | 137 | bool quic_enable_non_blocking_io; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 138 | // Disables using the disk cache to store QUIC server configs. |
rtenneti | 34dffe75 | 2015-02-24 23:27:32 | [diff] [blame] | 139 | bool quic_disable_disk_cache; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 140 | // Prefer AES-GCM to ChaCha20 even if no hardware support is present. |
rch | 9976b0c | 2015-06-10 21:27:23 | [diff] [blame] | 141 | bool quic_prefer_aes; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 142 | // Size in bytes of the QUIC DUP socket receive buffer. |
rch | c743357 | 2015-02-27 18:16:51 | [diff] [blame] | 143 | int quic_socket_receive_buffer_size; |
rtenneti | b8e80fb | 2016-05-16 00:12:09 | [diff] [blame] | 144 | // Delay starting a TCP connection when QUIC believes it can speak |
| 145 | // 0-RTT to a server. |
| 146 | bool quic_delay_tcp_race; |
rtenneti | 6971c17 | 2016-01-15 20:12:10 | [diff] [blame] | 147 | // Maximum number of server configs that are to be stored in |
| 148 | // HttpServerProperties, instead of the disk cache. |
| 149 | size_t quic_max_server_configs_stored_in_properties; |
rtenneti | 8a2f463 | 2016-03-21 20:26:57 | [diff] [blame] | 150 | // If not empty, QUIC will be used for all connections to the set of |
| 151 | // origins in |origins_to_force_quic_on|. |
| 152 | std::set<HostPortPair> origins_to_force_quic_on; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 153 | // Source of time for QUIC connections. Will be owned by QuicStreamFactory. |
| 154 | QuicClock* quic_clock; |
| 155 | // Source of entropy for QUIC connections. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 156 | QuicRandom* quic_random; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 157 | // Limit on the size of QUIC packets. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 158 | size_t quic_max_packet_length; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 159 | // User agent description to send in the QUIC handshake. |
[email protected] | 0c4017ca | 2014-06-06 03:30:45 | [diff] [blame] | 160 | std::string quic_user_agent_id; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 161 | bool enable_user_alternate_protocol_ports; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 162 | // Optional factory to use for creating QuicCryptoClientStreams. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 163 | QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory; |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 164 | // Versions of QUIC which may be used. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 165 | QuicVersionVector quic_supported_versions; |
jri | 8c44d69 | 2015-10-23 23:53:41 | [diff] [blame] | 166 | // Set of QUIC tags to send in the handshake's connection options. |
[email protected] | 488a0e25 | 2014-06-25 04:37:44 | [diff] [blame] | 167 | QuicTagVector quic_connection_options; |
jri | 8c44d69 | 2015-10-23 23:53:41 | [diff] [blame] | 168 | // If true, all QUIC sessions are closed when any local IP address changes. |
| 169 | bool quic_close_sessions_on_ip_change; |
zhongyi | 6ba0f425 | 2016-08-23 05:20:04 | [diff] [blame] | 170 | // Specifies QUIC idle connection state lifetime. |
rtenneti | 41c0999 | 2015-11-30 18:24:01 | [diff] [blame] | 171 | int quic_idle_connection_timeout_seconds; |
zhongyi | dd1439f6 | 2016-09-02 02:02:26 | [diff] [blame] | 172 | // Specifies the reduced ping timeout subsequent connections should use when |
| 173 | // a connection was timed out with open streams. |
| 174 | int quic_reduced_ping_timeout_seconds; |
zhongyi | 6ba0f425 | 2016-08-23 05:20:04 | [diff] [blame] | 175 | // Specifies the maximum time duration that QUIC packet reader can perform |
| 176 | // consecutive packets reading. |
| 177 | int quic_packet_reader_yield_after_duration_milliseconds; |
rtenneti | d2e74caa | 2015-12-09 00:51:57 | [diff] [blame] | 178 | // If true, disable preconnections if QUIC can do 0RTT. |
| 179 | bool quic_disable_preconnect_if_0rtt; |
rch | 74da0e1a | 2016-01-14 02:49:32 | [diff] [blame] | 180 | // List of hosts for which QUIC is explicitly whitelisted. |
| 181 | std::unordered_set<std::string> quic_host_whitelist; |
jri | d36ada6 | 2016-02-06 02:42:08 | [diff] [blame] | 182 | // If true, active QUIC sessions may be migrated onto a new network when |
| 183 | // the platform indicates that the default network is changing. |
jri | 7e63664 | 2016-01-14 06:57:08 | [diff] [blame] | 184 | bool quic_migrate_sessions_on_network_change; |
jri | d36ada6 | 2016-02-06 02:42:08 | [diff] [blame] | 185 | // If true, active QUIC sessions experiencing poor connectivity may be |
| 186 | // migrated onto a new network. |
| 187 | bool quic_migrate_sessions_early; |
jri | 217455a1 | 2016-07-13 20:15:09 | [diff] [blame] | 188 | // If true, allows migration of QUIC connections to a server-specified |
| 189 | // alternate server address. |
| 190 | bool quic_allow_server_migration; |
xunjieli | 888c2992 | 2016-03-18 21:05:09 | [diff] [blame] | 191 | // If true, bidirectional streams over QUIC will be disabled. |
| 192 | bool quic_disable_bidirectional_streams; |
ckrasic | da193a8 | 2016-07-09 00:39:36 | [diff] [blame] | 193 | // If true, enable force HOL blocking. For measurement purposes. |
| 194 | bool quic_force_hol_blocking; |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 195 | // If true, race cert verification with host resolution. |
| 196 | bool quic_race_cert_verification; |
rch | bedd5745 | 2016-08-30 19:11:48 | [diff] [blame] | 197 | // If true, configure QUIC sockets to not fragment packets. |
| 198 | bool quic_do_not_fragment; |
tbansal | 6b52748 | 2017-01-27 19:10:49 | [diff] [blame] | 199 | // If true, alternative service is not marked as broken if the alternative |
| 200 | // job fails due to a network change event. |
| 201 | bool quic_do_not_mark_as_broken_on_network_change; |
rch | d6163f3 | 2017-01-30 23:50:38 | [diff] [blame] | 202 | // If true, estimate the initial RTT for QUIC connections based on network. |
| 203 | bool quic_estimate_initial_rtt; |
xunjieli | 888c2992 | 2016-03-18 21:05:09 | [diff] [blame] | 204 | |
bengr | 39e40610 | 2014-09-10 23:04:46 | [diff] [blame] | 205 | ProxyDelegate* proxy_delegate; |
nharper | b7441ef | 2016-01-25 23:54:14 | [diff] [blame] | 206 | // Enable support for Token Binding. |
| 207 | bool enable_token_binding; |
mmenke | a7da6da | 2016-09-01 21:56:52 | [diff] [blame] | 208 | |
| 209 | // Enable HTTP/0.9 for HTTP/HTTPS on ports other than the default one for |
| 210 | // each protocol. |
| 211 | bool http_09_on_non_default_ports_enabled; |
tbansal | 7450edf | 2016-12-28 21:12:53 | [diff] [blame] | 212 | |
| 213 | // If true, only one pending preconnect is allowed to proxies that support |
| 214 | // request priorities. |
| 215 | bool restrict_to_one_preconnect_for_proxies; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 216 | }; |
| 217 | |
| 218 | enum SocketPoolType { |
| 219 | NORMAL_SOCKET_POOL, |
| 220 | WEBSOCKET_SOCKET_POOL, |
| 221 | NUM_SOCKET_POOL_TYPES |
| 222 | }; |
| 223 | |
| 224 | explicit HttpNetworkSession(const Params& params); |
hajimehoshi | 8156e7c | 2016-09-29 06:17:52 | [diff] [blame] | 225 | ~HttpNetworkSession() override; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 226 | |
| 227 | HttpAuthCache* http_auth_cache() { return &http_auth_cache_; } |
| 228 | SSLClientAuthCache* ssl_client_auth_cache() { |
| 229 | return &ssl_client_auth_cache_; |
| 230 | } |
| 231 | |
avi | fceb32f6 | 2016-10-07 16:30:52 | [diff] [blame] | 232 | void AddResponseDrainer(std::unique_ptr<HttpResponseBodyDrainer> drainer); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 233 | |
avi | fceb32f6 | 2016-10-07 16:30:52 | [diff] [blame] | 234 | // Removes the drainer from the session. Does not dispose of it. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 235 | void RemoveResponseDrainer(HttpResponseBodyDrainer* drainer); |
| 236 | |
| 237 | TransportClientSocketPool* GetTransportSocketPool(SocketPoolType pool_type); |
| 238 | SSLClientSocketPool* GetSSLSocketPool(SocketPoolType pool_type); |
| 239 | SOCKSClientSocketPool* GetSocketPoolForSOCKSProxy( |
| 240 | SocketPoolType pool_type, |
| 241 | const HostPortPair& socks_proxy); |
| 242 | HttpProxyClientSocketPool* GetSocketPoolForHTTPProxy( |
| 243 | SocketPoolType pool_type, |
| 244 | const HostPortPair& http_proxy); |
| 245 | SSLClientSocketPool* GetSocketPoolForSSLWithProxy( |
| 246 | SocketPoolType pool_type, |
| 247 | const HostPortPair& proxy_server); |
| 248 | |
| 249 | CertVerifier* cert_verifier() { return cert_verifier_; } |
| 250 | ProxyService* proxy_service() { return proxy_service_; } |
| 251 | SSLConfigService* ssl_config_service() { return ssl_config_service_.get(); } |
| 252 | SpdySessionPool* spdy_session_pool() { return &spdy_session_pool_; } |
| 253 | QuicStreamFactory* quic_stream_factory() { return &quic_stream_factory_; } |
| 254 | HttpAuthHandlerFactory* http_auth_handler_factory() { |
| 255 | return http_auth_handler_factory_; |
| 256 | } |
bnc | 525e175a | 2016-06-20 12:36:40 | [diff] [blame] | 257 | HttpServerProperties* http_server_properties() { |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 258 | return http_server_properties_; |
| 259 | } |
| 260 | HttpStreamFactory* http_stream_factory() { |
| 261 | return http_stream_factory_.get(); |
| 262 | } |
| 263 | HttpStreamFactory* http_stream_factory_for_websocket() { |
| 264 | return http_stream_factory_for_websocket_.get(); |
| 265 | } |
rdsmith | 1d343be5 | 2016-10-21 20:37:50 | [diff] [blame] | 266 | NetworkThrottleManager* throttler() { |
| 267 | return network_stream_throttler_.get(); |
| 268 | } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 269 | NetLog* net_log() { |
| 270 | return net_log_; |
| 271 | } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 272 | |
payal.pandey | 62a40029 | 2015-05-28 09:29:54 | [diff] [blame] | 273 | // Creates a Value summary of the state of the socket pools. |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 274 | std::unique_ptr<base::Value> SocketPoolInfoToValue() const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 275 | |
payal.pandey | 91cb231 | 2015-05-27 07:41:51 | [diff] [blame] | 276 | // Creates a Value summary of the state of the SPDY sessions. |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 277 | std::unique_ptr<base::Value> SpdySessionPoolInfoToValue() const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 278 | |
| 279 | // Creates a Value summary of the state of the QUIC sessions and |
payal.pandey | a18956a | 2015-05-27 05:57:55 | [diff] [blame] | 280 | // configuration. |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 281 | std::unique_ptr<base::Value> QuicInfoToValue() const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 282 | |
| 283 | void CloseAllConnections(); |
| 284 | void CloseIdleConnections(); |
| 285 | |
| 286 | // Returns the original Params used to construct this session. |
| 287 | const Params& params() const { return params_; } |
| 288 | |
bnc | 3472afd | 2016-11-17 15:27:21 | [diff] [blame] | 289 | bool IsProtocolEnabled(NextProto protocol) const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 290 | |
zhongyi | af25754 | 2016-12-19 03:36:01 | [diff] [blame] | 291 | void SetServerPushDelegate(std::unique_ptr<ServerPushDelegate> push_delegate); |
| 292 | |
bnc | 1f29537 | 2015-10-21 23:24:22 | [diff] [blame] | 293 | // Populates |*alpn_protos| with protocols to be used with ALPN. |
| 294 | void GetAlpnProtos(NextProtoVector* alpn_protos) const; |
| 295 | |
nharper | 8cdb0fb | 2016-04-22 21:34:59 | [diff] [blame] | 296 | // Populates |server_config| and |proxy_config| based on this session and |
| 297 | // |request|. |
| 298 | void GetSSLConfig(const HttpRequestInfo& request, |
| 299 | SSLConfig* server_config, |
| 300 | SSLConfig* proxy_config) const; |
| 301 | |
xunjieli | 9f8c5fb5 | 2016-12-07 22:59:33 | [diff] [blame] | 302 | // Dumps memory allocation stats. |parent_dump_absolute_name| is the name |
| 303 | // used by the parent MemoryAllocatorDump in the memory dump hierarchy. |
| 304 | void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd, |
| 305 | const std::string& parent_absolute_name) const; |
| 306 | |
pmarko | 6ab8be24 | 2017-01-11 11:02:55 | [diff] [blame] | 307 | // Evaluates if QUIC is enabled for new streams. |
| 308 | bool IsQuicEnabled() const; |
| 309 | |
| 310 | // Disable QUIC for new streams. |
| 311 | void DisableQuic(); |
| 312 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 313 | private: |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 314 | friend class HttpNetworkSessionPeer; |
| 315 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 316 | ClientSocketPoolManager* GetSocketPoolManager(SocketPoolType pool_type); |
| 317 | |
maksim.sisov | 0adf859 | 2016-07-15 06:25:56 | [diff] [blame] | 318 | // Flush sockets on low memory notifications callback. |
| 319 | void OnMemoryPressure( |
| 320 | base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
| 321 | |
hajimehoshi | 8156e7c | 2016-09-29 06:17:52 | [diff] [blame] | 322 | // base::MemoryCoordinatorClient implementation: |
bashi | 56b23f30 | 2017-02-09 01:24:57 | [diff] [blame] | 323 | void OnPurgeMemory() override; |
hajimehoshi | 8156e7c | 2016-09-29 06:17:52 | [diff] [blame] | 324 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 325 | NetLog* const net_log_; |
bnc | 525e175a | 2016-06-20 12:36:40 | [diff] [blame] | 326 | HttpServerProperties* const http_server_properties_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 327 | CertVerifier* const cert_verifier_; |
| 328 | HttpAuthHandlerFactory* const http_auth_handler_factory_; |
| 329 | |
| 330 | // Not const since it's modified by HttpNetworkSessionPeer for testing. |
| 331 | ProxyService* proxy_service_; |
| 332 | const scoped_refptr<SSLConfigService> ssl_config_service_; |
| 333 | |
| 334 | HttpAuthCache http_auth_cache_; |
| 335 | SSLClientAuthCache ssl_client_auth_cache_; |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 336 | std::unique_ptr<ClientSocketPoolManager> normal_socket_pool_manager_; |
| 337 | std::unique_ptr<ClientSocketPoolManager> websocket_socket_pool_manager_; |
zhongyi | af25754 | 2016-12-19 03:36:01 | [diff] [blame] | 338 | std::unique_ptr<ServerPushDelegate> push_delegate_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 339 | QuicStreamFactory quic_stream_factory_; |
| 340 | SpdySessionPool spdy_session_pool_; |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 341 | std::unique_ptr<HttpStreamFactory> http_stream_factory_; |
| 342 | std::unique_ptr<HttpStreamFactory> http_stream_factory_for_websocket_; |
avi | fceb32f6 | 2016-10-07 16:30:52 | [diff] [blame] | 343 | std::map<HttpResponseBodyDrainer*, std::unique_ptr<HttpResponseBodyDrainer>> |
| 344 | response_drainers_; |
rdsmith | 1d343be5 | 2016-10-21 20:37:50 | [diff] [blame] | 345 | std::unique_ptr<NetworkThrottleManager> network_stream_throttler_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 346 | |
bnc | 0d23cf4 | 2014-12-11 14:09:46 | [diff] [blame] | 347 | NextProtoVector next_protos_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 348 | |
| 349 | Params params_; |
maksim.sisov | 0adf859 | 2016-07-15 06:25:56 | [diff] [blame] | 350 | |
| 351 | std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 352 | }; |
| 353 | |
| 354 | } // namespace net |
| 355 | |
| 356 | #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_ |