Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: net/quic/quic_stream_factory.cc

Issue 1025573002: QUIC - disable QUIC if packet loss rate is bad for a connection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor comment fixes Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <set> 7 #include <set>
8 8
9 #include "base/cpu.h" 9 #include "base/cpu.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 size_t max_packet_length, 532 size_t max_packet_length,
533 const std::string& user_agent_id, 533 const std::string& user_agent_id,
534 const QuicVersionVector& supported_versions, 534 const QuicVersionVector& supported_versions,
535 bool enable_port_selection, 535 bool enable_port_selection,
536 bool always_require_handshake_confirmation, 536 bool always_require_handshake_confirmation,
537 bool disable_connection_pooling, 537 bool disable_connection_pooling,
538 float load_server_info_timeout_srtt_multiplier, 538 float load_server_info_timeout_srtt_multiplier,
539 bool enable_connection_racing, 539 bool enable_connection_racing,
540 bool enable_non_blocking_io, 540 bool enable_non_blocking_io,
541 bool disable_disk_cache, 541 bool disable_disk_cache,
542 int number_of_lossy_handshakes,
543 int packet_loss_threshold,
542 int socket_receive_buffer_size, 544 int socket_receive_buffer_size,
543 const QuicTagVector& connection_options) 545 const QuicTagVector& connection_options)
544 : require_confirmation_(true), 546 : require_confirmation_(true),
545 host_resolver_(host_resolver), 547 host_resolver_(host_resolver),
546 client_socket_factory_(client_socket_factory), 548 client_socket_factory_(client_socket_factory),
547 http_server_properties_(http_server_properties), 549 http_server_properties_(http_server_properties),
548 transport_security_state_(transport_security_state), 550 transport_security_state_(transport_security_state),
549 quic_server_info_factory_(nullptr), 551 quic_server_info_factory_(nullptr),
550 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), 552 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory),
551 random_generator_(random_generator), 553 random_generator_(random_generator),
552 clock_(clock), 554 clock_(clock),
553 max_packet_length_(max_packet_length), 555 max_packet_length_(max_packet_length),
554 config_(InitializeQuicConfig(connection_options)), 556 config_(InitializeQuicConfig(connection_options)),
555 supported_versions_(supported_versions), 557 supported_versions_(supported_versions),
556 enable_port_selection_(enable_port_selection), 558 enable_port_selection_(enable_port_selection),
557 always_require_handshake_confirmation_( 559 always_require_handshake_confirmation_(
558 always_require_handshake_confirmation), 560 always_require_handshake_confirmation),
559 disable_connection_pooling_(disable_connection_pooling), 561 disable_connection_pooling_(disable_connection_pooling),
560 load_server_info_timeout_srtt_multiplier_( 562 load_server_info_timeout_srtt_multiplier_(
561 load_server_info_timeout_srtt_multiplier), 563 load_server_info_timeout_srtt_multiplier),
562 enable_connection_racing_(enable_connection_racing), 564 enable_connection_racing_(enable_connection_racing),
563 enable_non_blocking_io_(enable_non_blocking_io), 565 enable_non_blocking_io_(enable_non_blocking_io),
564 disable_disk_cache_(disable_disk_cache), 566 disable_disk_cache_(disable_disk_cache),
567 number_of_lossy_handshakes_(number_of_lossy_handshakes),
568 packet_loss_threshold_(packet_loss_threshold),
569 disable_zero_rtt_(number_of_lossy_handshakes_ > 0 &&
570 packet_loss_threshold_ > 0),
565 socket_receive_buffer_size_(socket_receive_buffer_size), 571 socket_receive_buffer_size_(socket_receive_buffer_size),
566 port_seed_(random_generator_->RandUint64()), 572 port_seed_(random_generator_->RandUint64()),
567 check_persisted_supports_quic_(true), 573 check_persisted_supports_quic_(true),
568 task_runner_(nullptr), 574 task_runner_(nullptr),
569 weak_factory_(this) { 575 weak_factory_(this) {
570 DCHECK(transport_security_state_); 576 DCHECK(transport_security_state_);
571 crypto_config_.set_user_agent_id(user_agent_id); 577 crypto_config_.set_user_agent_id(user_agent_id);
572 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); 578 crypto_config_.AddCanonicalSuffix(".c.youtube.com");
573 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); 579 crypto_config_.AddCanonicalSuffix(".googlevideo.com");
574 crypto_config_.SetProofVerifier( 580 crypto_config_.SetProofVerifier(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 return ERR_IO_PENDING; 627 return ERR_IO_PENDING;
622 } 628 }
623 629
624 // TODO(rtenneti): |task_runner_| is used by the Job. Initialize task_runner_ 630 // TODO(rtenneti): |task_runner_| is used by the Job. Initialize task_runner_
625 // in the constructor after WebRequestActionWithThreadsTest.* tests are fixed. 631 // in the constructor after WebRequestActionWithThreadsTest.* tests are fixed.
626 if (!task_runner_) 632 if (!task_runner_)
627 task_runner_ = base::MessageLoop::current()->message_loop_proxy().get(); 633 task_runner_ = base::MessageLoop::current()->message_loop_proxy().get();
628 634
629 QuicServerInfo* quic_server_info = nullptr; 635 QuicServerInfo* quic_server_info = nullptr;
630 if (quic_server_info_factory_) { 636 if (quic_server_info_factory_) {
631 bool load_from_disk_cache = !disable_disk_cache_; 637 bool load_from_disk_cache = !disable_disk_cache_ || !disable_zero_rtt_;
632 if (http_server_properties_) { 638 if (http_server_properties_) {
633 const AlternateProtocolMap& alternate_protocol_map = 639 const AlternateProtocolMap& alternate_protocol_map =
634 http_server_properties_->alternate_protocol_map(); 640 http_server_properties_->alternate_protocol_map();
635 AlternateProtocolMap::const_iterator it = 641 AlternateProtocolMap::const_iterator it =
636 alternate_protocol_map.Peek(server_id.host_port_pair()); 642 alternate_protocol_map.Peek(server_id.host_port_pair());
637 if (it == alternate_protocol_map.end() || it->second.protocol != QUIC) { 643 if (it == alternate_protocol_map.end() || it->second.protocol != QUIC) {
638 // If there is no entry for QUIC, consider that as a new server and 644 // If there is no entry for QUIC, consider that as a new server and
639 // don't wait for Cache thread to load the data for that server. 645 // don't wait for Cache thread to load the data for that server.
640 load_from_disk_cache = false; 646 load_from_disk_cache = false;
641 } 647 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 DVLOG(1) << "No active session"; 762 DVLOG(1) << "No active session";
757 return scoped_ptr<QuicHttpStream>(); 763 return scoped_ptr<QuicHttpStream>();
758 } 764 }
759 765
760 QuicClientSession* session = active_sessions_[server_id]; 766 QuicClientSession* session = active_sessions_[server_id];
761 DCHECK(session); 767 DCHECK(session);
762 return scoped_ptr<QuicHttpStream>( 768 return scoped_ptr<QuicHttpStream>(
763 new QuicHttpStream(session->GetWeakPtr())); 769 new QuicHttpStream(session->GetWeakPtr()));
764 } 770 }
765 771
772 QuicErrorCode QuicStreamFactory::OnCryptoHandshakeCompleted(
773 QuicClientSession* session,
774 const QuicServerId& server_id,
775 int number_of_handshakes) {
776 DCHECK_LT(0, number_of_handshakes);
777 if (number_of_handshakes != number_of_lossy_handshakes_)
778 return QUIC_NO_ERROR;
779
780 bool bad_packet_loss_rate =
781 (session->PacketLossRate() / 10) > packet_loss_threshold_;
782
783 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.HasBadPacketLossRate",
784 bad_packet_loss_rate);
785
786 // It is not bad packet loss rate, enable 0-RTT.
787 if (!bad_packet_loss_rate) {
788 disable_zero_rtt_ = false;
789 return QUIC_NO_ERROR;
790 }
791
792 HistogramBrokenAlternateProtocolLocation(
793 BROKEN_ALTERNATE_PROTOCOL_LOCATION_QUIC_STREAM_FACTORY);
794
795 const HostPortPair& server = server_id.host_port_pair();
796 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
797 AlternativeService(QUIC, server.host(), server.port()));
798 // TODO(rtenneti): Should we close the connection?
799 return QUIC_BAD_PACKET_LOSS_RATE;
800 }
801
766 void QuicStreamFactory::OnIdleSession(QuicClientSession* session) { 802 void QuicStreamFactory::OnIdleSession(QuicClientSession* session) {
767 } 803 }
768 804
769 void QuicStreamFactory::OnSessionGoingAway(QuicClientSession* session) { 805 void QuicStreamFactory::OnSessionGoingAway(QuicClientSession* session) {
770 const AliasSet& aliases = session_aliases_[session]; 806 const AliasSet& aliases = session_aliases_[session];
771 for (AliasSet::const_iterator it = aliases.begin(); it != aliases.end(); 807 for (AliasSet::const_iterator it = aliases.begin(); it != aliases.end();
772 ++it) { 808 ++it) {
773 DCHECK(active_sessions_.count(*it)); 809 DCHECK(active_sessions_.count(*it));
774 DCHECK_EQ(session, active_sessions_[*it]); 810 DCHECK_EQ(session, active_sessions_[*it]);
775 // Track sessions which have recently gone away so that we can disable 811 // Track sessions which have recently gone away so that we can disable
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 1194 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP
1159 // job also fails. So to avoid not using QUIC when we otherwise could, we mark 1195 // job also fails. So to avoid not using QUIC when we otherwise could, we mark
1160 // it as recently broken, which means that 0-RTT will be disabled but we'll 1196 // it as recently broken, which means that 0-RTT will be disabled but we'll
1161 // still race. 1197 // still race.
1162 const HostPortPair& server = server_id.host_port_pair(); 1198 const HostPortPair& server = server_id.host_port_pair();
1163 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 1199 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
1164 AlternativeService(QUIC, server.host(), server.port())); 1200 AlternativeService(QUIC, server.host(), server.port()));
1165 } 1201 }
1166 1202
1167 } // namespace net 1203 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698