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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, | 538 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, |
539 QuicRandom* random_generator, | 539 QuicRandom* random_generator, |
540 QuicClock* clock, | 540 QuicClock* clock, |
541 size_t max_packet_length, | 541 size_t max_packet_length, |
542 const std::string& user_agent_id, | 542 const std::string& user_agent_id, |
543 const QuicVersionVector& supported_versions, | 543 const QuicVersionVector& supported_versions, |
544 bool enable_port_selection, | 544 bool enable_port_selection, |
545 bool always_require_handshake_confirmation, | 545 bool always_require_handshake_confirmation, |
546 bool disable_connection_pooling, | 546 bool disable_connection_pooling, |
547 int load_server_info_timeout, | 547 int load_server_info_timeout, |
| 548 bool disable_loading_server_info_for_new_servers, |
548 const QuicTagVector& connection_options) | 549 const QuicTagVector& connection_options) |
549 : require_confirmation_(true), | 550 : require_confirmation_(true), |
550 host_resolver_(host_resolver), | 551 host_resolver_(host_resolver), |
551 client_socket_factory_(client_socket_factory), | 552 client_socket_factory_(client_socket_factory), |
552 http_server_properties_(http_server_properties), | 553 http_server_properties_(http_server_properties), |
553 transport_security_state_(transport_security_state), | 554 transport_security_state_(transport_security_state), |
554 quic_server_info_factory_(nullptr), | 555 quic_server_info_factory_(nullptr), |
555 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 556 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
556 random_generator_(random_generator), | 557 random_generator_(random_generator), |
557 clock_(clock), | 558 clock_(clock), |
558 max_packet_length_(max_packet_length), | 559 max_packet_length_(max_packet_length), |
559 config_(InitializeQuicConfig(connection_options)), | 560 config_(InitializeQuicConfig(connection_options)), |
560 supported_versions_(supported_versions), | 561 supported_versions_(supported_versions), |
561 enable_port_selection_(enable_port_selection), | 562 enable_port_selection_(enable_port_selection), |
562 always_require_handshake_confirmation_( | 563 always_require_handshake_confirmation_( |
563 always_require_handshake_confirmation), | 564 always_require_handshake_confirmation), |
564 disable_connection_pooling_(disable_connection_pooling), | 565 disable_connection_pooling_(disable_connection_pooling), |
565 load_server_info_timeout_ms_(load_server_info_timeout), | 566 load_server_info_timeout_ms_(load_server_info_timeout), |
| 567 disable_loading_server_info_for_new_servers_( |
| 568 disable_loading_server_info_for_new_servers), |
566 port_seed_(random_generator_->RandUint64()), | 569 port_seed_(random_generator_->RandUint64()), |
567 check_persisted_supports_quic_(true), | 570 check_persisted_supports_quic_(true), |
568 task_runner_(nullptr), | 571 task_runner_(nullptr), |
569 weak_factory_(this) { | 572 weak_factory_(this) { |
570 DCHECK(transport_security_state_); | 573 DCHECK(transport_security_state_); |
571 crypto_config_.set_user_agent_id(user_agent_id); | 574 crypto_config_.set_user_agent_id(user_agent_id); |
572 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); | 575 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); |
573 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); | 576 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); |
574 crypto_config_.SetProofVerifier( | 577 crypto_config_.SetProofVerifier( |
575 new ProofVerifierChromium(cert_verifier, transport_security_state)); | 578 new ProofVerifierChromium(cert_verifier, transport_security_state)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 | 619 |
617 if (HasActiveJob(server_id)) { | 620 if (HasActiveJob(server_id)) { |
618 Job* job = active_jobs_[server_id]; | 621 Job* job = active_jobs_[server_id]; |
619 active_requests_[request] = job; | 622 active_requests_[request] = job; |
620 job_requests_map_[job].insert(request); | 623 job_requests_map_[job].insert(request); |
621 return ERR_IO_PENDING; | 624 return ERR_IO_PENDING; |
622 } | 625 } |
623 | 626 |
624 QuicServerInfo* quic_server_info = nullptr; | 627 QuicServerInfo* quic_server_info = nullptr; |
625 if (quic_server_info_factory_) { | 628 if (quic_server_info_factory_) { |
626 QuicCryptoClientConfig::CachedState* cached = | 629 bool load_from_disk_cache = true; |
627 crypto_config_.LookupOrCreate(server_id); | 630 if (disable_loading_server_info_for_new_servers_) { |
628 DCHECK(cached); | 631 const AlternateProtocolMap& alternate_protocol_map = |
629 if (cached->IsEmpty()) { | 632 http_server_properties_->alternate_protocol_map(); |
630 quic_server_info = quic_server_info_factory_->GetForServer(server_id); | 633 AlternateProtocolMap::const_iterator it = |
| 634 alternate_protocol_map.Peek(server_id.host_port_pair()); |
| 635 if (it == alternate_protocol_map.end() || it->second.protocol != QUIC) { |
| 636 // If there is no entry for QUIC, consider that as a new server and |
| 637 // don't wait for Cache thread to load the data for that server. |
| 638 load_from_disk_cache = false; |
| 639 } |
| 640 } |
| 641 if (load_from_disk_cache) { |
| 642 QuicCryptoClientConfig::CachedState* cached = |
| 643 crypto_config_.LookupOrCreate(server_id); |
| 644 DCHECK(cached); |
| 645 if (cached->IsEmpty()) { |
| 646 quic_server_info = quic_server_info_factory_->GetForServer(server_id); |
| 647 } |
631 } | 648 } |
632 } | 649 } |
633 // TODO(rtenneti): Initialize task_runner_ in the constructor after | 650 // TODO(rtenneti): Initialize task_runner_ in the constructor after |
634 // WebRequestActionWithThreadsTest.* tests are fixed. | 651 // WebRequestActionWithThreadsTest.* tests are fixed. |
635 if (!task_runner_) | 652 if (!task_runner_) |
636 task_runner_ = base::MessageLoop::current()->message_loop_proxy().get(); | 653 task_runner_ = base::MessageLoop::current()->message_loop_proxy().get(); |
637 | 654 |
638 bool was_alternate_protocol_recently_broken = | 655 bool was_alternate_protocol_recently_broken = |
639 http_server_properties_ && | 656 http_server_properties_ && |
640 http_server_properties_->WasAlternateProtocolRecentlyBroken( | 657 http_server_properties_->WasAlternateProtocolRecentlyBroken( |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 http_server_properties_->ClearAlternateProtocol(server); | 1152 http_server_properties_->ClearAlternateProtocol(server); |
1136 http_server_properties_->SetAlternateProtocol( | 1153 http_server_properties_->SetAlternateProtocol( |
1137 server, alternate.port, alternate.protocol, 1); | 1154 server, alternate.port, alternate.protocol, 1); |
1138 DCHECK_EQ(QUIC, | 1155 DCHECK_EQ(QUIC, |
1139 http_server_properties_->GetAlternateProtocol(server).protocol); | 1156 http_server_properties_->GetAlternateProtocol(server).protocol); |
1140 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( | 1157 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( |
1141 server)); | 1158 server)); |
1142 } | 1159 } |
1143 | 1160 |
1144 } // namespace net | 1161 } // namespace net |
OLD | NEW |