[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" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 29 | #include "net/http/http_auth_cache.h" |
Kevin DiClemente | f0711908 | 2019-08-12 13:31:34 | [diff] [blame] | 30 | #include "net/http/http_auth_preferences.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 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" |
Matt Menke | d6fd2a5 | 2019-03-20 06:14:36 | [diff] [blame] | 34 | #include "net/socket/connect_job.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 35 | #include "net/socket/next_proto.h" |
Bence Béky | 33a4e43 | 2018-12-03 16:17:23 | [diff] [blame] | 36 | #include "net/socket/websocket_endpoint_lock_manager.h" |
Bence Béky | 94658bf | 2018-05-11 19:22:58 | [diff] [blame] | 37 | #include "net/spdy/spdy_session_pool.h" |
Daniel McArdle | 3a663d6 | 2019-01-31 00:48:47 | [diff] [blame] | 38 | #include "net/ssl/ssl_client_session_cache.h" |
Victor Vasiliev | 27cc771 | 2019-01-24 11:50:14 | [diff] [blame] | 39 | #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 40 | |
| 41 | namespace base { |
| 42 | class Value; |
xunjieli | 9f8c5fb5 | 2016-12-07 22:59:33 | [diff] [blame] | 43 | namespace trace_event { |
| 44 | class ProcessMemoryDump; |
| 45 | } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 46 | } |
| 47 | |
Bence Béky | 33a4e43 | 2018-12-03 16:17:23 | [diff] [blame] | 48 | namespace quic { |
| 49 | class QuicClock; |
| 50 | } // namespace quic |
| 51 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 52 | namespace net { |
| 53 | |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 54 | class CTPolicyEnforcer; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 55 | class CertVerifier; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 56 | class ClientSocketFactory; |
Matt Menke | 12d33db9 | 2019-03-26 22:45:44 | [diff] [blame] | 57 | class ClientSocketPool; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 58 | class ClientSocketPoolManager; |
| 59 | class CTVerifier; |
| 60 | class HostResolver; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 61 | class HttpAuthHandlerFactory; |
| 62 | class HttpNetworkSessionPeer; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 63 | class HttpResponseBodyDrainer; |
| 64 | class HttpServerProperties; |
Matt Menke | d732ea4 | 2019-03-08 12:05:00 | [diff] [blame] | 65 | class HttpUserAgentSettings; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 66 | class NetLog; |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 67 | #if BUILDFLAG(ENABLE_REPORTING) |
| 68 | class NetworkErrorLoggingService; |
| 69 | #endif |
Tarun Bansal | ed2b20b64 | 2018-10-15 19:51:32 | [diff] [blame] | 70 | class NetworkQualityEstimator; |
Wojciech Dzierżanowski | 1f82356 | 2019-01-18 11:26:00 | [diff] [blame] | 71 | class ProxyDelegate; |
Lily Houghton | 8c2f97d | 2018-01-22 05:06:59 | [diff] [blame] | 72 | class ProxyResolutionService; |
Matt Menke | e8648fa | 2019-01-17 16:47:07 | [diff] [blame] | 73 | class ProxyServer; |
| 74 | class QuicCryptoClientStreamFactory; |
Douglas Creager | 134b52e | 2018-11-09 18:00:14 | [diff] [blame] | 75 | #if BUILDFLAG(ENABLE_REPORTING) |
| 76 | class ReportingService; |
| 77 | #endif |
tbansal | ba8f411 | 2015-09-03 21:57:19 | [diff] [blame] | 78 | class SocketPerformanceWatcherFactory; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 79 | class SSLConfigService; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 80 | class TransportSecurityState; |
| 81 | |
bnc | 3171a243 | 2016-12-28 18:40:26 | [diff] [blame] | 82 | // Specifies the maximum HPACK dynamic table size the server is allowed to set. |
| 83 | const uint32_t kSpdyMaxHeaderTableSize = 64 * 1024; |
| 84 | |
| 85 | // Specifies the maximum concurrent streams server could send (via push). |
| 86 | const uint32_t kSpdyMaxConcurrentPushedStreams = 1000; |
| 87 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 88 | // This class holds session objects used by HttpNetworkTransaction objects. |
Takashi Sakamoto | 420ec97c | 2018-09-26 09:27:59 | [diff] [blame] | 89 | class NET_EXPORT HttpNetworkSession { |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 90 | public: |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 91 | // Self-contained structure with all the simple configuration options |
| 92 | // supported by the HttpNetworkSession. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 93 | struct NET_EXPORT Params { |
| 94 | Params(); |
vmpstr | acd23b7 | 2016-02-26 21:08:55 | [diff] [blame] | 95 | Params(const Params& other); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 96 | ~Params(); |
| 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; |
rch | 1546ccd | 2017-04-20 02:14:23 | [diff] [blame] | 103 | bool enable_user_alternate_protocol_ports; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 104 | |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 105 | // Use SPDY ping frames to test for connection health after idle. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 106 | bool enable_spdy_ping_based_connection_checking; |
bnc | 3f0118e | 2016-02-02 15:42:22 | [diff] [blame] | 107 | bool enable_http2; |
bnc | 8f0f3b6 | 2015-04-08 04:37:23 | [diff] [blame] | 108 | size_t spdy_session_max_recv_window_size; |
David Schinazi | 410676a | 2019-08-13 22:31:05 | [diff] [blame] | 109 | // Maximum number of capped frames that can be queued at any time. |
| 110 | int spdy_session_max_queued_capped_frames; |
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 | |
Steven Valdez | 1c185917 | 2019-04-10 15:33:28 | [diff] [blame] | 132 | // Enables 0-RTT support. |
| 133 | bool enable_early_data; |
| 134 | |
rch | d502a30 | 2015-10-16 03:57:21 | [diff] [blame] | 135 | // Enables QUIC support. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 136 | bool enable_quic; |
rch | 1546ccd | 2017-04-20 02:14:23 | [diff] [blame] | 137 | |
Ryan Hamilton | 4cbcbf1 | 2018-12-15 05:16:14 | [diff] [blame] | 138 | // If true, HTTPS URLs can be sent to QUIC proxies. |
| 139 | bool enable_quic_proxies_for_https_urls; |
| 140 | |
Nick Harper | 72ade19 | 2019-07-17 03:30:42 | [diff] [blame] | 141 | // QUIC runtime configuration options and active experiments. |
| 142 | QuicParams quic_params; |
Renjie | a0522f06 | 2019-04-29 18:52:21 | [diff] [blame] | 143 | |
Yixin Wang | 10f477ed | 2017-11-21 04:20:20 | [diff] [blame] | 144 | // If non-empty, QUIC will only be spoken to hosts in this list. |
Ryan Sleevi | a9d6aa6 | 2019-07-26 13:32:18 | [diff] [blame] | 145 | base::flat_set<std::string> quic_host_allowlist; |
xunjieli | 888c2992 | 2016-03-18 21:05:09 | [diff] [blame] | 146 | |
yucliu | 48f235d | 2018-01-11 00:59:55 | [diff] [blame] | 147 | // If true, idle sockets won't be closed when memory pressure happens. |
| 148 | bool disable_idle_sockets_close_on_memory_pressure; |
Kevin DiClemente | f0711908 | 2019-08-12 13:31:34 | [diff] [blame] | 149 | |
| 150 | // If authentication APIs that support ambient authentication are allowed |
| 151 | // to use the default credentials. |
| 152 | HttpAuthPreferences::DefaultCredentials allow_default_credentials; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 153 | }; |
| 154 | |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 155 | // Structure with pointers to the dependencies of the HttpNetworkSession. |
| 156 | // These objects must all outlive the HttpNetworkSession. |
| 157 | struct NET_EXPORT Context { |
| 158 | Context(); |
| 159 | Context(const Context& other); |
| 160 | ~Context(); |
| 161 | |
| 162 | ClientSocketFactory* client_socket_factory; |
| 163 | HostResolver* host_resolver; |
| 164 | CertVerifier* cert_verifier; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 165 | TransportSecurityState* transport_security_state; |
| 166 | CTVerifier* cert_transparency_verifier; |
| 167 | CTPolicyEnforcer* ct_policy_enforcer; |
Lily Houghton | 8c2f97d | 2018-01-22 05:06:59 | [diff] [blame] | 168 | ProxyResolutionService* proxy_resolution_service; |
Wojciech Dzierżanowski | 1f82356 | 2019-01-18 11:26:00 | [diff] [blame] | 169 | ProxyDelegate* proxy_delegate; |
Matt Menke | d732ea4 | 2019-03-08 12:05:00 | [diff] [blame] | 170 | const HttpUserAgentSettings* http_user_agent_settings; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 171 | SSLConfigService* ssl_config_service; |
| 172 | HttpAuthHandlerFactory* http_auth_handler_factory; |
| 173 | HttpServerProperties* http_server_properties; |
| 174 | NetLog* net_log; |
| 175 | SocketPerformanceWatcherFactory* socket_performance_watcher_factory; |
Tarun Bansal | ed2b20b64 | 2018-10-15 19:51:32 | [diff] [blame] | 176 | NetworkQualityEstimator* network_quality_estimator; |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 177 | #if BUILDFLAG(ENABLE_REPORTING) |
Douglas Creager | 134b52e | 2018-11-09 18:00:14 | [diff] [blame] | 178 | ReportingService* reporting_service; |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 179 | NetworkErrorLoggingService* network_error_logging_service; |
| 180 | #endif |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 181 | |
| 182 | // Source of time for QUIC connections. |
Ryan Hamilton | 8d9ee76e | 2018-05-29 23:52:52 | [diff] [blame] | 183 | quic::QuicClock* quic_clock; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 184 | // Source of entropy for QUIC connections. |
Ryan Hamilton | 8d9ee76e | 2018-05-29 23:52:52 | [diff] [blame] | 185 | quic::QuicRandom* quic_random; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 186 | // Optional factory to use for creating QuicCryptoClientStreams. |
| 187 | QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 188 | }; |
| 189 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 190 | enum SocketPoolType { |
| 191 | NORMAL_SOCKET_POOL, |
| 192 | WEBSOCKET_SOCKET_POOL, |
| 193 | NUM_SOCKET_POOL_TYPES |
| 194 | }; |
| 195 | |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 196 | HttpNetworkSession(const Params& params, const Context& context); |
Takashi Sakamoto | 420ec97c | 2018-09-26 09:27:59 | [diff] [blame] | 197 | ~HttpNetworkSession(); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 198 | |
| 199 | HttpAuthCache* http_auth_cache() { return &http_auth_cache_; } |
David Benjamin | bac8dff | 2019-08-07 01:30:41 | [diff] [blame] | 200 | SSLClientContext* ssl_client_context() { return &ssl_client_context_; } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 201 | |
avi | fceb32f6 | 2016-10-07 16:30:52 | [diff] [blame] | 202 | void AddResponseDrainer(std::unique_ptr<HttpResponseBodyDrainer> drainer); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 203 | |
avi | fceb32f6 | 2016-10-07 16:30:52 | [diff] [blame] | 204 | // Removes the drainer from the session. Does not dispose of it. |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 205 | void RemoveResponseDrainer(HttpResponseBodyDrainer* drainer); |
| 206 | |
Matt Menke | d23ab95 | 2019-03-06 00:24:40 | [diff] [blame] | 207 | // Returns the socket pool of the given type for use with the specified |
| 208 | // ProxyServer. Use ProxyServer::Direct() to get the pool for use with direct |
| 209 | // connections. |
Matt Menke | 12d33db9 | 2019-03-26 22:45:44 | [diff] [blame] | 210 | ClientSocketPool* GetSocketPool(SocketPoolType pool_type, |
| 211 | const ProxyServer& proxy_server); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 212 | |
| 213 | CertVerifier* cert_verifier() { return cert_verifier_; } |
Lily Houghton | 8c2f97d | 2018-01-22 05:06:59 | [diff] [blame] | 214 | ProxyResolutionService* proxy_resolution_service() { |
| 215 | return proxy_resolution_service_; |
| 216 | } |
Ryan Sleevi | b8449e0 | 2018-07-15 04:31:07 | [diff] [blame] | 217 | SSLConfigService* ssl_config_service() { return ssl_config_service_; } |
Bence Béky | da280c6 | 2018-04-12 15:08:37 | [diff] [blame] | 218 | WebSocketEndpointLockManager* websocket_endpoint_lock_manager() { |
Bence Béky | 33a4e43 | 2018-12-03 16:17:23 | [diff] [blame] | 219 | return &websocket_endpoint_lock_manager_; |
Bence Béky | da280c6 | 2018-04-12 15:08:37 | [diff] [blame] | 220 | } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 221 | SpdySessionPool* spdy_session_pool() { return &spdy_session_pool_; } |
| 222 | QuicStreamFactory* quic_stream_factory() { return &quic_stream_factory_; } |
| 223 | HttpAuthHandlerFactory* http_auth_handler_factory() { |
| 224 | return http_auth_handler_factory_; |
| 225 | } |
bnc | 525e175a | 2016-06-20 12:36:40 | [diff] [blame] | 226 | HttpServerProperties* http_server_properties() { |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 227 | return http_server_properties_; |
| 228 | } |
| 229 | HttpStreamFactory* http_stream_factory() { |
| 230 | return http_stream_factory_.get(); |
| 231 | } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 232 | NetLog* net_log() { |
| 233 | return net_log_; |
| 234 | } |
Eric Orth | be2efac | 2019-03-06 01:11:11 | [diff] [blame] | 235 | HostResolver* host_resolver() { return host_resolver_; } |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 236 | #if BUILDFLAG(ENABLE_REPORTING) |
Douglas Creager | 134b52e | 2018-11-09 18:00:14 | [diff] [blame] | 237 | ReportingService* reporting_service() const { return reporting_service_; } |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 238 | NetworkErrorLoggingService* network_error_logging_service() const { |
| 239 | return network_error_logging_service_; |
| 240 | } |
| 241 | #endif |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 242 | |
payal.pandey | 62a40029 | 2015-05-28 09:29:54 | [diff] [blame] | 243 | // Creates a Value summary of the state of the socket pools. |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 244 | std::unique_ptr<base::Value> SocketPoolInfoToValue() const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 245 | |
payal.pandey | 91cb231 | 2015-05-27 07:41:51 | [diff] [blame] | 246 | // Creates a Value summary of the state of the SPDY sessions. |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 247 | std::unique_ptr<base::Value> SpdySessionPoolInfoToValue() const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 248 | |
| 249 | // Creates a Value summary of the state of the QUIC sessions and |
payal.pandey | a18956a | 2015-05-27 05:57:55 | [diff] [blame] | 250 | // configuration. |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 251 | std::unique_ptr<base::Value> QuicInfoToValue() const; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 252 | |
| 253 | void CloseAllConnections(); |
| 254 | void CloseIdleConnections(); |
| 255 | |
| 256 | // Returns the original Params used to construct this session. |
| 257 | const Params& params() const { return params_; } |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 258 | // Returns the original Context used to construct this session. |
| 259 | const Context& context() const { return context_; } |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 260 | |
zhongyi | af25754 | 2016-12-19 03:36:01 | [diff] [blame] | 261 | void SetServerPushDelegate(std::unique_ptr<ServerPushDelegate> push_delegate); |
| 262 | |
bnc | 1f29537 | 2015-10-21 23:24:22 | [diff] [blame] | 263 | // Populates |*alpn_protos| with protocols to be used with ALPN. |
| 264 | void GetAlpnProtos(NextProtoVector* alpn_protos) const; |
| 265 | |
David Benjamin | 8119ce9e4 | 2019-08-06 00:05:06 | [diff] [blame] | 266 | // Populates |server_config| and |proxy_config| based on this session. |
| 267 | void GetSSLConfig(SSLConfig* server_config, SSLConfig* proxy_config) const; |
nharper | 8cdb0fb | 2016-04-22 21:34:59 | [diff] [blame] | 268 | |
xunjieli | 9f8c5fb5 | 2016-12-07 22:59:33 | [diff] [blame] | 269 | // Dumps memory allocation stats. |parent_dump_absolute_name| is the name |
| 270 | // used by the parent MemoryAllocatorDump in the memory dump hierarchy. |
| 271 | void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd, |
| 272 | const std::string& parent_absolute_name) const; |
| 273 | |
pmarko | 6ab8be24 | 2017-01-11 11:02:55 | [diff] [blame] | 274 | // Evaluates if QUIC is enabled for new streams. |
| 275 | bool IsQuicEnabled() const; |
| 276 | |
| 277 | // Disable QUIC for new streams. |
| 278 | void DisableQuic(); |
| 279 | |
Daniel McArdle | 3a663d6 | 2019-01-31 00:48:47 | [diff] [blame] | 280 | // Clear the SSL session cache. |
| 281 | void ClearSSLSessionCache(); |
Matt Menke | d6fd2a5 | 2019-03-20 06:14:36 | [diff] [blame] | 282 | |
| 283 | // Returns a CommonConnectJobParams that references the NetworkSession's |
| 284 | // components. If |for_websockets| is true, the Params' |
| 285 | // |websocket_endpoint_lock_manager| field will be populated. Otherwise, it |
| 286 | // will be nullptr. |
| 287 | CommonConnectJobParams CreateCommonConnectJobParams( |
| 288 | bool for_websockets = false); |
Daniel McArdle | 3a663d6 | 2019-01-31 00:48:47 | [diff] [blame] | 289 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 290 | private: |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 291 | friend class HttpNetworkSessionPeer; |
| 292 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 293 | ClientSocketPoolManager* GetSocketPoolManager(SocketPoolType pool_type); |
| 294 | |
maksim.sisov | 0adf859 | 2016-07-15 06:25:56 | [diff] [blame] | 295 | // Flush sockets on low memory notifications callback. |
| 296 | void OnMemoryPressure( |
| 297 | base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
| 298 | |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 299 | NetLog* const net_log_; |
bnc | 525e175a | 2016-06-20 12:36:40 | [diff] [blame] | 300 | HttpServerProperties* const http_server_properties_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 301 | CertVerifier* const cert_verifier_; |
| 302 | HttpAuthHandlerFactory* const http_auth_handler_factory_; |
Eric Orth | be2efac | 2019-03-06 01:11:11 | [diff] [blame] | 303 | HostResolver* const host_resolver_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 304 | |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 305 | #if BUILDFLAG(ENABLE_REPORTING) |
Douglas Creager | 134b52e | 2018-11-09 18:00:14 | [diff] [blame] | 306 | ReportingService* const reporting_service_; |
Douglas Creager | 3cb04205 | 2018-11-06 23:08:52 | [diff] [blame] | 307 | NetworkErrorLoggingService* const network_error_logging_service_; |
| 308 | #endif |
Bence Béky | bf1c67f2 | 2018-04-12 09:26:26 | [diff] [blame] | 309 | ProxyResolutionService* const proxy_resolution_service_; |
Ryan Sleevi | b8449e0 | 2018-07-15 04:31:07 | [diff] [blame] | 310 | SSLConfigService* const ssl_config_service_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 311 | |
| 312 | HttpAuthCache http_auth_cache_; |
Daniel McArdle | 3a663d6 | 2019-01-31 00:48:47 | [diff] [blame] | 313 | SSLClientSessionCache ssl_client_session_cache_; |
David Benjamin | 24725be | 2019-07-24 20:57:18 | [diff] [blame] | 314 | SSLClientContext ssl_client_context_; |
Bence Béky | 33a4e43 | 2018-12-03 16:17:23 | [diff] [blame] | 315 | WebSocketEndpointLockManager websocket_endpoint_lock_manager_; |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 316 | std::unique_ptr<ClientSocketPoolManager> normal_socket_pool_manager_; |
| 317 | std::unique_ptr<ClientSocketPoolManager> websocket_socket_pool_manager_; |
zhongyi | af25754 | 2016-12-19 03:36:01 | [diff] [blame] | 318 | std::unique_ptr<ServerPushDelegate> push_delegate_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 319 | QuicStreamFactory quic_stream_factory_; |
| 320 | SpdySessionPool spdy_session_pool_; |
danakj | 1fd259a0 | 2016-04-16 03:17:09 | [diff] [blame] | 321 | std::unique_ptr<HttpStreamFactory> http_stream_factory_; |
avi | fceb32f6 | 2016-10-07 16:30:52 | [diff] [blame] | 322 | std::map<HttpResponseBodyDrainer*, std::unique_ptr<HttpResponseBodyDrainer>> |
| 323 | response_drainers_; |
bnc | 0d23cf4 | 2014-12-11 14:09:46 | [diff] [blame] | 324 | NextProtoVector next_protos_; |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 325 | |
| 326 | Params params_; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 327 | Context context_; |
maksim.sisov | 0adf859 | 2016-07-15 06:25:56 | [diff] [blame] | 328 | |
| 329 | std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 330 | |
| 331 | THREAD_CHECKER(thread_checker_); |
[email protected] | cf4cae3 | 2014-05-27 00:39:10 | [diff] [blame] | 332 | }; |
| 333 | |
| 334 | } // namespace net |
| 335 | |
| 336 | #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_ |