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 <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 Loading... | |
| 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 max_number_of_lossy_connections, | |
| 543 float 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 max_number_of_lossy_connections_(max_number_of_lossy_connections), | |
| 568 number_of_lossy_connections_(0), | |
| 569 quic_is_disabled_(false), | |
| 570 packet_loss_threshold_(packet_loss_threshold), | |
| 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 27 matching lines...) Expand all Loading... | |
| 602 local_address_.address()); | 608 local_address_.address()); |
| 603 } | 609 } |
| 604 } | 610 } |
| 605 | 611 |
| 606 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, | 612 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, |
| 607 bool is_https, | 613 bool is_https, |
| 608 PrivacyMode privacy_mode, | 614 PrivacyMode privacy_mode, |
| 609 base::StringPiece method, | 615 base::StringPiece method, |
| 610 const BoundNetLog& net_log, | 616 const BoundNetLog& net_log, |
| 611 QuicStreamRequest* request) { | 617 QuicStreamRequest* request) { |
| 618 // TODO(rtenneti): return a better error? | |
| 619 if (quic_is_disabled_) | |
| 620 return ERR_QUIC_PROTOCOL_ERROR; | |
|
Ryan Hamilton
2015/03/23 02:31:06
If you do QUIC_HANDSHAKE_FAILED then HttpNetworkTr
ramant (doing other things)
2015/03/24 03:07:22
As we had talked offline, hooked it to HttpStreamF
| |
| 612 QuicServerId server_id(host_port_pair, is_https, privacy_mode); | 621 QuicServerId server_id(host_port_pair, is_https, privacy_mode); |
| 613 if (HasActiveSession(server_id)) { | 622 if (HasActiveSession(server_id)) { |
| 614 request->set_stream(CreateIfSessionExists(server_id, net_log)); | 623 request->set_stream(CreateIfSessionExists(server_id, net_log)); |
| 615 return OK; | 624 return OK; |
| 616 } | 625 } |
| 617 | 626 |
| 618 if (HasActiveJob(server_id)) { | 627 if (HasActiveJob(server_id)) { |
| 619 active_requests_[request] = server_id; | 628 active_requests_[request] = server_id; |
| 620 job_requests_map_[server_id].insert(request); | 629 job_requests_map_[server_id].insert(request); |
| 621 return ERR_IO_PENDING; | 630 return ERR_IO_PENDING; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 DVLOG(1) << "No active session"; | 764 DVLOG(1) << "No active session"; |
| 756 return scoped_ptr<QuicHttpStream>(); | 765 return scoped_ptr<QuicHttpStream>(); |
| 757 } | 766 } |
| 758 | 767 |
| 759 QuicClientSession* session = active_sessions_[server_id]; | 768 QuicClientSession* session = active_sessions_[server_id]; |
| 760 DCHECK(session); | 769 DCHECK(session); |
| 761 return scoped_ptr<QuicHttpStream>( | 770 return scoped_ptr<QuicHttpStream>( |
| 762 new QuicHttpStream(session->GetWeakPtr())); | 771 new QuicHttpStream(session->GetWeakPtr())); |
| 763 } | 772 } |
| 764 | 773 |
| 774 void QuicStreamFactory::OnBadPacketLoss(const QuicServerId& server_id) { | |
| 775 ++number_of_lossy_connections_; | |
| 776 | |
| 777 if (http_server_properties_) { | |
| 778 const HostPortPair& server = server_id.host_port_pair(); | |
| 779 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | |
| 780 AlternativeService(QUIC, server.host(), server.port())); | |
| 781 } | |
| 782 | |
| 783 if (number_of_lossy_connections_ < max_number_of_lossy_connections_ || | |
| 784 quic_is_disabled_) { | |
| 785 return; | |
| 786 } | |
| 787 | |
| 788 quic_is_disabled_ = true; | |
| 789 UMA_HISTOGRAM_BOOLEAN("Net.QuicStreamFactory.QuicIsDisabled", | |
| 790 quic_is_disabled_); | |
| 791 } | |
| 792 | |
| 765 void QuicStreamFactory::OnIdleSession(QuicClientSession* session) { | 793 void QuicStreamFactory::OnIdleSession(QuicClientSession* session) { |
| 766 } | 794 } |
| 767 | 795 |
| 768 void QuicStreamFactory::OnSessionGoingAway(QuicClientSession* session) { | 796 void QuicStreamFactory::OnSessionGoingAway(QuicClientSession* session) { |
| 769 const AliasSet& aliases = session_aliases_[session]; | 797 const AliasSet& aliases = session_aliases_[session]; |
| 770 for (AliasSet::const_iterator it = aliases.begin(); it != aliases.end(); | 798 for (AliasSet::const_iterator it = aliases.begin(); it != aliases.end(); |
| 771 ++it) { | 799 ++it) { |
| 772 DCHECK(active_sessions_.count(*it)); | 800 DCHECK(active_sessions_.count(*it)); |
| 773 DCHECK_EQ(session, active_sessions_[*it]); | 801 DCHECK_EQ(session, active_sessions_[*it]); |
| 774 // Track sessions which have recently gone away so that we can disable | 802 // Track sessions which have recently gone away so that we can disable |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1160 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1188 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
| 1161 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1189 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
| 1162 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1190 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1163 // still race. | 1191 // still race. |
| 1164 const HostPortPair& server = server_id.host_port_pair(); | 1192 const HostPortPair& server = server_id.host_port_pair(); |
| 1165 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1193 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1166 AlternativeService(QUIC, server.host(), server.port())); | 1194 AlternativeService(QUIC, server.host(), server.port())); |
| 1167 } | 1195 } |
| 1168 | 1196 |
| 1169 } // namespace net | 1197 } // namespace net |
| OLD | NEW |