| 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/quic/quic_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 int max_disabled_reasons, | 578 int max_disabled_reasons, |
| 579 int threshold_public_resets_post_handshake, | 579 int threshold_public_resets_post_handshake, |
| 580 int threshold_timeouts_with_open_streams, | 580 int threshold_timeouts_with_open_streams, |
| 581 int socket_receive_buffer_size, | 581 int socket_receive_buffer_size, |
| 582 bool delay_tcp_race, | 582 bool delay_tcp_race, |
| 583 int max_server_configs_stored_in_properties, | 583 int max_server_configs_stored_in_properties, |
| 584 bool close_sessions_on_ip_change, | 584 bool close_sessions_on_ip_change, |
| 585 bool disable_quic_on_timeout_with_open_streams, | 585 bool disable_quic_on_timeout_with_open_streams, |
| 586 int idle_connection_timeout_seconds, | 586 int idle_connection_timeout_seconds, |
| 587 bool migrate_sessions_on_network_change, | 587 bool migrate_sessions_on_network_change, |
| 588 bool migrate_sessions_early, |
| 588 const QuicTagVector& connection_options) | 589 const QuicTagVector& connection_options) |
| 589 : require_confirmation_(true), | 590 : require_confirmation_(true), |
| 590 host_resolver_(host_resolver), | 591 host_resolver_(host_resolver), |
| 591 client_socket_factory_(client_socket_factory), | 592 client_socket_factory_(client_socket_factory), |
| 592 http_server_properties_(http_server_properties), | 593 http_server_properties_(http_server_properties), |
| 593 transport_security_state_(transport_security_state), | 594 transport_security_state_(transport_security_state), |
| 594 cert_transparency_verifier_(cert_transparency_verifier), | 595 cert_transparency_verifier_(cert_transparency_verifier), |
| 595 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 596 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
| 596 random_generator_(random_generator), | 597 random_generator_(random_generator), |
| 597 clock_(clock), | 598 clock_(clock), |
| (...skipping 29 matching lines...) Expand all Loading... |
| 627 threshold_public_resets_post_handshake), | 628 threshold_public_resets_post_handshake), |
| 628 socket_receive_buffer_size_(socket_receive_buffer_size), | 629 socket_receive_buffer_size_(socket_receive_buffer_size), |
| 629 delay_tcp_race_(delay_tcp_race), | 630 delay_tcp_race_(delay_tcp_race), |
| 630 yield_after_packets_(kQuicYieldAfterPacketsRead), | 631 yield_after_packets_(kQuicYieldAfterPacketsRead), |
| 631 yield_after_duration_(QuicTime::Delta::FromMilliseconds( | 632 yield_after_duration_(QuicTime::Delta::FromMilliseconds( |
| 632 kQuicYieldAfterDurationMilliseconds)), | 633 kQuicYieldAfterDurationMilliseconds)), |
| 633 close_sessions_on_ip_change_(close_sessions_on_ip_change), | 634 close_sessions_on_ip_change_(close_sessions_on_ip_change), |
| 634 migrate_sessions_on_network_change_( | 635 migrate_sessions_on_network_change_( |
| 635 migrate_sessions_on_network_change && | 636 migrate_sessions_on_network_change && |
| 636 NetworkChangeNotifier::AreNetworkHandlesSupported()), | 637 NetworkChangeNotifier::AreNetworkHandlesSupported()), |
| 638 migrate_sessions_early_(migrate_sessions_early && |
| 639 migrate_sessions_on_network_change_), |
| 637 port_seed_(random_generator_->RandUint64()), | 640 port_seed_(random_generator_->RandUint64()), |
| 638 check_persisted_supports_quic_(true), | 641 check_persisted_supports_quic_(true), |
| 639 has_initialized_data_(false), | 642 has_initialized_data_(false), |
| 640 task_runner_(nullptr), | 643 task_runner_(nullptr), |
| 641 weak_factory_(this) { | 644 weak_factory_(this) { |
| 642 if (disable_quic_on_timeout_with_open_streams) | 645 if (disable_quic_on_timeout_with_open_streams) |
| 643 threshold_timeouts_with_open_streams_ = 1; | 646 threshold_timeouts_with_open_streams_ = 1; |
| 644 DCHECK(transport_security_state_); | 647 DCHECK(transport_security_state_); |
| 645 DCHECK(http_server_properties_); | 648 DCHECK(http_server_properties_); |
| 646 crypto_config_.set_user_agent_id(user_agent_id); | 649 crypto_config_.set_user_agent_id(user_agent_id); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 667 if (!IsEcdsaSupported()) | 670 if (!IsEcdsaSupported()) |
| 668 crypto_config_.DisableEcdsa(); | 671 crypto_config_.DisableEcdsa(); |
| 669 // When disk cache is used to store the server configs, HttpCache code calls | 672 // When disk cache is used to store the server configs, HttpCache code calls |
| 670 // |set_quic_server_info_factory| if |quic_server_info_factory_| wasn't | 673 // |set_quic_server_info_factory| if |quic_server_info_factory_| wasn't |
| 671 // created. | 674 // created. |
| 672 if (max_server_configs_stored_in_properties > 0) { | 675 if (max_server_configs_stored_in_properties > 0) { |
| 673 quic_server_info_factory_.reset( | 676 quic_server_info_factory_.reset( |
| 674 new PropertiesBasedQuicServerInfoFactory(http_server_properties_)); | 677 new PropertiesBasedQuicServerInfoFactory(http_server_properties_)); |
| 675 } | 678 } |
| 676 | 679 |
| 677 DCHECK( | 680 // migrate_sessions_early_ should only be set to true if |
| 678 !(close_sessions_on_ip_change_ && migrate_sessions_on_network_change_)); | 681 // migrate_sessions_on_network_change_ is set to true. |
| 682 DCHECK(migrate_sessions_on_network_change_ || !migrate_sessions_early_); |
| 683 // close_sessions_on_ip_change_ and migrate_sessions_on_network_change_ should |
| 684 // never be simultaneously set to true. |
| 685 DCHECK(!close_sessions_on_ip_change_ || !migrate_sessions_on_network_change_); |
| 679 if (migrate_sessions_on_network_change_) { | 686 if (migrate_sessions_on_network_change_) { |
| 680 NetworkChangeNotifier::AddNetworkObserver(this); | 687 NetworkChangeNotifier::AddNetworkObserver(this); |
| 681 } else if (close_sessions_on_ip_change_) { | 688 } else if (close_sessions_on_ip_change_) { |
| 682 NetworkChangeNotifier::AddIPAddressObserver(this); | 689 NetworkChangeNotifier::AddIPAddressObserver(this); |
| 683 } | 690 } |
| 684 } | 691 } |
| 685 | 692 |
| 686 QuicStreamFactory::~QuicStreamFactory() { | 693 QuicStreamFactory::~QuicStreamFactory() { |
| 687 CloseAllSessions(ERR_ABORTED, QUIC_INTERNAL_ERROR); | 694 CloseAllSessions(ERR_ABORTED, QUIC_INTERNAL_ERROR); |
| 688 while (!all_sessions_.empty()) { | 695 while (!all_sessions_.empty()) { |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 QUIC_CONNECTION_MIGRATION_NO_NEW_NETWORK); | 1254 QUIC_CONNECTION_MIGRATION_NO_NEW_NETWORK); |
| 1248 } | 1255 } |
| 1249 continue; | 1256 continue; |
| 1250 } | 1257 } |
| 1251 MigrateSessionToNetwork(session, new_network); | 1258 MigrateSessionToNetwork(session, new_network); |
| 1252 } | 1259 } |
| 1253 } | 1260 } |
| 1254 | 1261 |
| 1255 void QuicStreamFactory::MaybeMigrateSessionEarly( | 1262 void QuicStreamFactory::MaybeMigrateSessionEarly( |
| 1256 QuicChromiumClientSession* session) { | 1263 QuicChromiumClientSession* session) { |
| 1257 if (session->GetNumActiveStreams() == 0) { | 1264 if (!migrate_sessions_early_ || (session->GetNumActiveStreams() == 0)) { |
| 1258 return; | 1265 return; |
| 1259 } | 1266 } |
| 1260 NetworkChangeNotifier::NetworkHandle current_network = | 1267 NetworkChangeNotifier::NetworkHandle current_network = |
| 1261 session->GetDefaultSocket()->GetBoundNetwork(); | 1268 session->GetDefaultSocket()->GetBoundNetwork(); |
| 1262 NetworkChangeNotifier::NetworkHandle new_network = | 1269 NetworkChangeNotifier::NetworkHandle new_network = |
| 1263 FindAlternateNetwork(current_network); | 1270 FindAlternateNetwork(current_network); |
| 1264 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) { | 1271 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) { |
| 1265 // No alternate network found. | 1272 // No alternate network found. |
| 1266 return; | 1273 return; |
| 1267 } | 1274 } |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 // Since the session was active, there's no longer an | 1649 // Since the session was active, there's no longer an |
| 1643 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1650 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
| 1644 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1651 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
| 1645 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1652 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1646 // still race. | 1653 // still race. |
| 1647 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1654 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1648 alternative_service); | 1655 alternative_service); |
| 1649 } | 1656 } |
| 1650 | 1657 |
| 1651 } // namespace net | 1658 } // namespace net |
| OLD | NEW |