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

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

Issue 48893003: QUIC - added googlevideo.com to the list of cannonical hostnames to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merging with tip Created 7 years, 1 month 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
« no previous file with comments | « net/quic/quic_stream_factory.h ('k') | net/quic/quic_stream_factory_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 13 matching lines...) Expand all
24 #include "net/quic/quic_client_session.h" 24 #include "net/quic/quic_client_session.h"
25 #include "net/quic/quic_clock.h" 25 #include "net/quic/quic_clock.h"
26 #include "net/quic/quic_connection.h" 26 #include "net/quic/quic_connection.h"
27 #include "net/quic/quic_connection_helper.h" 27 #include "net/quic/quic_connection_helper.h"
28 #include "net/quic/quic_crypto_client_stream_factory.h" 28 #include "net/quic/quic_crypto_client_stream_factory.h"
29 #include "net/quic/quic_default_packet_writer.h" 29 #include "net/quic/quic_default_packet_writer.h"
30 #include "net/quic/quic_http_stream.h" 30 #include "net/quic/quic_http_stream.h"
31 #include "net/quic/quic_protocol.h" 31 #include "net/quic/quic_protocol.h"
32 #include "net/socket/client_socket_factory.h" 32 #include "net/socket/client_socket_factory.h"
33 33
34 using std::string;
35 using std::vector;
36
34 namespace net { 37 namespace net {
35 38
36 // Responsible for creating a new QUIC session to the specified server, and 39 // Responsible for creating a new QUIC session to the specified server, and
37 // for notifying any associated requests when complete. 40 // for notifying any associated requests when complete.
38 class QuicStreamFactory::Job { 41 class QuicStreamFactory::Job {
39 public: 42 public:
40 Job(QuicStreamFactory* factory, 43 Job(QuicStreamFactory* factory,
41 HostResolver* host_resolver, 44 HostResolver* host_resolver,
42 const HostPortProxyPair& host_port_proxy_pair, 45 const HostPortProxyPair& host_port_proxy_pair,
43 bool is_https, 46 bool is_https,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 client_socket_factory_(client_socket_factory), 252 client_socket_factory_(client_socket_factory),
250 http_server_properties_(http_server_properties), 253 http_server_properties_(http_server_properties),
251 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), 254 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory),
252 random_generator_(random_generator), 255 random_generator_(random_generator),
253 clock_(clock), 256 clock_(clock),
254 weak_factory_(this) { 257 weak_factory_(this) {
255 config_.SetDefaults(); 258 config_.SetDefaults();
256 config_.set_idle_connection_state_lifetime( 259 config_.set_idle_connection_state_lifetime(
257 QuicTime::Delta::FromSeconds(30), 260 QuicTime::Delta::FromSeconds(30),
258 QuicTime::Delta::FromSeconds(30)); 261 QuicTime::Delta::FromSeconds(30));
262 cannoncial_suffixes_.push_back(string(".c.youtube.com"));
263 cannoncial_suffixes_.push_back(string(".googlevideo.com"));
259 } 264 }
260 265
261 QuicStreamFactory::~QuicStreamFactory() { 266 QuicStreamFactory::~QuicStreamFactory() {
262 CloseAllSessions(ERR_ABORTED); 267 CloseAllSessions(ERR_ABORTED);
263 STLDeleteElements(&all_sessions_); 268 STLDeleteElements(&all_sessions_);
264 STLDeleteValues(&active_jobs_); 269 STLDeleteValues(&active_jobs_);
265 STLDeleteValues(&all_crypto_configs_); 270 STLDeleteValues(&all_crypto_configs_);
266 } 271 }
267 272
268 int QuicStreamFactory::Create(const HostPortProxyPair& host_port_proxy_pair, 273 int QuicStreamFactory::Create(const HostPortProxyPair& host_port_proxy_pair,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 all_crypto_configs_[host_port_proxy_pair] = crypto_config; 504 all_crypto_configs_[host_port_proxy_pair] = crypto_config;
500 PopulateFromCanonicalConfig(host_port_proxy_pair, crypto_config); 505 PopulateFromCanonicalConfig(host_port_proxy_pair, crypto_config);
501 } 506 }
502 return crypto_config; 507 return crypto_config;
503 } 508 }
504 509
505 void QuicStreamFactory::PopulateFromCanonicalConfig( 510 void QuicStreamFactory::PopulateFromCanonicalConfig(
506 const HostPortProxyPair& host_port_proxy_pair, 511 const HostPortProxyPair& host_port_proxy_pair,
507 QuicCryptoClientConfig* crypto_config) { 512 QuicCryptoClientConfig* crypto_config) {
508 const string server_hostname = host_port_proxy_pair.first.host(); 513 const string server_hostname = host_port_proxy_pair.first.host();
509 const string kYouTubeSuffix(".c.youtube.com"); 514
510 if (!EndsWith(server_hostname, kYouTubeSuffix, false)) { 515 unsigned i = 0;
516 for (; i < cannoncial_suffixes_.size(); ++i) {
517 if (EndsWith(server_hostname, cannoncial_suffixes_[i], false)) {
518 break;
519 }
520 }
521 if (i == cannoncial_suffixes_.size())
511 return; 522 return;
512 }
513 523
514 HostPortPair canonical_host_port(kYouTubeSuffix, 524 HostPortPair canonical_host_port(cannoncial_suffixes_[i],
515 host_port_proxy_pair.first.port()); 525 host_port_proxy_pair.first.port());
516 if (!ContainsKey(canonical_hostname_to_origin_map_, canonical_host_port)) { 526 if (!ContainsKey(canonical_hostname_to_origin_map_, canonical_host_port)) {
517 // This is the first host we've seen which matches the suffix, so make it 527 // This is the first host we've seen which matches the suffix, so make it
518 // canonical. 528 // canonical.
519 canonical_hostname_to_origin_map_[canonical_host_port] = 529 canonical_hostname_to_origin_map_[canonical_host_port] =
520 host_port_proxy_pair; 530 host_port_proxy_pair;
521 return; 531 return;
522 } 532 }
523 533
524 const HostPortProxyPair& canonical_host_port_proxy_pair = 534 const HostPortProxyPair& canonical_host_port_proxy_pair =
525 canonical_hostname_to_origin_map_[canonical_host_port]; 535 canonical_hostname_to_origin_map_[canonical_host_port];
526 QuicCryptoClientConfig* canonical_crypto_config = 536 QuicCryptoClientConfig* canonical_crypto_config =
527 all_crypto_configs_[canonical_host_port_proxy_pair]; 537 all_crypto_configs_[canonical_host_port_proxy_pair];
528 DCHECK(canonical_crypto_config); 538 DCHECK(canonical_crypto_config);
529 539
530 // Copy the CachedState for the canonical server from canonical_crypto_config 540 // Copy the CachedState for the canonical server from canonical_crypto_config
531 // as the initial CachedState for the server_hostname in crypto_config. 541 // as the initial CachedState for the server_hostname in crypto_config.
532 crypto_config->InitializeFrom(server_hostname, 542 crypto_config->InitializeFrom(server_hostname,
533 canonical_host_port_proxy_pair.first.host(), 543 canonical_host_port_proxy_pair.first.host(),
534 canonical_crypto_config); 544 canonical_crypto_config);
535 // Update canonical version to point at the "most recent" crypto_config. 545 // Update canonical version to point at the "most recent" crypto_config.
536 canonical_hostname_to_origin_map_[canonical_host_port] = host_port_proxy_pair; 546 canonical_hostname_to_origin_map_[canonical_host_port] = host_port_proxy_pair;
537 } 547 }
538 548
539 } // namespace net 549 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory.h ('k') | net/quic/quic_stream_factory_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698