| 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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, | 503 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, |
| 504 QuicRandom* random_generator, | 504 QuicRandom* random_generator, |
| 505 QuicClock* clock, | 505 QuicClock* clock, |
| 506 size_t max_packet_length, | 506 size_t max_packet_length, |
| 507 const std::string& user_agent_id, | 507 const std::string& user_agent_id, |
| 508 const QuicVersionVector& supported_versions, | 508 const QuicVersionVector& supported_versions, |
| 509 bool enable_port_selection, | 509 bool enable_port_selection, |
| 510 bool always_require_handshake_confirmation, | 510 bool always_require_handshake_confirmation, |
| 511 bool disable_connection_pooling, | 511 bool disable_connection_pooling, |
| 512 int load_server_info_timeout, | 512 int load_server_info_timeout, |
| 513 bool load_server_info_if_already_spoke_quic, |
| 513 const QuicTagVector& connection_options) | 514 const QuicTagVector& connection_options) |
| 514 : require_confirmation_(true), | 515 : require_confirmation_(true), |
| 515 host_resolver_(host_resolver), | 516 host_resolver_(host_resolver), |
| 516 client_socket_factory_(client_socket_factory), | 517 client_socket_factory_(client_socket_factory), |
| 517 http_server_properties_(http_server_properties), | 518 http_server_properties_(http_server_properties), |
| 518 transport_security_state_(transport_security_state), | 519 transport_security_state_(transport_security_state), |
| 519 quic_server_info_factory_(nullptr), | 520 quic_server_info_factory_(nullptr), |
| 520 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 521 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
| 521 random_generator_(random_generator), | 522 random_generator_(random_generator), |
| 522 clock_(clock), | 523 clock_(clock), |
| 523 max_packet_length_(max_packet_length), | 524 max_packet_length_(max_packet_length), |
| 524 config_(InitializeQuicConfig(connection_options)), | 525 config_(InitializeQuicConfig(connection_options)), |
| 525 supported_versions_(supported_versions), | 526 supported_versions_(supported_versions), |
| 526 enable_port_selection_(enable_port_selection), | 527 enable_port_selection_(enable_port_selection), |
| 527 always_require_handshake_confirmation_( | 528 always_require_handshake_confirmation_( |
| 528 always_require_handshake_confirmation), | 529 always_require_handshake_confirmation), |
| 529 disable_connection_pooling_(disable_connection_pooling), | 530 disable_connection_pooling_(disable_connection_pooling), |
| 530 load_server_info_timeout_ms_(load_server_info_timeout), | 531 load_server_info_timeout_ms_(load_server_info_timeout), |
| 532 load_server_info_if_already_spoke_quic_( |
| 533 load_server_info_if_already_spoke_quic), |
| 531 port_seed_(random_generator_->RandUint64()), | 534 port_seed_(random_generator_->RandUint64()), |
| 532 check_persisted_supports_quic_(true), | 535 check_persisted_supports_quic_(true), |
| 533 task_runner_(nullptr), | 536 task_runner_(nullptr), |
| 534 weak_factory_(this) { | 537 weak_factory_(this) { |
| 535 DCHECK(transport_security_state_); | 538 DCHECK(transport_security_state_); |
| 536 crypto_config_.set_user_agent_id(user_agent_id); | 539 crypto_config_.set_user_agent_id(user_agent_id); |
| 537 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); | 540 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); |
| 538 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); | 541 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); |
| 539 crypto_config_.SetProofVerifier( | 542 crypto_config_.SetProofVerifier( |
| 540 new ProofVerifierChromium(cert_verifier, transport_security_state)); | 543 new ProofVerifierChromium(cert_verifier, transport_security_state)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 | 584 |
| 582 if (HasActiveJob(server_id)) { | 585 if (HasActiveJob(server_id)) { |
| 583 Job* job = active_jobs_[server_id]; | 586 Job* job = active_jobs_[server_id]; |
| 584 active_requests_[request] = job; | 587 active_requests_[request] = job; |
| 585 job_requests_map_[job].insert(request); | 588 job_requests_map_[job].insert(request); |
| 586 return ERR_IO_PENDING; | 589 return ERR_IO_PENDING; |
| 587 } | 590 } |
| 588 | 591 |
| 589 QuicServerInfo* quic_server_info = nullptr; | 592 QuicServerInfo* quic_server_info = nullptr; |
| 590 if (quic_server_info_factory_) { | 593 if (quic_server_info_factory_) { |
| 591 QuicCryptoClientConfig::CachedState* cached = | 594 bool load_from_disk_cache = true; |
| 592 crypto_config_.LookupOrCreate(server_id); | 595 if (load_server_info_if_already_spoke_quic_) { |
| 593 DCHECK(cached); | 596 const AlternateProtocolMap& alternate_protocol_map = |
| 594 if (cached->IsEmpty()) { | 597 http_server_properties_->alternate_protocol_map(); |
| 595 quic_server_info = quic_server_info_factory_->GetForServer(server_id); | 598 AlternateProtocolMap::const_iterator it = |
| 599 alternate_protocol_map.Peek(server_id.host_port_pair()); |
| 600 if (it == alternate_protocol_map.end() || it->second.protocol != QUIC) |
| 601 load_from_disk_cache = false; |
| 602 } |
| 603 if (load_from_disk_cache) { |
| 604 QuicCryptoClientConfig::CachedState* cached = |
| 605 crypto_config_.LookupOrCreate(server_id); |
| 606 DCHECK(cached); |
| 607 if (cached->IsEmpty()) { |
| 608 quic_server_info = quic_server_info_factory_->GetForServer(server_id); |
| 609 } |
| 596 } | 610 } |
| 597 } | 611 } |
| 598 // TODO(rtenneti): Initialize task_runner_ in the constructor after | 612 // TODO(rtenneti): Initialize task_runner_ in the constructor after |
| 599 // WebRequestActionWithThreadsTest.* tests are fixed. | 613 // WebRequestActionWithThreadsTest.* tests are fixed. |
| 600 if (!task_runner_) | 614 if (!task_runner_) |
| 601 task_runner_ = base::MessageLoop::current()->message_loop_proxy().get(); | 615 task_runner_ = base::MessageLoop::current()->message_loop_proxy().get(); |
| 602 | 616 |
| 603 bool was_alternate_protocol_recently_broken = | 617 bool was_alternate_protocol_recently_broken = |
| 604 http_server_properties_ && | 618 http_server_properties_ && |
| 605 http_server_properties_->WasAlternateProtocolRecentlyBroken( | 619 http_server_properties_->WasAlternateProtocolRecentlyBroken( |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 http_server_properties_->ClearAlternateProtocol(server); | 1114 http_server_properties_->ClearAlternateProtocol(server); |
| 1101 http_server_properties_->SetAlternateProtocol( | 1115 http_server_properties_->SetAlternateProtocol( |
| 1102 server, alternate.port, alternate.protocol, 1); | 1116 server, alternate.port, alternate.protocol, 1); |
| 1103 DCHECK_EQ(QUIC, | 1117 DCHECK_EQ(QUIC, |
| 1104 http_server_properties_->GetAlternateProtocol(server).protocol); | 1118 http_server_properties_->GetAlternateProtocol(server).protocol); |
| 1105 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( | 1119 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( |
| 1106 server)); | 1120 server)); |
| 1107 } | 1121 } |
| 1108 | 1122 |
| 1109 } // namespace net | 1123 } // namespace net |
| OLD | NEW |