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/chromium/quic_stream_factory.h" | 5 #include "net/quic/chromium/quic_stream_factory.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 659 } | 659 } |
| 660 | 660 |
| 661 factory_->ActivateSession(key_, session_); | 661 factory_->ActivateSession(key_, session_); |
| 662 | 662 |
| 663 return OK; | 663 return OK; |
| 664 } | 664 } |
| 665 | 665 |
| 666 QuicStreamRequest::QuicStreamRequest( | 666 QuicStreamRequest::QuicStreamRequest( |
| 667 QuicStreamFactory* factory, | 667 QuicStreamFactory* factory, |
| 668 HttpServerProperties* http_server_properties) | 668 HttpServerProperties* http_server_properties) |
| 669 : factory_(factory), http_server_properties_(http_server_properties) {} | 669 : factory_(factory), |
| 670 http_server_properties_(http_server_properties), | |
| 671 mark_quic_broken_when_network_suspected_( | |
| 672 factory->mark_quic_broken_when_network_suspected()) {} | |
| 670 | 673 |
| 671 QuicStreamRequest::~QuicStreamRequest() { | 674 QuicStreamRequest::~QuicStreamRequest() { |
| 672 if (factory_ && !callback_.is_null()) | 675 if (factory_ && !callback_.is_null()) |
| 673 factory_->CancelRequest(this); | 676 factory_->CancelRequest(this); |
| 674 } | 677 } |
| 675 | 678 |
| 676 int QuicStreamRequest::Request(const HostPortPair& destination, | 679 int QuicStreamRequest::Request(const HostPortPair& destination, |
| 677 PrivacyMode privacy_mode, | 680 PrivacyMode privacy_mode, |
| 678 int cert_verify_flags, | 681 int cert_verify_flags, |
| 679 const GURL& url, | 682 const GURL& url, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 709 | 712 |
| 710 base::TimeDelta QuicStreamRequest::GetTimeDelayForWaitingJob() const { | 713 base::TimeDelta QuicStreamRequest::GetTimeDelayForWaitingJob() const { |
| 711 if (!factory_) | 714 if (!factory_) |
| 712 return base::TimeDelta(); | 715 return base::TimeDelta(); |
| 713 return factory_->GetTimeDelayForWaitingJob(server_id_); | 716 return factory_->GetTimeDelayForWaitingJob(server_id_); |
| 714 } | 717 } |
| 715 | 718 |
| 716 std::unique_ptr<QuicHttpStream> QuicStreamRequest::CreateStream() { | 719 std::unique_ptr<QuicHttpStream> QuicStreamRequest::CreateStream() { |
| 717 if (!session_) | 720 if (!session_) |
| 718 return nullptr; | 721 return nullptr; |
| 719 return base::MakeUnique<QuicHttpStream>(session_, http_server_properties_); | 722 return base::MakeUnique<QuicHttpStream>( |
| 723 session_, http_server_properties_, | |
| 724 mark_quic_broken_when_network_suspected_); | |
| 720 } | 725 } |
| 721 | 726 |
| 722 std::unique_ptr<BidirectionalStreamImpl> | 727 std::unique_ptr<BidirectionalStreamImpl> |
| 723 QuicStreamRequest::CreateBidirectionalStreamImpl() { | 728 QuicStreamRequest::CreateBidirectionalStreamImpl() { |
| 724 if (!session_) | 729 if (!session_) |
| 725 return nullptr; | 730 return nullptr; |
| 726 return base::MakeUnique<BidirectionalStreamQuicImpl>(session_); | 731 return base::MakeUnique<BidirectionalStreamQuicImpl>(session_); |
| 727 } | 732 } |
| 728 | 733 |
| 729 QuicStreamFactory::QuicStreamFactory( | 734 QuicStreamFactory::QuicStreamFactory( |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 750 float load_server_info_timeout_srtt_multiplier, | 755 float load_server_info_timeout_srtt_multiplier, |
| 751 bool enable_connection_racing, | 756 bool enable_connection_racing, |
| 752 bool enable_non_blocking_io, | 757 bool enable_non_blocking_io, |
| 753 bool disable_disk_cache, | 758 bool disable_disk_cache, |
| 754 bool prefer_aes, | 759 bool prefer_aes, |
| 755 int socket_receive_buffer_size, | 760 int socket_receive_buffer_size, |
| 756 bool delay_tcp_race, | 761 bool delay_tcp_race, |
| 757 int max_server_configs_stored_in_properties, | 762 int max_server_configs_stored_in_properties, |
| 758 bool close_sessions_on_ip_change, | 763 bool close_sessions_on_ip_change, |
| 759 bool disable_quic_on_timeout_with_open_streams, | 764 bool disable_quic_on_timeout_with_open_streams, |
| 765 bool mark_quic_broken_when_network_suspected, | |
| 760 int idle_connection_timeout_seconds, | 766 int idle_connection_timeout_seconds, |
| 761 int reduced_ping_timeout_seconds, | 767 int reduced_ping_timeout_seconds, |
| 762 int packet_reader_yield_after_duration_milliseconds, | 768 int packet_reader_yield_after_duration_milliseconds, |
| 763 bool migrate_sessions_on_network_change, | 769 bool migrate_sessions_on_network_change, |
| 764 bool migrate_sessions_early, | 770 bool migrate_sessions_early, |
| 765 bool allow_server_migration, | 771 bool allow_server_migration, |
| 766 bool force_hol_blocking, | 772 bool force_hol_blocking, |
| 767 bool race_cert_verification, | 773 bool race_cert_verification, |
| 768 bool do_not_fragment, | 774 bool do_not_fragment, |
| 769 bool estimate_initial_rtt, | 775 bool estimate_initial_rtt, |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 796 always_require_handshake_confirmation), | 802 always_require_handshake_confirmation), |
| 797 disable_connection_pooling_(disable_connection_pooling), | 803 disable_connection_pooling_(disable_connection_pooling), |
| 798 load_server_info_timeout_srtt_multiplier_( | 804 load_server_info_timeout_srtt_multiplier_( |
| 799 load_server_info_timeout_srtt_multiplier), | 805 load_server_info_timeout_srtt_multiplier), |
| 800 enable_connection_racing_(enable_connection_racing), | 806 enable_connection_racing_(enable_connection_racing), |
| 801 enable_non_blocking_io_(enable_non_blocking_io), | 807 enable_non_blocking_io_(enable_non_blocking_io), |
| 802 disable_disk_cache_(disable_disk_cache), | 808 disable_disk_cache_(disable_disk_cache), |
| 803 prefer_aes_(prefer_aes), | 809 prefer_aes_(prefer_aes), |
| 804 disable_quic_on_timeout_with_open_streams_( | 810 disable_quic_on_timeout_with_open_streams_( |
| 805 disable_quic_on_timeout_with_open_streams), | 811 disable_quic_on_timeout_with_open_streams), |
| 812 mark_quic_broken_when_network_suspected_( | |
| 813 mark_quic_broken_when_network_suspected), | |
| 806 consecutive_disabled_count_(0), | 814 consecutive_disabled_count_(0), |
| 807 need_to_evaluate_consecutive_disabled_count_(false), | 815 need_to_evaluate_consecutive_disabled_count_(false), |
| 808 socket_receive_buffer_size_(socket_receive_buffer_size), | 816 socket_receive_buffer_size_(socket_receive_buffer_size), |
| 809 delay_tcp_race_(delay_tcp_race), | 817 delay_tcp_race_(delay_tcp_race), |
| 810 ping_timeout_(QuicTime::Delta::FromSeconds(kPingTimeoutSecs)), | 818 ping_timeout_(QuicTime::Delta::FromSeconds(kPingTimeoutSecs)), |
| 811 reduced_ping_timeout_( | 819 reduced_ping_timeout_( |
| 812 QuicTime::Delta::FromSeconds(reduced_ping_timeout_seconds)), | 820 QuicTime::Delta::FromSeconds(reduced_ping_timeout_seconds)), |
| 813 yield_after_packets_(kQuicYieldAfterPacketsRead), | 821 yield_after_packets_(kQuicYieldAfterPacketsRead), |
| 814 yield_after_duration_(QuicTime::Delta::FromMilliseconds( | 822 yield_after_duration_(QuicTime::Delta::FromMilliseconds( |
| 815 packet_reader_yield_after_duration_milliseconds)), | 823 packet_reader_yield_after_duration_milliseconds)), |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1184 active_jobs_.erase(server_id); | 1192 active_jobs_.erase(server_id); |
| 1185 job_requests_map_.erase(server_id); | 1193 job_requests_map_.erase(server_id); |
| 1186 } | 1194 } |
| 1187 | 1195 |
| 1188 void QuicStreamFactory::OnCertVerifyJobComplete(CertVerifierJob* job, int rv) { | 1196 void QuicStreamFactory::OnCertVerifyJobComplete(CertVerifierJob* job, int rv) { |
| 1189 active_cert_verifier_jobs_.erase(job->server_id()); | 1197 active_cert_verifier_jobs_.erase(job->server_id()); |
| 1190 } | 1198 } |
| 1191 | 1199 |
| 1192 std::unique_ptr<QuicHttpStream> QuicStreamFactory::CreateFromSession( | 1200 std::unique_ptr<QuicHttpStream> QuicStreamFactory::CreateFromSession( |
| 1193 QuicChromiumClientSession* session) { | 1201 QuicChromiumClientSession* session) { |
| 1194 return std::unique_ptr<QuicHttpStream>( | 1202 return base::MakeUnique<QuicHttpStream>( |
| 1195 new QuicHttpStream(session->GetWeakPtr(), http_server_properties_)); | 1203 session->GetWeakPtr(), http_server_properties_, |
| 1204 mark_quic_broken_when_network_suspected_); | |
|
Jana
2017/04/06 02:29:18
Is there an easy way to test this piece? That the
Ryan Hamilton
2017/04/06 03:43:39
This happens in the QuicNetworkTransaction test wh
| |
| 1196 } | 1205 } |
| 1197 | 1206 |
| 1198 bool QuicStreamFactory::IsQuicDisabled() const { | 1207 bool QuicStreamFactory::IsQuicDisabled() const { |
| 1199 return status_ != OPEN; | 1208 return status_ != OPEN; |
| 1200 } | 1209 } |
| 1201 | 1210 |
| 1202 bool QuicStreamFactory::OnHandshakeConfirmed( | 1211 bool QuicStreamFactory::OnHandshakeConfirmed( |
| 1203 QuicChromiumClientSession* session) { | 1212 QuicChromiumClientSession* session) { |
| 1204 if (!IsQuicDisabled()) | 1213 if (!IsQuicDisabled()) |
| 1205 return false; | 1214 return false; |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1944 const QuicServerId& server_id, | 1953 const QuicServerId& server_id, |
| 1945 bool session_was_active) { | 1954 bool session_was_active) { |
| 1946 if (!http_server_properties_) | 1955 if (!http_server_properties_) |
| 1947 return; | 1956 return; |
| 1948 | 1957 |
| 1949 const QuicConnectionStats& stats = session->connection()->GetStats(); | 1958 const QuicConnectionStats& stats = session->connection()->GetStats(); |
| 1950 const AlternativeService alternative_service(kProtoQUIC, | 1959 const AlternativeService alternative_service(kProtoQUIC, |
| 1951 server_id.host_port_pair()); | 1960 server_id.host_port_pair()); |
| 1952 url::SchemeHostPort server("https", server_id.host_port_pair().host(), | 1961 url::SchemeHostPort server("https", server_id.host_port_pair().host(), |
| 1953 server_id.host_port_pair().port()); | 1962 server_id.host_port_pair().port()); |
| 1963 // Do nothing if QUIC is currently marked as broken. | |
| 1964 if (http_server_properties_->IsAlternativeServiceBroken(alternative_service)) | |
| 1965 return; | |
|
Jana
2017/04/06 02:29:18
Did we not need this earlier because we wouldn't e
Ryan Hamilton
2017/04/06 03:43:39
It needs to happen because otherwise we'd un-mark
Jana
2017/04/06 23:55:25
Ah! Of course... Makes sense.
| |
| 1966 | |
| 1954 if (session->IsCryptoHandshakeConfirmed()) { | 1967 if (session->IsCryptoHandshakeConfirmed()) { |
| 1955 http_server_properties_->ConfirmAlternativeService(alternative_service); | 1968 http_server_properties_->ConfirmAlternativeService(alternative_service); |
| 1956 ServerNetworkStats network_stats; | 1969 ServerNetworkStats network_stats; |
| 1957 network_stats.srtt = base::TimeDelta::FromMicroseconds(stats.srtt_us); | 1970 network_stats.srtt = base::TimeDelta::FromMicroseconds(stats.srtt_us); |
| 1958 network_stats.bandwidth_estimate = stats.estimated_bandwidth; | 1971 network_stats.bandwidth_estimate = stats.estimated_bandwidth; |
| 1959 http_server_properties_->SetServerNetworkStats(server, network_stats); | 1972 http_server_properties_->SetServerNetworkStats(server, network_stats); |
| 1960 return; | 1973 return; |
| 1961 } | 1974 } |
| 1962 | 1975 |
| 1963 http_server_properties_->ClearServerNetworkStats(server); | 1976 http_server_properties_->ClearServerNetworkStats(server); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1987 void QuicStreamFactory::OpenFactory() { | 2000 void QuicStreamFactory::OpenFactory() { |
| 1988 status_ = OPEN; | 2001 status_ = OPEN; |
| 1989 } | 2002 } |
| 1990 | 2003 |
| 1991 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { | 2004 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { |
| 1992 if (status_ == OPEN) | 2005 if (status_ == OPEN) |
| 1993 consecutive_disabled_count_ = 0; | 2006 consecutive_disabled_count_ = 0; |
| 1994 } | 2007 } |
| 1995 | 2008 |
| 1996 } // namespace net | 2009 } // namespace net |
| OLD | NEW |