| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 // The maximum receive window sizes for HTTP/2 sessions and streams. | 60 // The maximum receive window sizes for HTTP/2 sessions and streams. |
| 61 const int32_t kSpdySessionMaxRecvWindowSize = 15 * 1024 * 1024; // 15 MB | 61 const int32_t kSpdySessionMaxRecvWindowSize = 15 * 1024 * 1024; // 15 MB |
| 62 const int32_t kSpdyStreamMaxRecvWindowSize = 6 * 1024 * 1024; // 6 MB | 62 const int32_t kSpdyStreamMaxRecvWindowSize = 6 * 1024 * 1024; // 6 MB |
| 63 // QUIC's socket receive buffer size. | 63 // QUIC's socket receive buffer size. |
| 64 // We should adaptively set this buffer size, but for now, we'll use a size | 64 // We should adaptively set this buffer size, but for now, we'll use a size |
| 65 // that seems large enough to receive data at line rate for most connections, | 65 // that seems large enough to receive data at line rate for most connections, |
| 66 // and does not consume "too much" memory. | 66 // and does not consume "too much" memory. |
| 67 const int32_t kQuicSocketReceiveBufferSize = 1024 * 1024; // 1MB | 67 const int32_t kQuicSocketReceiveBufferSize = 1024 * 1024; // 1MB |
| 68 | 68 |
| 69 // Number of recent connections to consider for certain thresholds | |
| 70 // that trigger disabling QUIC. E.g. disable QUIC if PUBLIC_RESET was | |
| 71 // received post handshake for at least 2 of 20 recent connections. | |
| 72 const int32_t kQuicMaxRecentDisabledReasons = 20; | |
| 73 | |
| 74 HttpNetworkSession::Params::Params() | 69 HttpNetworkSession::Params::Params() |
| 75 : client_socket_factory(NULL), | 70 : client_socket_factory(NULL), |
| 76 host_resolver(NULL), | 71 host_resolver(NULL), |
| 77 cert_verifier(NULL), | 72 cert_verifier(NULL), |
| 78 channel_id_service(NULL), | 73 channel_id_service(NULL), |
| 79 transport_security_state(NULL), | 74 transport_security_state(NULL), |
| 80 cert_transparency_verifier(NULL), | 75 cert_transparency_verifier(NULL), |
| 81 ct_policy_enforcer(NULL), | 76 ct_policy_enforcer(NULL), |
| 82 proxy_service(NULL), | 77 proxy_service(NULL), |
| 83 ssl_config_service(NULL), | 78 ssl_config_service(NULL), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 99 enable_quic(false), | 94 enable_quic(false), |
| 100 disable_quic_on_timeout_with_open_streams(false), | 95 disable_quic_on_timeout_with_open_streams(false), |
| 101 enable_quic_port_selection(true), | 96 enable_quic_port_selection(true), |
| 102 quic_always_require_handshake_confirmation(false), | 97 quic_always_require_handshake_confirmation(false), |
| 103 quic_disable_connection_pooling(false), | 98 quic_disable_connection_pooling(false), |
| 104 quic_load_server_info_timeout_srtt_multiplier(0.25f), | 99 quic_load_server_info_timeout_srtt_multiplier(0.25f), |
| 105 quic_enable_connection_racing(false), | 100 quic_enable_connection_racing(false), |
| 106 quic_enable_non_blocking_io(false), | 101 quic_enable_non_blocking_io(false), |
| 107 quic_disable_disk_cache(false), | 102 quic_disable_disk_cache(false), |
| 108 quic_prefer_aes(false), | 103 quic_prefer_aes(false), |
| 109 quic_max_number_of_lossy_connections(0), | |
| 110 quic_packet_loss_threshold(1.0f), | |
| 111 quic_socket_receive_buffer_size(kQuicSocketReceiveBufferSize), | 104 quic_socket_receive_buffer_size(kQuicSocketReceiveBufferSize), |
| 112 quic_delay_tcp_race(true), | 105 quic_delay_tcp_race(true), |
| 113 quic_max_server_configs_stored_in_properties(0u), | 106 quic_max_server_configs_stored_in_properties(0u), |
| 114 quic_clock(NULL), | 107 quic_clock(NULL), |
| 115 quic_random(NULL), | 108 quic_random(NULL), |
| 116 quic_max_packet_length(kDefaultMaxPacketSize), | 109 quic_max_packet_length(kDefaultMaxPacketSize), |
| 117 enable_user_alternate_protocol_ports(false), | 110 enable_user_alternate_protocol_ports(false), |
| 118 quic_crypto_client_stream_factory( | 111 quic_crypto_client_stream_factory( |
| 119 QuicCryptoClientStreamFactory::GetDefaultFactory()), | 112 QuicCryptoClientStreamFactory::GetDefaultFactory()), |
| 120 quic_max_recent_disabled_reasons(kQuicMaxRecentDisabledReasons), | |
| 121 quic_threshold_public_resets_post_handshake(0), | |
| 122 quic_threshold_timeouts_streams_open(0), | |
| 123 quic_close_sessions_on_ip_change(false), | 113 quic_close_sessions_on_ip_change(false), |
| 124 quic_idle_connection_timeout_seconds(kIdleConnectionTimeoutSeconds), | 114 quic_idle_connection_timeout_seconds(kIdleConnectionTimeoutSeconds), |
| 125 quic_reduced_ping_timeout_seconds(kPingTimeoutSecs), | 115 quic_reduced_ping_timeout_seconds(kPingTimeoutSecs), |
| 126 quic_packet_reader_yield_after_duration_milliseconds( | 116 quic_packet_reader_yield_after_duration_milliseconds( |
| 127 kQuicYieldAfterDurationMilliseconds), | 117 kQuicYieldAfterDurationMilliseconds), |
| 128 quic_disable_preconnect_if_0rtt(false), | 118 quic_disable_preconnect_if_0rtt(false), |
| 129 quic_migrate_sessions_on_network_change(false), | 119 quic_migrate_sessions_on_network_change(false), |
| 130 quic_migrate_sessions_early(false), | 120 quic_migrate_sessions_early(false), |
| 131 quic_allow_server_migration(false), | 121 quic_allow_server_migration(false), |
| 132 quic_disable_bidirectional_streams(false), | 122 quic_disable_bidirectional_streams(false), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 params.quic_user_agent_id, | 162 params.quic_user_agent_id, |
| 173 params.quic_supported_versions, | 163 params.quic_supported_versions, |
| 174 params.enable_quic_port_selection, | 164 params.enable_quic_port_selection, |
| 175 params.quic_always_require_handshake_confirmation, | 165 params.quic_always_require_handshake_confirmation, |
| 176 params.quic_disable_connection_pooling, | 166 params.quic_disable_connection_pooling, |
| 177 params.quic_load_server_info_timeout_srtt_multiplier, | 167 params.quic_load_server_info_timeout_srtt_multiplier, |
| 178 params.quic_enable_connection_racing, | 168 params.quic_enable_connection_racing, |
| 179 params.quic_enable_non_blocking_io, | 169 params.quic_enable_non_blocking_io, |
| 180 params.quic_disable_disk_cache, | 170 params.quic_disable_disk_cache, |
| 181 params.quic_prefer_aes, | 171 params.quic_prefer_aes, |
| 182 params.quic_max_number_of_lossy_connections, | |
| 183 params.quic_packet_loss_threshold, | |
| 184 params.quic_max_recent_disabled_reasons, | |
| 185 params.quic_threshold_public_resets_post_handshake, | |
| 186 params.quic_threshold_timeouts_streams_open, | |
| 187 params.quic_socket_receive_buffer_size, | 172 params.quic_socket_receive_buffer_size, |
| 188 params.quic_delay_tcp_race, | 173 params.quic_delay_tcp_race, |
| 189 params.quic_max_server_configs_stored_in_properties, | 174 params.quic_max_server_configs_stored_in_properties, |
| 190 params.quic_close_sessions_on_ip_change, | 175 params.quic_close_sessions_on_ip_change, |
| 191 params.disable_quic_on_timeout_with_open_streams, | 176 params.disable_quic_on_timeout_with_open_streams, |
| 192 params.quic_idle_connection_timeout_seconds, | 177 params.quic_idle_connection_timeout_seconds, |
| 193 params.quic_reduced_ping_timeout_seconds, | 178 params.quic_reduced_ping_timeout_seconds, |
| 194 params.quic_packet_reader_yield_after_duration_milliseconds, | 179 params.quic_packet_reader_yield_after_duration_milliseconds, |
| 195 params.quic_migrate_sessions_on_network_change, | 180 params.quic_migrate_sessions_on_network_change, |
| 196 params.quic_migrate_sessions_early, | 181 params.quic_migrate_sessions_early, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 origins_to_force_quic_on->AppendString("'" + origin.ToString() + "'"); | 314 origins_to_force_quic_on->AppendString("'" + origin.ToString() + "'"); |
| 330 } | 315 } |
| 331 dict->Set("origins_to_force_quic_on", std::move(origins_to_force_quic_on)); | 316 dict->Set("origins_to_force_quic_on", std::move(origins_to_force_quic_on)); |
| 332 | 317 |
| 333 dict->SetDouble("load_server_info_timeout_srtt_multiplier", | 318 dict->SetDouble("load_server_info_timeout_srtt_multiplier", |
| 334 params_.quic_load_server_info_timeout_srtt_multiplier); | 319 params_.quic_load_server_info_timeout_srtt_multiplier); |
| 335 dict->SetBoolean("enable_connection_racing", | 320 dict->SetBoolean("enable_connection_racing", |
| 336 params_.quic_enable_connection_racing); | 321 params_.quic_enable_connection_racing); |
| 337 dict->SetBoolean("disable_disk_cache", params_.quic_disable_disk_cache); | 322 dict->SetBoolean("disable_disk_cache", params_.quic_disable_disk_cache); |
| 338 dict->SetBoolean("prefer_aes", params_.quic_prefer_aes); | 323 dict->SetBoolean("prefer_aes", params_.quic_prefer_aes); |
| 339 dict->SetInteger("max_number_of_lossy_connections", | |
| 340 params_.quic_max_number_of_lossy_connections); | |
| 341 dict->SetDouble("packet_loss_threshold", params_.quic_packet_loss_threshold); | |
| 342 dict->SetBoolean("delay_tcp_race", params_.quic_delay_tcp_race); | 324 dict->SetBoolean("delay_tcp_race", params_.quic_delay_tcp_race); |
| 343 dict->SetInteger("max_server_configs_stored_in_properties", | 325 dict->SetInteger("max_server_configs_stored_in_properties", |
| 344 params_.quic_max_server_configs_stored_in_properties); | 326 params_.quic_max_server_configs_stored_in_properties); |
| 345 dict->SetInteger("idle_connection_timeout_seconds", | 327 dict->SetInteger("idle_connection_timeout_seconds", |
| 346 params_.quic_idle_connection_timeout_seconds); | 328 params_.quic_idle_connection_timeout_seconds); |
| 347 dict->SetInteger("reduced_ping_timeout_seconds", | 329 dict->SetInteger("reduced_ping_timeout_seconds", |
| 348 params_.quic_reduced_ping_timeout_seconds); | 330 params_.quic_reduced_ping_timeout_seconds); |
| 349 dict->SetInteger( | 331 dict->SetInteger( |
| 350 "packet_reader_yield_after_duration_milliseconds", | 332 "packet_reader_yield_after_duration_milliseconds", |
| 351 params_.quic_packet_reader_yield_after_duration_milliseconds); | 333 params_.quic_packet_reader_yield_after_duration_milliseconds); |
| 352 dict->SetBoolean("disable_preconnect_if_0rtt", | 334 dict->SetBoolean("disable_preconnect_if_0rtt", |
| 353 params_.quic_disable_preconnect_if_0rtt); | 335 params_.quic_disable_preconnect_if_0rtt); |
| 354 dict->SetBoolean("disable_quic_on_timeout_with_open_streams", | 336 dict->SetBoolean("disable_quic_on_timeout_with_open_streams", |
| 355 params_.disable_quic_on_timeout_with_open_streams); | 337 params_.disable_quic_on_timeout_with_open_streams); |
| 356 dict->SetString("disabled_reason", | 338 dict->SetBoolean("is_quic_disabled", quic_stream_factory_.IsQuicDisabled()); |
| 357 quic_stream_factory_.QuicDisabledReasonString()); | |
| 358 dict->SetBoolean("force_hol_blocking", params_.quic_force_hol_blocking); | 339 dict->SetBoolean("force_hol_blocking", params_.quic_force_hol_blocking); |
| 359 dict->SetBoolean("race_cert_verification", | 340 dict->SetBoolean("race_cert_verification", |
| 360 params_.quic_race_cert_verification); | 341 params_.quic_race_cert_verification); |
| 361 return std::move(dict); | 342 return std::move(dict); |
| 362 } | 343 } |
| 363 | 344 |
| 364 void HttpNetworkSession::CloseAllConnections() { | 345 void HttpNetworkSession::CloseAllConnections() { |
| 365 normal_socket_pool_manager_->FlushSocketPoolsWithError(ERR_ABORTED); | 346 normal_socket_pool_manager_->FlushSocketPoolsWithError(ERR_ABORTED); |
| 366 websocket_socket_pool_manager_->FlushSocketPoolsWithError(ERR_ABORTED); | 347 websocket_socket_pool_manager_->FlushSocketPoolsWithError(ERR_ABORTED); |
| 367 spdy_session_pool_.CloseCurrentSessions(ERR_ABORTED); | 348 spdy_session_pool_.CloseCurrentSessions(ERR_ABORTED); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: | 403 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: |
| 423 break; | 404 break; |
| 424 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE: | 405 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE: |
| 425 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: | 406 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: |
| 426 CloseIdleConnections(); | 407 CloseIdleConnections(); |
| 427 break; | 408 break; |
| 428 } | 409 } |
| 429 } | 410 } |
| 430 | 411 |
| 431 } // namespace net | 412 } // namespace net |
| OLD | NEW |