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

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

Issue 107803002: Consistently suggest ephemeral port for QUIC client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Repond to wtc review Created 7 years 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
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"
11 #include "base/message_loop/message_loop_proxy.h" 11 #include "base/message_loop/message_loop_proxy.h"
12 #include "base/rand_util.h" 12 #include "base/rand_util.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/cert/cert_verifier.h" 17 #include "net/cert/cert_verifier.h"
18 #include "net/dns/host_resolver.h" 18 #include "net/dns/host_resolver.h"
19 #include "net/dns/single_request_host_resolver.h" 19 #include "net/dns/single_request_host_resolver.h"
20 #include "net/http/http_server_properties.h" 20 #include "net/http/http_server_properties.h"
21 #include "net/quic/congestion_control/tcp_receiver.h" 21 #include "net/quic/congestion_control/tcp_receiver.h"
22 #include "net/quic/crypto/proof_verifier_chromium.h" 22 #include "net/quic/crypto/proof_verifier_chromium.h"
23 #include "net/quic/crypto/quic_random.h" 23 #include "net/quic/crypto/quic_random.h"
24 #include "net/quic/port_suggester.h"
24 #include "net/quic/quic_client_session.h" 25 #include "net/quic/quic_client_session.h"
25 #include "net/quic/quic_clock.h" 26 #include "net/quic/quic_clock.h"
26 #include "net/quic/quic_connection.h" 27 #include "net/quic/quic_connection.h"
27 #include "net/quic/quic_connection_helper.h" 28 #include "net/quic/quic_connection_helper.h"
28 #include "net/quic/quic_crypto_client_stream_factory.h" 29 #include "net/quic/quic_crypto_client_stream_factory.h"
29 #include "net/quic/quic_default_packet_writer.h" 30 #include "net/quic/quic_default_packet_writer.h"
30 #include "net/quic/quic_http_stream.h" 31 #include "net/quic/quic_http_stream.h"
31 #include "net/quic/quic_protocol.h" 32 #include "net/quic/quic_protocol.h"
32 #include "net/socket/client_socket_factory.h" 33 #include "net/socket/client_socket_factory.h"
33 34
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 QuicClock* clock, 250 QuicClock* clock,
250 size_t max_packet_length) 251 size_t max_packet_length)
251 : require_confirmation_(true), 252 : require_confirmation_(true),
252 host_resolver_(host_resolver), 253 host_resolver_(host_resolver),
253 client_socket_factory_(client_socket_factory), 254 client_socket_factory_(client_socket_factory),
254 http_server_properties_(http_server_properties), 255 http_server_properties_(http_server_properties),
255 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), 256 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory),
256 random_generator_(random_generator), 257 random_generator_(random_generator),
257 clock_(clock), 258 clock_(clock),
258 max_packet_length_(max_packet_length), 259 max_packet_length_(max_packet_length),
259 weak_factory_(this) { 260 weak_factory_(this),
261 port_entropy_(random_generator_->RandUint64()) {
260 config_.SetDefaults(); 262 config_.SetDefaults();
261 config_.set_idle_connection_state_lifetime( 263 config_.set_idle_connection_state_lifetime(
262 QuicTime::Delta::FromSeconds(30), 264 QuicTime::Delta::FromSeconds(30),
263 QuicTime::Delta::FromSeconds(30)); 265 QuicTime::Delta::FromSeconds(30));
264 cannoncial_suffixes_.push_back(string(".c.youtube.com")); 266 cannoncial_suffixes_.push_back(string(".c.youtube.com"));
265 cannoncial_suffixes_.push_back(string(".googlevideo.com")); 267 cannoncial_suffixes_.push_back(string(".googlevideo.com"));
266 } 268 }
267 269
268 QuicStreamFactory::~QuicStreamFactory() { 270 QuicStreamFactory::~QuicStreamFactory() {
269 CloseAllSessions(ERR_ABORTED); 271 CloseAllSessions(ERR_ABORTED);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 442 }
441 443
442 QuicClientSession* QuicStreamFactory::CreateSession( 444 QuicClientSession* QuicStreamFactory::CreateSession(
443 const HostPortProxyPair& host_port_proxy_pair, 445 const HostPortProxyPair& host_port_proxy_pair,
444 bool is_https, 446 bool is_https,
445 CertVerifier* cert_verifier, 447 CertVerifier* cert_verifier,
446 const AddressList& address_list, 448 const AddressList& address_list,
447 const BoundNetLog& net_log) { 449 const BoundNetLog& net_log) {
448 QuicGuid guid = random_generator_->RandUint64(); 450 QuicGuid guid = random_generator_->RandUint64();
449 IPEndPoint addr = *address_list.begin(); 451 IPEndPoint addr = *address_list.begin();
452 scoped_refptr<PortSuggester> port_suggester =
453 new PortSuggester(host_port_proxy_pair.first, port_entropy_);
450 scoped_ptr<DatagramClientSocket> socket( 454 scoped_ptr<DatagramClientSocket> socket(
451 client_socket_factory_->CreateDatagramClientSocket( 455 client_socket_factory_->CreateDatagramClientSocket(
452 DatagramSocket::DEFAULT_BIND, base::Bind(&base::RandInt), 456 DatagramSocket::RANDOM_BIND,
457 base::Bind(&PortSuggester::SuggestPort, port_suggester),
Ryan Hamilton 2013/12/07 01:46:14 It would be super great if we had a test that veri
jar (doing other things) 2013/12/07 03:12:18 I added some code to DCHECK() that the port_sugges
Ryan Hamilton 2013/12/07 04:52:22 If you reverted the changes to this file, would an
453 net_log.net_log(), net_log.source())); 458 net_log.net_log(), net_log.source()));
454 socket->Connect(addr); 459 socket->Connect(addr);
455 460
456 // We should adaptively set this buffer size, but for now, we'll use a size 461 // We should adaptively set this buffer size, but for now, we'll use a size
457 // that is more than large enough for a full receive window, and yet 462 // that is more than large enough for a full receive window, and yet
458 // does not consume "too much" memory. If we see bursty packet loss, we may 463 // does not consume "too much" memory. If we see bursty packet loss, we may
459 // revisit this setting and test for its impact. 464 // revisit this setting and test for its impact.
460 const int32 kSocketBufferSize(TcpReceiver::kReceiveWindowTCP); 465 const int32 kSocketBufferSize(TcpReceiver::kReceiveWindowTCP);
461 socket->SetReceiveBufferSize(kSocketBufferSize); 466 socket->SetReceiveBufferSize(kSocketBufferSize);
462 // Set a buffer large enough to contain the initial CWND's worth of packet 467 // Set a buffer large enough to contain the initial CWND's worth of packet
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // Copy the CachedState for the canonical server from canonical_crypto_config 565 // Copy the CachedState for the canonical server from canonical_crypto_config
561 // as the initial CachedState for the server_hostname in crypto_config. 566 // as the initial CachedState for the server_hostname in crypto_config.
562 crypto_config->InitializeFrom(server_hostname, 567 crypto_config->InitializeFrom(server_hostname,
563 canonical_host_port_proxy_pair.first.host(), 568 canonical_host_port_proxy_pair.first.host(),
564 canonical_crypto_config); 569 canonical_crypto_config);
565 // Update canonical version to point at the "most recent" crypto_config. 570 // Update canonical version to point at the "most recent" crypto_config.
566 canonical_hostname_to_origin_map_[canonical_host_port] = host_port_proxy_pair; 571 canonical_hostname_to_origin_map_[canonical_host_port] = host_port_proxy_pair;
567 } 572 }
568 573
569 } // namespace net 574 } // namespace net
OLDNEW
« net/quic/quic_stream_factory.h ('K') | « net/quic/quic_stream_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698