| 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 |
| 69 HttpNetworkSession::Params::Params() | 74 HttpNetworkSession::Params::Params() |
| 70 : client_socket_factory(NULL), | 75 : client_socket_factory(NULL), |
| 71 host_resolver(NULL), | 76 host_resolver(NULL), |
| 72 cert_verifier(NULL), | 77 cert_verifier(NULL), |
| 73 channel_id_service(NULL), | 78 channel_id_service(NULL), |
| 74 transport_security_state(NULL), | 79 transport_security_state(NULL), |
| 75 cert_transparency_verifier(NULL), | 80 cert_transparency_verifier(NULL), |
| 76 ct_policy_enforcer(NULL), | 81 ct_policy_enforcer(NULL), |
| 77 proxy_service(NULL), | 82 proxy_service(NULL), |
| 78 ssl_config_service(NULL), | 83 ssl_config_service(NULL), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 94 enable_quic(false), | 99 enable_quic(false), |
| 95 disable_quic_on_timeout_with_open_streams(false), | 100 disable_quic_on_timeout_with_open_streams(false), |
| 96 enable_quic_port_selection(true), | 101 enable_quic_port_selection(true), |
| 97 quic_always_require_handshake_confirmation(false), | 102 quic_always_require_handshake_confirmation(false), |
| 98 quic_disable_connection_pooling(false), | 103 quic_disable_connection_pooling(false), |
| 99 quic_load_server_info_timeout_srtt_multiplier(0.25f), | 104 quic_load_server_info_timeout_srtt_multiplier(0.25f), |
| 100 quic_enable_connection_racing(false), | 105 quic_enable_connection_racing(false), |
| 101 quic_enable_non_blocking_io(false), | 106 quic_enable_non_blocking_io(false), |
| 102 quic_disable_disk_cache(false), | 107 quic_disable_disk_cache(false), |
| 103 quic_prefer_aes(false), | 108 quic_prefer_aes(false), |
| 109 quic_max_number_of_lossy_connections(0), |
| 110 quic_packet_loss_threshold(1.0f), |
| 104 quic_socket_receive_buffer_size(kQuicSocketReceiveBufferSize), | 111 quic_socket_receive_buffer_size(kQuicSocketReceiveBufferSize), |
| 105 quic_delay_tcp_race(true), | 112 quic_delay_tcp_race(true), |
| 106 quic_max_server_configs_stored_in_properties(0u), | 113 quic_max_server_configs_stored_in_properties(0u), |
| 107 quic_clock(NULL), | 114 quic_clock(NULL), |
| 108 quic_random(NULL), | 115 quic_random(NULL), |
| 109 quic_max_packet_length(kDefaultMaxPacketSize), | 116 quic_max_packet_length(kDefaultMaxPacketSize), |
| 110 enable_user_alternate_protocol_ports(false), | 117 enable_user_alternate_protocol_ports(false), |
| 111 quic_crypto_client_stream_factory( | 118 quic_crypto_client_stream_factory( |
| 112 QuicCryptoClientStreamFactory::GetDefaultFactory()), | 119 QuicCryptoClientStreamFactory::GetDefaultFactory()), |
| 120 quic_max_recent_disabled_reasons(kQuicMaxRecentDisabledReasons), |
| 121 quic_threshold_public_resets_post_handshake(0), |
| 122 quic_threshold_timeouts_streams_open(0), |
| 113 quic_close_sessions_on_ip_change(false), | 123 quic_close_sessions_on_ip_change(false), |
| 114 quic_idle_connection_timeout_seconds(kIdleConnectionTimeoutSeconds), | 124 quic_idle_connection_timeout_seconds(kIdleConnectionTimeoutSeconds), |
| 115 quic_reduced_ping_timeout_seconds(kPingTimeoutSecs), | 125 quic_reduced_ping_timeout_seconds(kPingTimeoutSecs), |
| 116 quic_packet_reader_yield_after_duration_milliseconds( | 126 quic_packet_reader_yield_after_duration_milliseconds( |
| 117 kQuicYieldAfterDurationMilliseconds), | 127 kQuicYieldAfterDurationMilliseconds), |
| 118 quic_disable_preconnect_if_0rtt(false), | 128 quic_disable_preconnect_if_0rtt(false), |
| 119 quic_migrate_sessions_on_network_change(false), | 129 quic_migrate_sessions_on_network_change(false), |
| 120 quic_migrate_sessions_early(false), | 130 quic_migrate_sessions_early(false), |
| 121 quic_allow_server_migration(false), | 131 quic_allow_server_migration(false), |
| 122 quic_disable_bidirectional_streams(false), | 132 quic_disable_bidirectional_streams(false), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 params.quic_user_agent_id, | 172 params.quic_user_agent_id, |
| 163 params.quic_supported_versions, | 173 params.quic_supported_versions, |
| 164 params.enable_quic_port_selection, | 174 params.enable_quic_port_selection, |
| 165 params.quic_always_require_handshake_confirmation, | 175 params.quic_always_require_handshake_confirmation, |
| 166 params.quic_disable_connection_pooling, | 176 params.quic_disable_connection_pooling, |
| 167 params.quic_load_server_info_timeout_srtt_multiplier, | 177 params.quic_load_server_info_timeout_srtt_multiplier, |
| 168 params.quic_enable_connection_racing, | 178 params.quic_enable_connection_racing, |
| 169 params.quic_enable_non_blocking_io, | 179 params.quic_enable_non_blocking_io, |
| 170 params.quic_disable_disk_cache, | 180 params.quic_disable_disk_cache, |
| 171 params.quic_prefer_aes, | 181 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, |
| 172 params.quic_socket_receive_buffer_size, | 187 params.quic_socket_receive_buffer_size, |
| 173 params.quic_delay_tcp_race, | 188 params.quic_delay_tcp_race, |
| 174 params.quic_max_server_configs_stored_in_properties, | 189 params.quic_max_server_configs_stored_in_properties, |
| 175 params.quic_close_sessions_on_ip_change, | 190 params.quic_close_sessions_on_ip_change, |
| 176 params.disable_quic_on_timeout_with_open_streams, | 191 params.disable_quic_on_timeout_with_open_streams, |
| 177 params.quic_idle_connection_timeout_seconds, | 192 params.quic_idle_connection_timeout_seconds, |
| 178 params.quic_reduced_ping_timeout_seconds, | 193 params.quic_reduced_ping_timeout_seconds, |
| 179 params.quic_packet_reader_yield_after_duration_milliseconds, | 194 params.quic_packet_reader_yield_after_duration_milliseconds, |
| 180 params.quic_migrate_sessions_on_network_change, | 195 params.quic_migrate_sessions_on_network_change, |
| 181 params.quic_migrate_sessions_early, | 196 params.quic_migrate_sessions_early, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 origins_to_force_quic_on->AppendString("'" + origin.ToString() + "'"); | 329 origins_to_force_quic_on->AppendString("'" + origin.ToString() + "'"); |
| 315 } | 330 } |
| 316 dict->Set("origins_to_force_quic_on", std::move(origins_to_force_quic_on)); | 331 dict->Set("origins_to_force_quic_on", std::move(origins_to_force_quic_on)); |
| 317 | 332 |
| 318 dict->SetDouble("load_server_info_timeout_srtt_multiplier", | 333 dict->SetDouble("load_server_info_timeout_srtt_multiplier", |
| 319 params_.quic_load_server_info_timeout_srtt_multiplier); | 334 params_.quic_load_server_info_timeout_srtt_multiplier); |
| 320 dict->SetBoolean("enable_connection_racing", | 335 dict->SetBoolean("enable_connection_racing", |
| 321 params_.quic_enable_connection_racing); | 336 params_.quic_enable_connection_racing); |
| 322 dict->SetBoolean("disable_disk_cache", params_.quic_disable_disk_cache); | 337 dict->SetBoolean("disable_disk_cache", params_.quic_disable_disk_cache); |
| 323 dict->SetBoolean("prefer_aes", params_.quic_prefer_aes); | 338 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); |
| 324 dict->SetBoolean("delay_tcp_race", params_.quic_delay_tcp_race); | 342 dict->SetBoolean("delay_tcp_race", params_.quic_delay_tcp_race); |
| 325 dict->SetInteger("max_server_configs_stored_in_properties", | 343 dict->SetInteger("max_server_configs_stored_in_properties", |
| 326 params_.quic_max_server_configs_stored_in_properties); | 344 params_.quic_max_server_configs_stored_in_properties); |
| 327 dict->SetInteger("idle_connection_timeout_seconds", | 345 dict->SetInteger("idle_connection_timeout_seconds", |
| 328 params_.quic_idle_connection_timeout_seconds); | 346 params_.quic_idle_connection_timeout_seconds); |
| 329 dict->SetInteger("reduced_ping_timeout_seconds", | 347 dict->SetInteger("reduced_ping_timeout_seconds", |
| 330 params_.quic_reduced_ping_timeout_seconds); | 348 params_.quic_reduced_ping_timeout_seconds); |
| 331 dict->SetInteger( | 349 dict->SetInteger( |
| 332 "packet_reader_yield_after_duration_milliseconds", | 350 "packet_reader_yield_after_duration_milliseconds", |
| 333 params_.quic_packet_reader_yield_after_duration_milliseconds); | 351 params_.quic_packet_reader_yield_after_duration_milliseconds); |
| 334 dict->SetBoolean("disable_preconnect_if_0rtt", | 352 dict->SetBoolean("disable_preconnect_if_0rtt", |
| 335 params_.quic_disable_preconnect_if_0rtt); | 353 params_.quic_disable_preconnect_if_0rtt); |
| 336 dict->SetBoolean("disable_quic_on_timeout_with_open_streams", | 354 dict->SetBoolean("disable_quic_on_timeout_with_open_streams", |
| 337 params_.disable_quic_on_timeout_with_open_streams); | 355 params_.disable_quic_on_timeout_with_open_streams); |
| 338 dict->SetBoolean("is_quic_disabled", quic_stream_factory_.IsQuicDisabled()); | 356 dict->SetString("disabled_reason", |
| 357 quic_stream_factory_.QuicDisabledReasonString()); |
| 339 dict->SetBoolean("force_hol_blocking", params_.quic_force_hol_blocking); | 358 dict->SetBoolean("force_hol_blocking", params_.quic_force_hol_blocking); |
| 340 dict->SetBoolean("race_cert_verification", | 359 dict->SetBoolean("race_cert_verification", |
| 341 params_.quic_race_cert_verification); | 360 params_.quic_race_cert_verification); |
| 342 return std::move(dict); | 361 return std::move(dict); |
| 343 } | 362 } |
| 344 | 363 |
| 345 void HttpNetworkSession::CloseAllConnections() { | 364 void HttpNetworkSession::CloseAllConnections() { |
| 346 normal_socket_pool_manager_->FlushSocketPoolsWithError(ERR_ABORTED); | 365 normal_socket_pool_manager_->FlushSocketPoolsWithError(ERR_ABORTED); |
| 347 websocket_socket_pool_manager_->FlushSocketPoolsWithError(ERR_ABORTED); | 366 websocket_socket_pool_manager_->FlushSocketPoolsWithError(ERR_ABORTED); |
| 348 spdy_session_pool_.CloseCurrentSessions(ERR_ABORTED); | 367 spdy_session_pool_.CloseCurrentSessions(ERR_ABORTED); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: | 422 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: |
| 404 break; | 423 break; |
| 405 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE: | 424 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE: |
| 406 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: | 425 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: |
| 407 CloseIdleConnections(); | 426 CloseIdleConnections(); |
| 408 break; | 427 break; |
| 409 } | 428 } |
| 410 } | 429 } |
| 411 | 430 |
| 412 } // namespace net | 431 } // namespace net |
| OLD | NEW |