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

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

Issue 192583004: QUIC - use QuicSessionKey tuple (host, port, is_https) instead of server_hostname (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use QuicSessionKey as arg and delete server_hostname as arg Created 6 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 | Annotate | Revision Log
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/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 13 matching lines...) Expand all
24 #include "net/quic/crypto/quic_server_info.h" 24 #include "net/quic/crypto/quic_server_info.h"
25 #include "net/quic/port_suggester.h" 25 #include "net/quic/port_suggester.h"
26 #include "net/quic/quic_client_session.h" 26 #include "net/quic/quic_client_session.h"
27 #include "net/quic/quic_clock.h" 27 #include "net/quic/quic_clock.h"
28 #include "net/quic/quic_connection.h" 28 #include "net/quic/quic_connection.h"
29 #include "net/quic/quic_connection_helper.h" 29 #include "net/quic/quic_connection_helper.h"
30 #include "net/quic/quic_crypto_client_stream_factory.h" 30 #include "net/quic/quic_crypto_client_stream_factory.h"
31 #include "net/quic/quic_default_packet_writer.h" 31 #include "net/quic/quic_default_packet_writer.h"
32 #include "net/quic/quic_http_stream.h" 32 #include "net/quic/quic_http_stream.h"
33 #include "net/quic/quic_protocol.h" 33 #include "net/quic/quic_protocol.h"
34 #include "net/quic/quic_session_key.h"
34 #include "net/socket/client_socket_factory.h" 35 #include "net/socket/client_socket_factory.h"
35 36
36 using std::string; 37 using std::string;
37 using std::vector; 38 using std::vector;
38 39
39 namespace net { 40 namespace net {
40 41
41 QuicStreamFactory::IpAliasKey::IpAliasKey() {} 42 QuicStreamFactory::IpAliasKey::IpAliasKey() {}
42 43
43 QuicStreamFactory::IpAliasKey::IpAliasKey(IPEndPoint ip_endpoint, 44 QuicStreamFactory::IpAliasKey::IpAliasKey(IPEndPoint ip_endpoint,
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 const HttpServerProperties::NetworkStats* stats = 647 const HttpServerProperties::NetworkStats* stats =
647 http_server_properties_->GetServerNetworkStats(host_port_pair); 648 http_server_properties_->GetServerNetworkStats(host_port_pair);
648 if (stats != NULL) { 649 if (stats != NULL) {
649 config.set_initial_round_trip_time_us(stats->rtt.InMicroseconds(), 650 config.set_initial_round_trip_time_us(stats->rtt.InMicroseconds(),
650 stats->rtt.InMicroseconds()); 651 stats->rtt.InMicroseconds());
651 } 652 }
652 } 653 }
653 654
654 *session = new QuicClientSession( 655 *session = new QuicClientSession(
655 connection, socket.Pass(), writer.Pass(), this, 656 connection, socket.Pass(), writer.Pass(), this,
656 quic_crypto_client_stream_factory_, host_port_pair.host(), 657 quic_crypto_client_stream_factory_, session_key, config, crypto_config,
657 config, crypto_config, net_log.net_log()); 658 net_log.net_log());
658 all_sessions_.insert(*session); // owning pointer 659 all_sessions_.insert(*session); // owning pointer
659 if (is_https) { 660 if (is_https) {
660 crypto_config->SetProofVerifier( 661 crypto_config->SetProofVerifier(
661 new ProofVerifierChromium(cert_verifier, net_log)); 662 new ProofVerifierChromium(cert_verifier, net_log));
662 } 663 }
663 return OK; 664 return OK;
664 } 665 }
665 666
666 bool QuicStreamFactory::HasActiveJob(const QuicSessionKey& key) const { 667 bool QuicStreamFactory::HasActiveJob(const QuicSessionKey& key) const {
667 return ContainsKey(active_jobs_, key); 668 return ContainsKey(active_jobs_, key);
(...skipping 17 matching lines...) Expand all
685 686
686 if (ContainsKey(all_crypto_configs_, session_key)) { 687 if (ContainsKey(all_crypto_configs_, session_key)) {
687 crypto_config = all_crypto_configs_[session_key]; 688 crypto_config = all_crypto_configs_[session_key];
688 DCHECK(crypto_config); 689 DCHECK(crypto_config);
689 } else { 690 } else {
690 // TODO(rtenneti): if two quic_sessions for the same host_port_pair 691 // TODO(rtenneti): if two quic_sessions for the same host_port_pair
691 // share the same crypto_config, will it cause issues? 692 // share the same crypto_config, will it cause issues?
692 crypto_config = new QuicCryptoClientConfig(); 693 crypto_config = new QuicCryptoClientConfig();
693 if (quic_server_info_factory_) { 694 if (quic_server_info_factory_) {
694 QuicCryptoClientConfig::CachedState* cached = 695 QuicCryptoClientConfig::CachedState* cached =
695 crypto_config->Create(session_key.host_port_pair().host(), 696 crypto_config->Create(session_key, quic_server_info_factory_);
696 quic_server_info_factory_);
697 DCHECK(cached); 697 DCHECK(cached);
698 } 698 }
699 crypto_config->SetDefaults(); 699 crypto_config->SetDefaults();
700 all_crypto_configs_[session_key] = crypto_config; 700 all_crypto_configs_[session_key] = crypto_config;
701 PopulateFromCanonicalConfig(session_key, crypto_config); 701 PopulateFromCanonicalConfig(session_key, crypto_config);
702 } 702 }
703 return crypto_config; 703 return crypto_config;
704 } 704 }
705 705
706 void QuicStreamFactory::PopulateFromCanonicalConfig( 706 void QuicStreamFactory::PopulateFromCanonicalConfig(
707 const QuicSessionKey& session_key, 707 const QuicSessionKey& session_key,
708 QuicCryptoClientConfig* crypto_config) { 708 QuicCryptoClientConfig* crypto_config) {
709 const string server_hostname = session_key.host_port_pair().host(); 709 const string server_hostname = session_key.host_port_pair().host();
710 const uint16 server_port = session_key.host_port_pair().port();
711 unsigned i = 0; 710 unsigned i = 0;
712 for (; i < canoncial_suffixes_.size(); ++i) { 711 for (; i < canoncial_suffixes_.size(); ++i) {
713 if (EndsWith(server_hostname, canoncial_suffixes_[i], false)) { 712 if (EndsWith(server_hostname, canoncial_suffixes_[i], false)) {
714 break; 713 break;
715 } 714 }
716 } 715 }
717 if (i == canoncial_suffixes_.size()) 716 if (i == canoncial_suffixes_.size())
718 return; 717 return;
719 718
720 HostPortPair suffix_host_port_pair(canoncial_suffixes_[i], server_port); 719 HostPortPair suffix_host_port_pair(canoncial_suffixes_[i],
720 session_key.host_port_pair().port());
721 QuicSessionKey suffix_session_key(suffix_host_port_pair, 721 QuicSessionKey suffix_session_key(suffix_host_port_pair,
722 session_key.is_https()); 722 session_key.is_https());
723 if (!ContainsKey(canonical_hostname_to_origin_map_, suffix_session_key)) { 723 if (!ContainsKey(canonical_hostname_to_origin_map_, suffix_session_key)) {
724 // This is the first host we've seen which matches the suffix, so make it 724 // This is the first host we've seen which matches the suffix, so make it
725 // canonical. 725 // canonical.
726 canonical_hostname_to_origin_map_[suffix_session_key] = session_key; 726 canonical_hostname_to_origin_map_[suffix_session_key] = session_key;
727 return; 727 return;
728 } 728 }
729 729
730 const QuicSessionKey& canonical_session_key = 730 const QuicSessionKey& canonical_session_key =
731 canonical_hostname_to_origin_map_[suffix_session_key]; 731 canonical_hostname_to_origin_map_[suffix_session_key];
732 QuicCryptoClientConfig* canonical_crypto_config = 732 QuicCryptoClientConfig* canonical_crypto_config =
733 all_crypto_configs_[canonical_session_key]; 733 all_crypto_configs_[canonical_session_key];
734 DCHECK(canonical_crypto_config); 734 DCHECK(canonical_crypto_config);
735 const HostPortPair& canonical_host_port_pair =
736 canonical_session_key.host_port_pair();
737 735
738 // Copy the CachedState for the canonical server from canonical_crypto_config 736 // Copy the CachedState for the canonical server from canonical_crypto_config
739 // as the initial CachedState for the server_hostname in crypto_config. 737 // as the initial CachedState for the server_hostname in crypto_config.
740 crypto_config->InitializeFrom(server_hostname, 738 crypto_config->InitializeFrom(session_key, canonical_session_key,
741 canonical_host_port_pair.host(),
742 canonical_crypto_config); 739 canonical_crypto_config);
743 // Update canonical version to point at the "most recent" crypto_config. 740 // Update canonical version to point at the "most recent" crypto_config.
744 canonical_hostname_to_origin_map_[suffix_session_key] = 741 canonical_hostname_to_origin_map_[suffix_session_key] =
745 canonical_session_key; 742 canonical_session_key;
746 } 743 }
747 744
748 } // namespace net 745 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698