| 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, | 558 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, |
| 559 QuicRandom* random_generator, | 559 QuicRandom* random_generator, |
| 560 QuicClock* clock, | 560 QuicClock* clock, |
| 561 size_t max_packet_length, | 561 size_t max_packet_length, |
| 562 const std::string& user_agent_id, | 562 const std::string& user_agent_id, |
| 563 const QuicVersionVector& supported_versions, | 563 const QuicVersionVector& supported_versions, |
| 564 bool enable_port_selection, | 564 bool enable_port_selection, |
| 565 bool always_require_handshake_confirmation, | 565 bool always_require_handshake_confirmation, |
| 566 bool disable_connection_pooling, | 566 bool disable_connection_pooling, |
| 567 int load_server_info_timeout, | 567 int load_server_info_timeout, |
| 568 bool disable_loading_server_info_for_new_servers, | |
| 569 float load_server_info_timeout_srtt_multiplier, | 568 float load_server_info_timeout_srtt_multiplier, |
| 570 bool enable_truncated_connection_ids, | 569 bool enable_truncated_connection_ids, |
| 571 const QuicTagVector& connection_options) | 570 const QuicTagVector& connection_options) |
| 572 : require_confirmation_(true), | 571 : require_confirmation_(true), |
| 573 host_resolver_(host_resolver), | 572 host_resolver_(host_resolver), |
| 574 client_socket_factory_(client_socket_factory), | 573 client_socket_factory_(client_socket_factory), |
| 575 http_server_properties_(http_server_properties), | 574 http_server_properties_(http_server_properties), |
| 576 transport_security_state_(transport_security_state), | 575 transport_security_state_(transport_security_state), |
| 577 quic_server_info_factory_(nullptr), | 576 quic_server_info_factory_(nullptr), |
| 578 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 577 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
| 579 random_generator_(random_generator), | 578 random_generator_(random_generator), |
| 580 clock_(clock), | 579 clock_(clock), |
| 581 max_packet_length_(max_packet_length), | 580 max_packet_length_(max_packet_length), |
| 582 config_(InitializeQuicConfig(connection_options)), | 581 config_(InitializeQuicConfig(connection_options)), |
| 583 supported_versions_(supported_versions), | 582 supported_versions_(supported_versions), |
| 584 enable_port_selection_(enable_port_selection), | 583 enable_port_selection_(enable_port_selection), |
| 585 always_require_handshake_confirmation_( | 584 always_require_handshake_confirmation_( |
| 586 always_require_handshake_confirmation), | 585 always_require_handshake_confirmation), |
| 587 disable_connection_pooling_(disable_connection_pooling), | 586 disable_connection_pooling_(disable_connection_pooling), |
| 588 load_server_info_timeout_ms_(load_server_info_timeout), | 587 load_server_info_timeout_ms_(load_server_info_timeout), |
| 589 disable_loading_server_info_for_new_servers_( | |
| 590 disable_loading_server_info_for_new_servers), | |
| 591 load_server_info_timeout_srtt_multiplier_( | 588 load_server_info_timeout_srtt_multiplier_( |
| 592 load_server_info_timeout_srtt_multiplier), | 589 load_server_info_timeout_srtt_multiplier), |
| 593 enable_truncated_connection_ids_(enable_truncated_connection_ids), | 590 enable_truncated_connection_ids_(enable_truncated_connection_ids), |
| 594 port_seed_(random_generator_->RandUint64()), | 591 port_seed_(random_generator_->RandUint64()), |
| 595 check_persisted_supports_quic_(true), | 592 check_persisted_supports_quic_(true), |
| 596 task_runner_(nullptr), | 593 task_runner_(nullptr), |
| 597 weak_factory_(this) { | 594 weak_factory_(this) { |
| 598 DCHECK(transport_security_state_); | 595 DCHECK(transport_security_state_); |
| 599 crypto_config_.set_user_agent_id(user_agent_id); | 596 crypto_config_.set_user_agent_id(user_agent_id); |
| 600 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); | 597 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 if (HasActiveJob(server_id)) { | 642 if (HasActiveJob(server_id)) { |
| 646 Job* job = active_jobs_[server_id]; | 643 Job* job = active_jobs_[server_id]; |
| 647 active_requests_[request] = job; | 644 active_requests_[request] = job; |
| 648 job_requests_map_[job].insert(request); | 645 job_requests_map_[job].insert(request); |
| 649 return ERR_IO_PENDING; | 646 return ERR_IO_PENDING; |
| 650 } | 647 } |
| 651 | 648 |
| 652 QuicServerInfo* quic_server_info = nullptr; | 649 QuicServerInfo* quic_server_info = nullptr; |
| 653 if (quic_server_info_factory_) { | 650 if (quic_server_info_factory_) { |
| 654 bool load_from_disk_cache = true; | 651 bool load_from_disk_cache = true; |
| 655 if (disable_loading_server_info_for_new_servers_) { | 652 if (http_server_properties_) { |
| 656 const AlternateProtocolMap& alternate_protocol_map = | 653 const AlternateProtocolMap& alternate_protocol_map = |
| 657 http_server_properties_->alternate_protocol_map(); | 654 http_server_properties_->alternate_protocol_map(); |
| 658 AlternateProtocolMap::const_iterator it = | 655 AlternateProtocolMap::const_iterator it = |
| 659 alternate_protocol_map.Peek(server_id.host_port_pair()); | 656 alternate_protocol_map.Peek(server_id.host_port_pair()); |
| 660 if (it == alternate_protocol_map.end() || it->second.protocol != QUIC) { | 657 if (it == alternate_protocol_map.end() || it->second.protocol != QUIC) { |
| 661 // If there is no entry for QUIC, consider that as a new server and | 658 // If there is no entry for QUIC, consider that as a new server and |
| 662 // don't wait for Cache thread to load the data for that server. | 659 // don't wait for Cache thread to load the data for that server. |
| 663 load_from_disk_cache = false; | 660 load_from_disk_cache = false; |
| 664 } | 661 } |
| 665 } | 662 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 return rv; | 696 return rv; |
| 700 } | 697 } |
| 701 | 698 |
| 702 bool QuicStreamFactory::OnResolution( | 699 bool QuicStreamFactory::OnResolution( |
| 703 const QuicServerId& server_id, | 700 const QuicServerId& server_id, |
| 704 const AddressList& address_list) { | 701 const AddressList& address_list) { |
| 705 DCHECK(!HasActiveSession(server_id)); | 702 DCHECK(!HasActiveSession(server_id)); |
| 706 if (disable_connection_pooling_) { | 703 if (disable_connection_pooling_) { |
| 707 return false; | 704 return false; |
| 708 } | 705 } |
| 709 for (size_t i = 0; i < address_list.size(); ++i) { | 706 for (const IPEndPoint& address : address_list) { |
| 710 const IPEndPoint& address = address_list[i]; | |
| 711 const IpAliasKey ip_alias_key(address, server_id.is_https()); | 707 const IpAliasKey ip_alias_key(address, server_id.is_https()); |
| 712 if (!ContainsKey(ip_aliases_, ip_alias_key)) | 708 if (!ContainsKey(ip_aliases_, ip_alias_key)) |
| 713 continue; | 709 continue; |
| 714 | 710 |
| 715 const SessionSet& sessions = ip_aliases_[ip_alias_key]; | 711 const SessionSet& sessions = ip_aliases_[ip_alias_key]; |
| 716 for (SessionSet::const_iterator i = sessions.begin(); | 712 for (QuicClientSession* session : sessions) { |
| 717 i != sessions.end(); ++i) { | 713 if (!session->CanPool(server_id.host(), server_id.privacy_mode())) |
| 718 QuicClientSession* session = *i; | |
| 719 if (!session->CanPool(server_id.host())) | |
| 720 continue; | 714 continue; |
| 721 active_sessions_[server_id] = session; | 715 active_sessions_[server_id] = session; |
| 722 session_aliases_[session].insert(server_id); | 716 session_aliases_[session].insert(server_id); |
| 723 return true; | 717 return true; |
| 724 } | 718 } |
| 725 } | 719 } |
| 726 return false; | 720 return false; |
| 727 } | 721 } |
| 728 | 722 |
| 729 void QuicStreamFactory::OnJobComplete(Job* job, int rv) { | 723 void QuicStreamFactory::OnJobComplete(Job* job, int rv) { |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1098 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1105 "422516 QuicStreamFactory::CreateSession6")); | 1099 "422516 QuicStreamFactory::CreateSession6")); |
| 1106 | 1100 |
| 1107 // Start the disk cache loading so that we can persist the newer QUIC server | 1101 // Start the disk cache loading so that we can persist the newer QUIC server |
| 1108 // information and/or inform the disk cache that we have reused | 1102 // information and/or inform the disk cache that we have reused |
| 1109 // |server_info|. | 1103 // |server_info|. |
| 1110 server_info.reset(quic_server_info_factory_->GetForServer(server_id)); | 1104 server_info.reset(quic_server_info_factory_->GetForServer(server_id)); |
| 1111 server_info->Start(); | 1105 server_info->Start(); |
| 1112 } | 1106 } |
| 1113 | 1107 |
| 1108 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 1109 tracked_objects::ScopedTracker tracking_profile6( |
| 1110 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1111 "422516 QuicStreamFactory::CreateSession61")); |
| 1112 |
| 1114 *session = new QuicClientSession( | 1113 *session = new QuicClientSession( |
| 1115 connection, socket.Pass(), this, transport_security_state_, | 1114 connection, socket.Pass(), this, transport_security_state_, |
| 1116 server_info.Pass(), config, | 1115 server_info.Pass(), config, |
| 1117 base::MessageLoop::current()->message_loop_proxy().get(), | 1116 base::MessageLoop::current()->message_loop_proxy().get(), |
| 1118 net_log.net_log()); | 1117 net_log.net_log()); |
| 1119 all_sessions_[*session] = server_id; // owning pointer | 1118 all_sessions_[*session] = server_id; // owning pointer |
| 1120 | 1119 |
| 1121 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 1120 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 1122 tracked_objects::ScopedTracker tracking_profile7( | 1121 tracked_objects::ScopedTracker tracking_profile7( |
| 1123 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1122 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 http_server_properties_->ClearAlternateProtocol(server); | 1272 http_server_properties_->ClearAlternateProtocol(server); |
| 1274 http_server_properties_->SetAlternateProtocol( | 1273 http_server_properties_->SetAlternateProtocol( |
| 1275 server, alternate.port, alternate.protocol, 1); | 1274 server, alternate.port, alternate.protocol, 1); |
| 1276 DCHECK_EQ(QUIC, | 1275 DCHECK_EQ(QUIC, |
| 1277 http_server_properties_->GetAlternateProtocol(server).protocol); | 1276 http_server_properties_->GetAlternateProtocol(server).protocol); |
| 1278 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( | 1277 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( |
| 1279 server)); | 1278 server)); |
| 1280 } | 1279 } |
| 1281 | 1280 |
| 1282 } // namespace net | 1281 } // namespace net |
| OLD | NEW |