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 enable_spdy_ping_based_connection_checking(true), | 93 enable_spdy_ping_based_connection_checking(true), |
94 enable_http2(true), | 94 enable_http2(true), |
95 spdy_session_max_recv_window_size(kSpdySessionMaxRecvWindowSize), | 95 spdy_session_max_recv_window_size(kSpdySessionMaxRecvWindowSize), |
96 spdy_stream_max_recv_window_size(kSpdyStreamMaxRecvWindowSize), | 96 spdy_stream_max_recv_window_size(kSpdyStreamMaxRecvWindowSize), |
97 time_func(&base::TimeTicks::Now), | 97 time_func(&base::TimeTicks::Now), |
98 enable_http2_alternative_service_with_different_host(false), | 98 enable_http2_alternative_service_with_different_host(false), |
99 enable_quic_alternative_service_with_different_host(true), | 99 enable_quic_alternative_service_with_different_host(true), |
100 enable_quic(false), | 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 // TODO(mbelshe): Move the socket factories into HttpStreamFactory. | 141 // TODO(mbelshe): Move the socket factories into HttpStreamFactory. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 285 } |
286 | 286 |
287 std::unique_ptr<base::Value> HttpNetworkSession::SpdySessionPoolInfoToValue() | 287 std::unique_ptr<base::Value> HttpNetworkSession::SpdySessionPoolInfoToValue() |
288 const { | 288 const { |
289 return spdy_session_pool_.SpdySessionPoolInfoToValue(); | 289 return spdy_session_pool_.SpdySessionPoolInfoToValue(); |
290 } | 290 } |
291 | 291 |
292 std::unique_ptr<base::Value> HttpNetworkSession::QuicInfoToValue() const { | 292 std::unique_ptr<base::Value> HttpNetworkSession::QuicInfoToValue() const { |
293 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 293 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
294 dict->Set("sessions", quic_stream_factory_.QuicStreamFactoryInfoToValue()); | 294 dict->Set("sessions", quic_stream_factory_.QuicStreamFactoryInfoToValue()); |
295 dict->SetBoolean("quic_enabled", params_.enable_quic); | 295 dict->SetBoolean("quic_enabled", IsQuicEnabled()); |
296 std::unique_ptr<base::ListValue> connection_options(new base::ListValue); | 296 std::unique_ptr<base::ListValue> connection_options(new base::ListValue); |
297 for (QuicTagVector::const_iterator it = | 297 for (QuicTagVector::const_iterator it = |
298 params_.quic_connection_options.begin(); | 298 params_.quic_connection_options.begin(); |
299 it != params_.quic_connection_options.end(); ++it) { | 299 it != params_.quic_connection_options.end(); ++it) { |
300 connection_options->AppendString("'" + QuicTagToString(*it) + "'"); | 300 connection_options->AppendString("'" + QuicTagToString(*it) + "'"); |
301 } | 301 } |
302 dict->Set("connection_options", std::move(connection_options)); | 302 dict->Set("connection_options", std::move(connection_options)); |
303 | 303 |
304 std::unique_ptr<base::ListValue> origins_to_force_quic_on( | 304 std::unique_ptr<base::ListValue> origins_to_force_quic_on( |
305 new base::ListValue); | 305 new base::ListValue); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 bool HttpNetworkSession::IsProtocolEnabled(NextProto protocol) const { | 351 bool HttpNetworkSession::IsProtocolEnabled(NextProto protocol) const { |
352 switch (protocol) { | 352 switch (protocol) { |
353 case kProtoUnknown: | 353 case kProtoUnknown: |
354 NOTREACHED(); | 354 NOTREACHED(); |
355 return false; | 355 return false; |
356 case kProtoHTTP11: | 356 case kProtoHTTP11: |
357 return true; | 357 return true; |
358 case kProtoHTTP2: | 358 case kProtoHTTP2: |
359 return params_.enable_http2; | 359 return params_.enable_http2; |
360 case kProtoQUIC: | 360 case kProtoQUIC: |
361 return params_.enable_quic; | 361 return IsQuicEnabled(); |
362 } | 362 } |
363 NOTREACHED(); | 363 NOTREACHED(); |
364 return false; | 364 return false; |
365 } | 365 } |
366 | 366 |
367 void HttpNetworkSession::SetServerPushDelegate( | 367 void HttpNetworkSession::SetServerPushDelegate( |
368 std::unique_ptr<ServerPushDelegate> push_delegate) { | 368 std::unique_ptr<ServerPushDelegate> push_delegate) { |
369 DCHECK(!push_delegate_ && push_delegate); | 369 DCHECK(!push_delegate_ && push_delegate); |
370 | 370 |
371 push_delegate_ = std::move(push_delegate); | 371 push_delegate_ = std::move(push_delegate); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 } | 408 } |
409 http_network_session_dump = pmd->CreateAllocatorDump(name); | 409 http_network_session_dump = pmd->CreateAllocatorDump(name); |
410 normal_socket_pool_manager_->DumpMemoryStats( | 410 normal_socket_pool_manager_->DumpMemoryStats( |
411 pmd, http_network_session_dump->absolute_name()); | 411 pmd, http_network_session_dump->absolute_name()); |
412 spdy_session_pool_.DumpMemoryStats( | 412 spdy_session_pool_.DumpMemoryStats( |
413 pmd, http_network_session_dump->absolute_name()); | 413 pmd, http_network_session_dump->absolute_name()); |
414 pmd->AddOwnershipEdge(pmd->GetAllocatorDump(parent_absolute_name)->guid(), | 414 pmd->AddOwnershipEdge(pmd->GetAllocatorDump(parent_absolute_name)->guid(), |
415 http_network_session_dump->guid()); | 415 http_network_session_dump->guid()); |
416 } | 416 } |
417 | 417 |
| 418 bool HttpNetworkSession::IsQuicEnabled() const { |
| 419 return params_.enable_quic; |
| 420 } |
| 421 |
| 422 void HttpNetworkSession::SetQuicEnabled(bool quic_enabled) { |
| 423 params_.enable_quic = quic_enabled; |
| 424 } |
| 425 |
418 ClientSocketPoolManager* HttpNetworkSession::GetSocketPoolManager( | 426 ClientSocketPoolManager* HttpNetworkSession::GetSocketPoolManager( |
419 SocketPoolType pool_type) { | 427 SocketPoolType pool_type) { |
420 switch (pool_type) { | 428 switch (pool_type) { |
421 case NORMAL_SOCKET_POOL: | 429 case NORMAL_SOCKET_POOL: |
422 return normal_socket_pool_manager_.get(); | 430 return normal_socket_pool_manager_.get(); |
423 case WEBSOCKET_SOCKET_POOL: | 431 case WEBSOCKET_SOCKET_POOL: |
424 return websocket_socket_pool_manager_.get(); | 432 return websocket_socket_pool_manager_.get(); |
425 default: | 433 default: |
426 NOTREACHED(); | 434 NOTREACHED(); |
427 break; | 435 break; |
(...skipping 25 matching lines...) Expand all Loading... |
453 break; | 461 break; |
454 case base::MemoryState::SUSPENDED: | 462 case base::MemoryState::SUSPENDED: |
455 // Note: Not supported at present. Fall through. | 463 // Note: Not supported at present. Fall through. |
456 case base::MemoryState::UNKNOWN: | 464 case base::MemoryState::UNKNOWN: |
457 NOTREACHED(); | 465 NOTREACHED(); |
458 break; | 466 break; |
459 } | 467 } |
460 } | 468 } |
461 | 469 |
462 } // namespace net | 470 } // namespace net |
OLD | NEW |