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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 it = http2_settings.find(SETTINGS_INITIAL_WINDOW_SIZE); | 92 it = http2_settings.find(SETTINGS_INITIAL_WINDOW_SIZE); |
93 if (it == http2_settings.end()) | 93 if (it == http2_settings.end()) |
94 http2_settings[SETTINGS_INITIAL_WINDOW_SIZE] = kSpdyStreamMaxRecvWindowSize; | 94 http2_settings[SETTINGS_INITIAL_WINDOW_SIZE] = kSpdyStreamMaxRecvWindowSize; |
95 | 95 |
96 return http2_settings; | 96 return http2_settings; |
97 } | 97 } |
98 | 98 |
99 } // unnamed namespace | 99 } // unnamed namespace |
100 | 100 |
101 HttpNetworkSession::Params::Params() | 101 HttpNetworkSession::Params::Params() |
102 : client_socket_factory(NULL), | 102 : client_socket_factory(nullptr), |
103 host_resolver(NULL), | 103 host_resolver(nullptr), |
104 cert_verifier(NULL), | 104 cert_verifier(nullptr), |
105 channel_id_service(NULL), | 105 channel_id_service(nullptr), |
106 transport_security_state(NULL), | 106 transport_security_state(nullptr), |
107 cert_transparency_verifier(NULL), | 107 cert_transparency_verifier(nullptr), |
108 ct_policy_enforcer(NULL), | 108 ct_policy_enforcer(nullptr), |
109 proxy_service(NULL), | 109 proxy_service(nullptr), |
110 ssl_config_service(NULL), | 110 ssl_config_service(nullptr), |
111 http_auth_handler_factory(NULL), | 111 http_auth_handler_factory(nullptr), |
112 net_log(NULL), | 112 net_log(nullptr), |
113 host_mapping_rules(NULL), | 113 host_mapping_rules(nullptr), |
114 socket_performance_watcher_factory(NULL), | 114 socket_performance_watcher_factory(nullptr), |
115 ignore_certificate_errors(false), | 115 ignore_certificate_errors(false), |
116 testing_fixed_http_port(0), | 116 testing_fixed_http_port(0), |
117 testing_fixed_https_port(0), | 117 testing_fixed_https_port(0), |
118 enable_tcp_fast_open_for_ssl(false), | 118 enable_tcp_fast_open_for_ssl(false), |
119 enable_spdy_ping_based_connection_checking(true), | 119 enable_spdy_ping_based_connection_checking(true), |
120 enable_http2(true), | 120 enable_http2(true), |
121 spdy_session_max_recv_window_size(kSpdySessionMaxRecvWindowSize), | 121 spdy_session_max_recv_window_size(kSpdySessionMaxRecvWindowSize), |
122 time_func(&base::TimeTicks::Now), | 122 time_func(&base::TimeTicks::Now), |
123 enable_http2_alternative_service_with_different_host(false), | 123 enable_http2_alternative_service_with_different_host(false), |
124 enable_quic_alternative_service_with_different_host(true), | 124 enable_quic_alternative_service_with_different_host(true), |
125 enable_quic(false), | 125 enable_quic(false), |
126 disable_quic_on_timeout_with_open_streams(false), | 126 disable_quic_on_timeout_with_open_streams(false), |
127 quic_always_require_handshake_confirmation(false), | 127 quic_always_require_handshake_confirmation(false), |
128 quic_disable_connection_pooling(false), | 128 quic_disable_connection_pooling(false), |
129 quic_load_server_info_timeout_srtt_multiplier(0.25f), | 129 quic_load_server_info_timeout_srtt_multiplier(0.25f), |
130 quic_enable_connection_racing(false), | 130 quic_enable_connection_racing(false), |
131 quic_enable_non_blocking_io(false), | 131 quic_enable_non_blocking_io(false), |
132 quic_disable_disk_cache(false), | 132 quic_disable_disk_cache(false), |
133 quic_prefer_aes(false), | 133 quic_prefer_aes(false), |
134 quic_socket_receive_buffer_size(kQuicSocketReceiveBufferSize), | 134 quic_socket_receive_buffer_size(kQuicSocketReceiveBufferSize), |
135 quic_delay_tcp_race(true), | 135 quic_delay_tcp_race(true), |
136 quic_max_server_configs_stored_in_properties(0u), | 136 quic_max_server_configs_stored_in_properties(0u), |
137 quic_clock(NULL), | 137 quic_clock(nullptr), |
138 quic_random(NULL), | 138 quic_random(nullptr), |
139 quic_max_packet_length(kDefaultMaxPacketSize), | 139 quic_max_packet_length(kDefaultMaxPacketSize), |
140 enable_user_alternate_protocol_ports(false), | 140 enable_user_alternate_protocol_ports(false), |
141 quic_crypto_client_stream_factory( | 141 quic_crypto_client_stream_factory( |
142 QuicCryptoClientStreamFactory::GetDefaultFactory()), | 142 QuicCryptoClientStreamFactory::GetDefaultFactory()), |
143 quic_close_sessions_on_ip_change(false), | 143 quic_close_sessions_on_ip_change(false), |
144 quic_idle_connection_timeout_seconds(kIdleConnectionTimeoutSeconds), | 144 quic_idle_connection_timeout_seconds(kIdleConnectionTimeoutSeconds), |
145 quic_reduced_ping_timeout_seconds(kPingTimeoutSecs), | 145 quic_reduced_ping_timeout_seconds(kPingTimeoutSecs), |
146 quic_packet_reader_yield_after_duration_milliseconds( | 146 quic_packet_reader_yield_after_duration_milliseconds( |
147 kQuicYieldAfterDurationMilliseconds), | 147 kQuicYieldAfterDurationMilliseconds), |
148 quic_disable_preconnect_if_0rtt(false), | 148 quic_disable_preconnect_if_0rtt(false), |
149 quic_migrate_sessions_on_network_change(false), | 149 quic_migrate_sessions_on_network_change(false), |
150 quic_migrate_sessions_early(false), | 150 quic_migrate_sessions_early(false), |
151 quic_allow_server_migration(false), | 151 quic_allow_server_migration(false), |
152 quic_disable_bidirectional_streams(false), | 152 quic_disable_bidirectional_streams(false), |
153 quic_force_hol_blocking(false), | 153 quic_force_hol_blocking(false), |
154 quic_race_cert_verification(false), | 154 quic_race_cert_verification(false), |
155 quic_do_not_fragment(false), | 155 quic_do_not_fragment(false), |
156 proxy_delegate(NULL), | 156 proxy_delegate(nullptr), |
157 enable_token_binding(false), | 157 enable_token_binding(false), |
158 http_09_on_non_default_ports_enabled(false), | 158 http_09_on_non_default_ports_enabled(false), |
159 restrict_to_one_preconnect_for_proxies(false) { | 159 restrict_to_one_preconnect_for_proxies(false) { |
160 quic_supported_versions.push_back(QUIC_VERSION_35); | 160 quic_supported_versions.push_back(QUIC_VERSION_35); |
161 } | 161 } |
162 | 162 |
163 HttpNetworkSession::Params::Params(const Params& other) = default; | 163 HttpNetworkSession::Params::Params(const Params& other) = default; |
164 | 164 |
165 HttpNetworkSession::Params::~Params() {} | 165 HttpNetworkSession::Params::~Params() {} |
166 | 166 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 } | 311 } |
312 | 312 |
313 std::unique_ptr<base::Value> HttpNetworkSession::SpdySessionPoolInfoToValue() | 313 std::unique_ptr<base::Value> HttpNetworkSession::SpdySessionPoolInfoToValue() |
314 const { | 314 const { |
315 return spdy_session_pool_.SpdySessionPoolInfoToValue(); | 315 return spdy_session_pool_.SpdySessionPoolInfoToValue(); |
316 } | 316 } |
317 | 317 |
318 std::unique_ptr<base::Value> HttpNetworkSession::QuicInfoToValue() const { | 318 std::unique_ptr<base::Value> HttpNetworkSession::QuicInfoToValue() const { |
319 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 319 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
320 dict->Set("sessions", quic_stream_factory_.QuicStreamFactoryInfoToValue()); | 320 dict->Set("sessions", quic_stream_factory_.QuicStreamFactoryInfoToValue()); |
321 dict->SetBoolean("quic_enabled", params_.enable_quic); | 321 dict->SetBoolean("quic_enabled", IsQuicEnabled()); |
322 std::unique_ptr<base::ListValue> connection_options(new base::ListValue); | 322 std::unique_ptr<base::ListValue> connection_options(new base::ListValue); |
323 for (QuicTagVector::const_iterator it = | 323 for (QuicTagVector::const_iterator it = |
324 params_.quic_connection_options.begin(); | 324 params_.quic_connection_options.begin(); |
325 it != params_.quic_connection_options.end(); ++it) { | 325 it != params_.quic_connection_options.end(); ++it) { |
326 connection_options->AppendString("'" + QuicTagToString(*it) + "'"); | 326 connection_options->AppendString("'" + QuicTagToString(*it) + "'"); |
327 } | 327 } |
328 dict->Set("connection_options", std::move(connection_options)); | 328 dict->Set("connection_options", std::move(connection_options)); |
329 | 329 |
330 std::unique_ptr<base::ListValue> origins_to_force_quic_on( | 330 std::unique_ptr<base::ListValue> origins_to_force_quic_on( |
331 new base::ListValue); | 331 new base::ListValue); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 bool HttpNetworkSession::IsProtocolEnabled(NextProto protocol) const { | 377 bool HttpNetworkSession::IsProtocolEnabled(NextProto protocol) const { |
378 switch (protocol) { | 378 switch (protocol) { |
379 case kProtoUnknown: | 379 case kProtoUnknown: |
380 NOTREACHED(); | 380 NOTREACHED(); |
381 return false; | 381 return false; |
382 case kProtoHTTP11: | 382 case kProtoHTTP11: |
383 return true; | 383 return true; |
384 case kProtoHTTP2: | 384 case kProtoHTTP2: |
385 return params_.enable_http2; | 385 return params_.enable_http2; |
386 case kProtoQUIC: | 386 case kProtoQUIC: |
387 return params_.enable_quic; | 387 return IsQuicEnabled(); |
388 } | 388 } |
389 NOTREACHED(); | 389 NOTREACHED(); |
390 return false; | 390 return false; |
391 } | 391 } |
392 | 392 |
393 void HttpNetworkSession::SetServerPushDelegate( | 393 void HttpNetworkSession::SetServerPushDelegate( |
394 std::unique_ptr<ServerPushDelegate> push_delegate) { | 394 std::unique_ptr<ServerPushDelegate> push_delegate) { |
395 DCHECK(!push_delegate_ && push_delegate); | 395 DCHECK(!push_delegate_ && push_delegate); |
396 | 396 |
397 push_delegate_ = std::move(push_delegate); | 397 push_delegate_ = std::move(push_delegate); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 } | 431 } |
432 // Create an empty row under parent's dump so size can be attributed correctly | 432 // Create an empty row under parent's dump so size can be attributed correctly |
433 // if |this| is shared between URLRequestContexts. | 433 // if |this| is shared between URLRequestContexts. |
434 base::trace_event::MemoryAllocatorDump* empty_row_dump = | 434 base::trace_event::MemoryAllocatorDump* empty_row_dump = |
435 pmd->CreateAllocatorDump(base::StringPrintf( | 435 pmd->CreateAllocatorDump(base::StringPrintf( |
436 "%s/http_network_session", parent_absolute_name.c_str())); | 436 "%s/http_network_session", parent_absolute_name.c_str())); |
437 pmd->AddOwnershipEdge(empty_row_dump->guid(), | 437 pmd->AddOwnershipEdge(empty_row_dump->guid(), |
438 http_network_session_dump->guid()); | 438 http_network_session_dump->guid()); |
439 } | 439 } |
440 | 440 |
| 441 bool HttpNetworkSession::IsQuicEnabled() const { |
| 442 return params_.enable_quic; |
| 443 } |
| 444 |
| 445 void HttpNetworkSession::DisableQuic() { |
| 446 params_.enable_quic = false; |
| 447 } |
| 448 |
441 ClientSocketPoolManager* HttpNetworkSession::GetSocketPoolManager( | 449 ClientSocketPoolManager* HttpNetworkSession::GetSocketPoolManager( |
442 SocketPoolType pool_type) { | 450 SocketPoolType pool_type) { |
443 switch (pool_type) { | 451 switch (pool_type) { |
444 case NORMAL_SOCKET_POOL: | 452 case NORMAL_SOCKET_POOL: |
445 return normal_socket_pool_manager_.get(); | 453 return normal_socket_pool_manager_.get(); |
446 case WEBSOCKET_SOCKET_POOL: | 454 case WEBSOCKET_SOCKET_POOL: |
447 return websocket_socket_pool_manager_.get(); | 455 return websocket_socket_pool_manager_.get(); |
448 default: | 456 default: |
449 NOTREACHED(); | 457 NOTREACHED(); |
450 break; | 458 break; |
(...skipping 25 matching lines...) Expand all Loading... |
476 break; | 484 break; |
477 case base::MemoryState::SUSPENDED: | 485 case base::MemoryState::SUSPENDED: |
478 // Note: Not supported at present. Fall through. | 486 // Note: Not supported at present. Fall through. |
479 case base::MemoryState::UNKNOWN: | 487 case base::MemoryState::UNKNOWN: |
480 NOTREACHED(); | 488 NOTREACHED(); |
481 break; | 489 break; |
482 } | 490 } |
483 } | 491 } |
484 | 492 |
485 } // namespace net | 493 } // namespace net |
OLD | NEW |