Chromium Code Reviews| 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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 int max_disabled_reasons, | 584 int max_disabled_reasons, |
| 585 int threshold_public_resets_post_handshake, | 585 int threshold_public_resets_post_handshake, |
| 586 int threshold_timeouts_with_open_streams, | 586 int threshold_timeouts_with_open_streams, |
| 587 int socket_receive_buffer_size, | 587 int socket_receive_buffer_size, |
| 588 bool delay_tcp_race, | 588 bool delay_tcp_race, |
| 589 int max_server_configs_stored_in_properties, | 589 int max_server_configs_stored_in_properties, |
| 590 bool close_sessions_on_ip_change, | 590 bool close_sessions_on_ip_change, |
| 591 bool disable_quic_on_timeout_with_open_streams, | 591 bool disable_quic_on_timeout_with_open_streams, |
| 592 int idle_connection_timeout_seconds, | 592 int idle_connection_timeout_seconds, |
| 593 bool migrate_sessions_on_network_change, | 593 bool migrate_sessions_on_network_change, |
| 594 bool migrate_sessions_early, | |
| 594 const QuicTagVector& connection_options) | 595 const QuicTagVector& connection_options) |
| 595 : require_confirmation_(true), | 596 : require_confirmation_(true), |
| 596 host_resolver_(host_resolver), | 597 host_resolver_(host_resolver), |
| 597 client_socket_factory_(client_socket_factory), | 598 client_socket_factory_(client_socket_factory), |
| 598 http_server_properties_(http_server_properties), | 599 http_server_properties_(http_server_properties), |
| 599 transport_security_state_(transport_security_state), | 600 transport_security_state_(transport_security_state), |
| 600 cert_transparency_verifier_(cert_transparency_verifier), | 601 cert_transparency_verifier_(cert_transparency_verifier), |
| 601 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 602 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
| 602 random_generator_(random_generator), | 603 random_generator_(random_generator), |
| 603 clock_(clock), | 604 clock_(clock), |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 633 threshold_public_resets_post_handshake), | 634 threshold_public_resets_post_handshake), |
| 634 socket_receive_buffer_size_(socket_receive_buffer_size), | 635 socket_receive_buffer_size_(socket_receive_buffer_size), |
| 635 delay_tcp_race_(delay_tcp_race), | 636 delay_tcp_race_(delay_tcp_race), |
| 636 yield_after_packets_(kQuicYieldAfterPacketsRead), | 637 yield_after_packets_(kQuicYieldAfterPacketsRead), |
| 637 yield_after_duration_(QuicTime::Delta::FromMilliseconds( | 638 yield_after_duration_(QuicTime::Delta::FromMilliseconds( |
| 638 kQuicYieldAfterDurationMilliseconds)), | 639 kQuicYieldAfterDurationMilliseconds)), |
| 639 close_sessions_on_ip_change_(close_sessions_on_ip_change), | 640 close_sessions_on_ip_change_(close_sessions_on_ip_change), |
| 640 migrate_sessions_on_network_change_( | 641 migrate_sessions_on_network_change_( |
| 641 migrate_sessions_on_network_change && | 642 migrate_sessions_on_network_change && |
| 642 NetworkChangeNotifier::AreNetworkHandlesSupported()), | 643 NetworkChangeNotifier::AreNetworkHandlesSupported()), |
| 644 migrate_sessions_early_(migrate_sessions_early && | |
| 645 migrate_sessions_on_network_change_), | |
| 643 port_seed_(random_generator_->RandUint64()), | 646 port_seed_(random_generator_->RandUint64()), |
| 644 check_persisted_supports_quic_(true), | 647 check_persisted_supports_quic_(true), |
| 645 has_initialized_data_(false), | 648 has_initialized_data_(false), |
| 646 task_runner_(nullptr), | 649 task_runner_(nullptr), |
| 647 weak_factory_(this) { | 650 weak_factory_(this) { |
| 648 if (disable_quic_on_timeout_with_open_streams) | 651 if (disable_quic_on_timeout_with_open_streams) |
| 649 threshold_timeouts_with_open_streams_ = 1; | 652 threshold_timeouts_with_open_streams_ = 1; |
| 650 DCHECK(transport_security_state_); | 653 DCHECK(transport_security_state_); |
| 651 DCHECK(http_server_properties_); | 654 DCHECK(http_server_properties_); |
| 652 crypto_config_.set_user_agent_id(user_agent_id); | 655 crypto_config_.set_user_agent_id(user_agent_id); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 673 if (!IsEcdsaSupported()) | 676 if (!IsEcdsaSupported()) |
| 674 crypto_config_.DisableEcdsa(); | 677 crypto_config_.DisableEcdsa(); |
| 675 // When disk cache is used to store the server configs, HttpCache code calls | 678 // When disk cache is used to store the server configs, HttpCache code calls |
| 676 // |set_quic_server_info_factory| if |quic_server_info_factory_| wasn't | 679 // |set_quic_server_info_factory| if |quic_server_info_factory_| wasn't |
| 677 // created. | 680 // created. |
| 678 if (max_server_configs_stored_in_properties > 0) { | 681 if (max_server_configs_stored_in_properties > 0) { |
| 679 quic_server_info_factory_.reset( | 682 quic_server_info_factory_.reset( |
| 680 new PropertiesBasedQuicServerInfoFactory(http_server_properties_)); | 683 new PropertiesBasedQuicServerInfoFactory(http_server_properties_)); |
| 681 } | 684 } |
| 682 | 685 |
| 683 DCHECK( | 686 // migrate_sessions_early_ should only be set to true if |
| 684 !(close_sessions_on_ip_change_ && migrate_sessions_on_network_change_)); | 687 // migrate_sessions_on_network_change_ is set to true. |
| 688 DCHECK(migrate_sessions_on_network_change_ || !migrate_sessions_early_); | |
| 689 // close_sessions_on_ip_change_ and migrate_sessions_on_network_change_ should | |
| 690 // never be simultaneously set to true. | |
| 691 DCHECK(!close_sessions_on_ip_change_ || !migrate_sessions_on_network_change_); | |
| 685 if (migrate_sessions_on_network_change_) { | 692 if (migrate_sessions_on_network_change_) { |
| 686 NetworkChangeNotifier::AddNetworkObserver(this); | 693 NetworkChangeNotifier::AddNetworkObserver(this); |
| 687 } else if (close_sessions_on_ip_change_) { | 694 } else if (close_sessions_on_ip_change_) { |
| 688 NetworkChangeNotifier::AddIPAddressObserver(this); | 695 NetworkChangeNotifier::AddIPAddressObserver(this); |
| 689 } | 696 } |
| 690 } | 697 } |
| 691 | 698 |
| 692 QuicStreamFactory::~QuicStreamFactory() { | 699 QuicStreamFactory::~QuicStreamFactory() { |
| 693 CloseAllSessions(ERR_ABORTED, QUIC_CONNECTION_CANCELLED); | 700 CloseAllSessions(ERR_ABORTED, QUIC_CONNECTION_CANCELLED); |
| 694 while (!all_sessions_.empty()) { | 701 while (!all_sessions_.empty()) { |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1254 QUIC_CONNECTION_MIGRATION_NO_NEW_NETWORK); | 1261 QUIC_CONNECTION_MIGRATION_NO_NEW_NETWORK); |
| 1255 } | 1262 } |
| 1256 continue; | 1263 continue; |
| 1257 } | 1264 } |
| 1258 MigrateSessionToNetwork(session, new_network); | 1265 MigrateSessionToNetwork(session, new_network); |
| 1259 } | 1266 } |
| 1260 } | 1267 } |
| 1261 | 1268 |
| 1262 void QuicStreamFactory::MaybeMigrateSessionEarly( | 1269 void QuicStreamFactory::MaybeMigrateSessionEarly( |
| 1263 QuicChromiumClientSession* session) { | 1270 QuicChromiumClientSession* session) { |
| 1264 if (session->GetNumActiveStreams() == 0) { | 1271 if (!migrate_sessions_early_ || (session->GetNumActiveStreams() == 0)) { |
|
Ryan Hamilton
2016/02/05 01:32:55
nit: no need for the extra ()s, I don't think.
Ac
Jana
2016/02/05 03:03:31
Yeah, I put those for clarity, but maybe it's more
Ryan Hamilton
2016/02/05 17:57:37
I guess I'm confused about the motivations for ear
Jana
2016/02/05 22:24:36
Per our offline conversation, we'll migrate all se
| |
| 1265 return; | 1272 return; |
| 1266 } | 1273 } |
| 1267 NetworkChangeNotifier::NetworkHandle current_network = | 1274 NetworkChangeNotifier::NetworkHandle current_network = |
|
Ryan Hamilton
2016/02/05 01:32:55
You might consider "using NetworkChangeNotifier::N
Jana
2016/02/05 03:03:31
Yeah, I wanted that too :-) NetworkHandle is a t
Ryan Hamilton
2016/02/05 17:57:37
Really? f'n C++. What's the error?
Jana
2016/02/05 22:24:36
"using declaration cannot refer to class member".
| |
| 1268 session->GetDefaultSocket()->GetBoundNetwork(); | 1275 session->GetDefaultSocket()->GetBoundNetwork(); |
| 1269 NetworkChangeNotifier::NetworkHandle new_network = | 1276 NetworkChangeNotifier::NetworkHandle new_network = |
| 1270 FindAlternateNetwork(current_network); | 1277 FindAlternateNetwork(current_network); |
|
Ryan Hamilton
2016/02/05 01:32:55
Might as well just inline this:
NetworkChangeNoti
Jana
2016/02/05 03:03:31
Done.
| |
| 1271 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) { | 1278 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) { |
| 1272 // No alternate network found. | 1279 // No alternate network found. |
| 1273 return; | 1280 return; |
| 1274 } | 1281 } |
| 1275 OnSessionGoingAway(session); | 1282 OnSessionGoingAway(session); |
| 1276 MigrateSessionToNetwork(session, new_network); | 1283 MigrateSessionToNetwork(session, new_network); |
| 1277 } | 1284 } |
| 1278 | 1285 |
| 1279 void QuicStreamFactory::MigrateSessionToNetwork( | 1286 void QuicStreamFactory::MigrateSessionToNetwork( |
| 1280 QuicChromiumClientSession* session, | 1287 QuicChromiumClientSession* session, |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1654 // Since the session was active, there's no longer an | 1661 // Since the session was active, there's no longer an |
| 1655 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1662 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
| 1656 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1663 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
| 1657 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1664 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1658 // still race. | 1665 // still race. |
| 1659 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1666 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1660 alternative_service); | 1667 alternative_service); |
| 1661 } | 1668 } |
| 1662 | 1669 |
| 1663 } // namespace net | 1670 } // namespace net |
| OLD | NEW |