OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_network_session.h" | 5 #include "net/http/http_network_session.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // The maximum receive window sizes for HTTP/2 sessions and streams. | 66 // The maximum receive window sizes for HTTP/2 sessions and streams. |
67 const int32_t kSpdySessionMaxRecvWindowSize = 15 * 1024 * 1024; // 15 MB | 67 const int32_t kSpdySessionMaxRecvWindowSize = 15 * 1024 * 1024; // 15 MB |
68 const int32_t kSpdyStreamMaxRecvWindowSize = 6 * 1024 * 1024; // 6 MB | 68 const int32_t kSpdyStreamMaxRecvWindowSize = 6 * 1024 * 1024; // 6 MB |
69 // QUIC's socket receive buffer size. | 69 // QUIC's socket receive buffer size. |
70 // We should adaptively set this buffer size, but for now, we'll use a size | 70 // We should adaptively set this buffer size, but for now, we'll use a size |
71 // that seems large enough to receive data at line rate for most connections, | 71 // that seems large enough to receive data at line rate for most connections, |
72 // and does not consume "too much" memory. | 72 // and does not consume "too much" memory. |
73 const int32_t kQuicSocketReceiveBufferSize = 1024 * 1024; // 1MB | 73 const int32_t kQuicSocketReceiveBufferSize = 1024 * 1024; // 1MB |
74 | 74 |
75 HttpNetworkSession::Params::Params() | 75 HttpNetworkSession::Params::Params() |
76 : client_socket_factory(NULL), | 76 : client_socket_factory(nullptr), |
77 host_resolver(NULL), | 77 host_resolver(nullptr), |
78 cert_verifier(NULL), | 78 cert_verifier(nullptr), |
79 channel_id_service(NULL), | 79 channel_id_service(nullptr), |
80 transport_security_state(NULL), | 80 transport_security_state(nullptr), |
81 cert_transparency_verifier(NULL), | 81 cert_transparency_verifier(nullptr), |
82 ct_policy_enforcer(NULL), | 82 ct_policy_enforcer(nullptr), |
83 proxy_service(NULL), | 83 proxy_service(nullptr), |
84 ssl_config_service(NULL), | 84 ssl_config_service(nullptr), |
85 http_auth_handler_factory(NULL), | 85 http_auth_handler_factory(nullptr), |
86 net_log(NULL), | 86 net_log(nullptr), |
87 host_mapping_rules(NULL), | 87 host_mapping_rules(nullptr), |
88 socket_performance_watcher_factory(NULL), | 88 socket_performance_watcher_factory(nullptr), |
89 ignore_certificate_errors(false), | 89 ignore_certificate_errors(false), |
90 testing_fixed_http_port(0), | 90 testing_fixed_http_port(0), |
91 testing_fixed_https_port(0), | 91 testing_fixed_https_port(0), |
92 enable_tcp_fast_open_for_ssl(false), | 92 enable_tcp_fast_open_for_ssl(false), |
| 93 dynamic_shared_params(nullptr), |
93 enable_spdy_ping_based_connection_checking(true), | 94 enable_spdy_ping_based_connection_checking(true), |
94 enable_http2(true), | 95 enable_http2(true), |
95 spdy_session_max_recv_window_size(kSpdySessionMaxRecvWindowSize), | 96 spdy_session_max_recv_window_size(kSpdySessionMaxRecvWindowSize), |
96 spdy_stream_max_recv_window_size(kSpdyStreamMaxRecvWindowSize), | 97 spdy_stream_max_recv_window_size(kSpdyStreamMaxRecvWindowSize), |
97 time_func(&base::TimeTicks::Now), | 98 time_func(&base::TimeTicks::Now), |
98 enable_http2_alternative_service_with_different_host(false), | 99 enable_http2_alternative_service_with_different_host(false), |
99 enable_quic_alternative_service_with_different_host(true), | 100 enable_quic_alternative_service_with_different_host(true), |
100 enable_quic(false), | |
101 disable_quic_on_timeout_with_open_streams(false), | 101 disable_quic_on_timeout_with_open_streams(false), |
102 quic_always_require_handshake_confirmation(false), | 102 quic_always_require_handshake_confirmation(false), |
103 quic_disable_connection_pooling(false), | 103 quic_disable_connection_pooling(false), |
104 quic_load_server_info_timeout_srtt_multiplier(0.25f), | 104 quic_load_server_info_timeout_srtt_multiplier(0.25f), |
105 quic_enable_connection_racing(false), | 105 quic_enable_connection_racing(false), |
106 quic_enable_non_blocking_io(false), | 106 quic_enable_non_blocking_io(false), |
107 quic_disable_disk_cache(false), | 107 quic_disable_disk_cache(false), |
108 quic_prefer_aes(false), | 108 quic_prefer_aes(false), |
109 quic_socket_receive_buffer_size(kQuicSocketReceiveBufferSize), | 109 quic_socket_receive_buffer_size(kQuicSocketReceiveBufferSize), |
110 quic_delay_tcp_race(true), | 110 quic_delay_tcp_race(true), |
111 quic_max_server_configs_stored_in_properties(0u), | 111 quic_max_server_configs_stored_in_properties(0u), |
112 quic_clock(NULL), | 112 quic_clock(nullptr), |
113 quic_random(NULL), | 113 quic_random(nullptr), |
114 quic_max_packet_length(kDefaultMaxPacketSize), | 114 quic_max_packet_length(kDefaultMaxPacketSize), |
115 enable_user_alternate_protocol_ports(false), | 115 enable_user_alternate_protocol_ports(false), |
116 quic_crypto_client_stream_factory( | 116 quic_crypto_client_stream_factory( |
117 QuicCryptoClientStreamFactory::GetDefaultFactory()), | 117 QuicCryptoClientStreamFactory::GetDefaultFactory()), |
118 quic_close_sessions_on_ip_change(false), | 118 quic_close_sessions_on_ip_change(false), |
119 quic_idle_connection_timeout_seconds(kIdleConnectionTimeoutSeconds), | 119 quic_idle_connection_timeout_seconds(kIdleConnectionTimeoutSeconds), |
120 quic_reduced_ping_timeout_seconds(kPingTimeoutSecs), | 120 quic_reduced_ping_timeout_seconds(kPingTimeoutSecs), |
121 quic_packet_reader_yield_after_duration_milliseconds( | 121 quic_packet_reader_yield_after_duration_milliseconds( |
122 kQuicYieldAfterDurationMilliseconds), | 122 kQuicYieldAfterDurationMilliseconds), |
123 quic_disable_preconnect_if_0rtt(false), | 123 quic_disable_preconnect_if_0rtt(false), |
124 quic_migrate_sessions_on_network_change(false), | 124 quic_migrate_sessions_on_network_change(false), |
125 quic_migrate_sessions_early(false), | 125 quic_migrate_sessions_early(false), |
126 quic_allow_server_migration(false), | 126 quic_allow_server_migration(false), |
127 quic_disable_bidirectional_streams(false), | 127 quic_disable_bidirectional_streams(false), |
128 quic_force_hol_blocking(false), | 128 quic_force_hol_blocking(false), |
129 quic_race_cert_verification(false), | 129 quic_race_cert_verification(false), |
130 quic_do_not_fragment(false), | 130 quic_do_not_fragment(false), |
131 proxy_delegate(NULL), | 131 proxy_delegate(nullptr), |
132 enable_token_binding(false), | 132 enable_token_binding(false), |
133 http_09_on_non_default_ports_enabled(false) { | 133 http_09_on_non_default_ports_enabled(false) { |
134 quic_supported_versions.push_back(QUIC_VERSION_35); | 134 quic_supported_versions.push_back(QUIC_VERSION_35); |
135 } | 135 } |
136 | 136 |
137 HttpNetworkSession::Params::Params(const Params& other) = default; | 137 HttpNetworkSession::Params::Params(const Params& other) = default; |
138 | 138 |
139 HttpNetworkSession::Params::~Params() {} | 139 HttpNetworkSession::Params::~Params() {} |
140 | 140 |
| 141 bool HttpNetworkSession::Params::enable_quic() const { |
| 142 return dynamic_shared_params && dynamic_shared_params->enable_quic; |
| 143 } |
| 144 |
| 145 HttpNetworkSession::DynamicSharedParams::DynamicSharedParams() |
| 146 : enable_quic(false) {} |
| 147 |
| 148 HttpNetworkSession::DynamicSharedParams::~DynamicSharedParams() {} |
| 149 |
141 // TODO(mbelshe): Move the socket factories into HttpStreamFactory. | 150 // TODO(mbelshe): Move the socket factories into HttpStreamFactory. |
142 HttpNetworkSession::HttpNetworkSession(const Params& params) | 151 HttpNetworkSession::HttpNetworkSession(const Params& params) |
143 : net_log_(params.net_log), | 152 : net_log_(params.net_log), |
144 http_server_properties_(params.http_server_properties), | 153 http_server_properties_(params.http_server_properties), |
145 cert_verifier_(params.cert_verifier), | 154 cert_verifier_(params.cert_verifier), |
146 http_auth_handler_factory_(params.http_auth_handler_factory), | 155 http_auth_handler_factory_(params.http_auth_handler_factory), |
147 proxy_service_(params.proxy_service), | 156 proxy_service_(params.proxy_service), |
148 ssl_config_service_(params.ssl_config_service), | 157 ssl_config_service_(params.ssl_config_service), |
149 push_delegate_(nullptr), | 158 push_delegate_(nullptr), |
150 quic_stream_factory_( | 159 quic_stream_factory_( |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 294 } |
286 | 295 |
287 std::unique_ptr<base::Value> HttpNetworkSession::SpdySessionPoolInfoToValue() | 296 std::unique_ptr<base::Value> HttpNetworkSession::SpdySessionPoolInfoToValue() |
288 const { | 297 const { |
289 return spdy_session_pool_.SpdySessionPoolInfoToValue(); | 298 return spdy_session_pool_.SpdySessionPoolInfoToValue(); |
290 } | 299 } |
291 | 300 |
292 std::unique_ptr<base::Value> HttpNetworkSession::QuicInfoToValue() const { | 301 std::unique_ptr<base::Value> HttpNetworkSession::QuicInfoToValue() const { |
293 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 302 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
294 dict->Set("sessions", quic_stream_factory_.QuicStreamFactoryInfoToValue()); | 303 dict->Set("sessions", quic_stream_factory_.QuicStreamFactoryInfoToValue()); |
295 dict->SetBoolean("quic_enabled", params_.enable_quic); | 304 dict->SetBoolean("quic_enabled", params_.enable_quic()); |
296 std::unique_ptr<base::ListValue> connection_options(new base::ListValue); | 305 std::unique_ptr<base::ListValue> connection_options(new base::ListValue); |
297 for (QuicTagVector::const_iterator it = | 306 for (QuicTagVector::const_iterator it = |
298 params_.quic_connection_options.begin(); | 307 params_.quic_connection_options.begin(); |
299 it != params_.quic_connection_options.end(); ++it) { | 308 it != params_.quic_connection_options.end(); ++it) { |
300 connection_options->AppendString("'" + QuicTagToString(*it) + "'"); | 309 connection_options->AppendString("'" + QuicTagToString(*it) + "'"); |
301 } | 310 } |
302 dict->Set("connection_options", std::move(connection_options)); | 311 dict->Set("connection_options", std::move(connection_options)); |
303 | 312 |
304 std::unique_ptr<base::ListValue> origins_to_force_quic_on( | 313 std::unique_ptr<base::ListValue> origins_to_force_quic_on( |
305 new base::ListValue); | 314 new base::ListValue); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 bool HttpNetworkSession::IsProtocolEnabled(NextProto protocol) const { | 360 bool HttpNetworkSession::IsProtocolEnabled(NextProto protocol) const { |
352 switch (protocol) { | 361 switch (protocol) { |
353 case kProtoUnknown: | 362 case kProtoUnknown: |
354 NOTREACHED(); | 363 NOTREACHED(); |
355 return false; | 364 return false; |
356 case kProtoHTTP11: | 365 case kProtoHTTP11: |
357 return true; | 366 return true; |
358 case kProtoHTTP2: | 367 case kProtoHTTP2: |
359 return params_.enable_http2; | 368 return params_.enable_http2; |
360 case kProtoQUIC: | 369 case kProtoQUIC: |
361 return params_.enable_quic; | 370 return params_.enable_quic(); |
362 } | 371 } |
363 NOTREACHED(); | 372 NOTREACHED(); |
364 return false; | 373 return false; |
365 } | 374 } |
366 | 375 |
367 void HttpNetworkSession::SetServerPushDelegate( | 376 void HttpNetworkSession::SetServerPushDelegate( |
368 std::unique_ptr<ServerPushDelegate> push_delegate) { | 377 std::unique_ptr<ServerPushDelegate> push_delegate) { |
369 DCHECK(!push_delegate_ && push_delegate); | 378 DCHECK(!push_delegate_ && push_delegate); |
370 | 379 |
371 push_delegate_ = std::move(push_delegate); | 380 push_delegate_ = std::move(push_delegate); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 break; | 462 break; |
454 case base::MemoryState::SUSPENDED: | 463 case base::MemoryState::SUSPENDED: |
455 // Note: Not supported at present. Fall through. | 464 // Note: Not supported at present. Fall through. |
456 case base::MemoryState::UNKNOWN: | 465 case base::MemoryState::UNKNOWN: |
457 NOTREACHED(); | 466 NOTREACHED(); |
458 break; | 467 break; |
459 } | 468 } |
460 } | 469 } |
461 | 470 |
462 } // namespace net | 471 } // namespace net |
OLD | NEW |