| 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/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/metrics/histogram.h" |
| 12 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 17 #include "net/cert/cert_verifier.h" | 18 #include "net/cert/cert_verifier.h" |
| 18 #include "net/dns/host_resolver.h" | 19 #include "net/dns/host_resolver.h" |
| 19 #include "net/dns/single_request_host_resolver.h" | 20 #include "net/dns/single_request_host_resolver.h" |
| 20 #include "net/http/http_server_properties.h" | 21 #include "net/http/http_server_properties.h" |
| 21 #include "net/quic/congestion_control/tcp_receiver.h" | 22 #include "net/quic/congestion_control/tcp_receiver.h" |
| 22 #include "net/quic/crypto/proof_verifier_chromium.h" | 23 #include "net/quic/crypto/proof_verifier_chromium.h" |
| 23 #include "net/quic/crypto/quic_random.h" | 24 #include "net/quic/crypto/quic_random.h" |
| 25 #include "net/quic/port_suggester.h" |
| 24 #include "net/quic/quic_client_session.h" | 26 #include "net/quic/quic_client_session.h" |
| 25 #include "net/quic/quic_clock.h" | 27 #include "net/quic/quic_clock.h" |
| 26 #include "net/quic/quic_connection.h" | 28 #include "net/quic/quic_connection.h" |
| 27 #include "net/quic/quic_connection_helper.h" | 29 #include "net/quic/quic_connection_helper.h" |
| 28 #include "net/quic/quic_crypto_client_stream_factory.h" | 30 #include "net/quic/quic_crypto_client_stream_factory.h" |
| 29 #include "net/quic/quic_default_packet_writer.h" | 31 #include "net/quic/quic_default_packet_writer.h" |
| 30 #include "net/quic/quic_http_stream.h" | 32 #include "net/quic/quic_http_stream.h" |
| 31 #include "net/quic/quic_protocol.h" | 33 #include "net/quic/quic_protocol.h" |
| 32 #include "net/socket/client_socket_factory.h" | 34 #include "net/socket/client_socket_factory.h" |
| 33 | 35 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 QuicClock* clock, | 258 QuicClock* clock, |
| 257 size_t max_packet_length) | 259 size_t max_packet_length) |
| 258 : require_confirmation_(true), | 260 : require_confirmation_(true), |
| 259 host_resolver_(host_resolver), | 261 host_resolver_(host_resolver), |
| 260 client_socket_factory_(client_socket_factory), | 262 client_socket_factory_(client_socket_factory), |
| 261 http_server_properties_(http_server_properties), | 263 http_server_properties_(http_server_properties), |
| 262 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 264 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
| 263 random_generator_(random_generator), | 265 random_generator_(random_generator), |
| 264 clock_(clock), | 266 clock_(clock), |
| 265 max_packet_length_(max_packet_length), | 267 max_packet_length_(max_packet_length), |
| 266 weak_factory_(this) { | 268 weak_factory_(this), |
| 269 port_entropy_(random_generator_->RandUint64()) { |
| 267 config_.SetDefaults(); | 270 config_.SetDefaults(); |
| 268 config_.set_idle_connection_state_lifetime( | 271 config_.set_idle_connection_state_lifetime( |
| 269 QuicTime::Delta::FromSeconds(30), | 272 QuicTime::Delta::FromSeconds(30), |
| 270 QuicTime::Delta::FromSeconds(30)); | 273 QuicTime::Delta::FromSeconds(30)); |
| 271 | 274 |
| 272 cannoncial_suffixes_.push_back(string(".c.youtube.com")); | 275 cannoncial_suffixes_.push_back(string(".c.youtube.com")); |
| 273 cannoncial_suffixes_.push_back(string(".googlevideo.com")); | 276 cannoncial_suffixes_.push_back(string(".googlevideo.com")); |
| 274 } | 277 } |
| 275 | 278 |
| 276 QuicStreamFactory::~QuicStreamFactory() { | 279 QuicStreamFactory::~QuicStreamFactory() { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 | 452 |
| 450 int QuicStreamFactory::CreateSession( | 453 int QuicStreamFactory::CreateSession( |
| 451 const HostPortProxyPair& host_port_proxy_pair, | 454 const HostPortProxyPair& host_port_proxy_pair, |
| 452 bool is_https, | 455 bool is_https, |
| 453 CertVerifier* cert_verifier, | 456 CertVerifier* cert_verifier, |
| 454 const AddressList& address_list, | 457 const AddressList& address_list, |
| 455 const BoundNetLog& net_log, | 458 const BoundNetLog& net_log, |
| 456 QuicClientSession** session) { | 459 QuicClientSession** session) { |
| 457 QuicGuid guid = random_generator_->RandUint64(); | 460 QuicGuid guid = random_generator_->RandUint64(); |
| 458 IPEndPoint addr = *address_list.begin(); | 461 IPEndPoint addr = *address_list.begin(); |
| 462 scoped_refptr<PortSuggester> port_suggester = |
| 463 new PortSuggester(host_port_proxy_pair.first, port_entropy_); |
| 459 scoped_ptr<DatagramClientSocket> socket( | 464 scoped_ptr<DatagramClientSocket> socket( |
| 460 client_socket_factory_->CreateDatagramClientSocket( | 465 client_socket_factory_->CreateDatagramClientSocket( |
| 461 DatagramSocket::RANDOM_BIND, base::Bind(&base::RandInt), | 466 DatagramSocket::RANDOM_BIND, |
| 467 base::Bind(&PortSuggester::SuggestPort, port_suggester), |
| 462 net_log.net_log(), net_log.source())); | 468 net_log.net_log(), net_log.source())); |
| 463 int rv = socket->Connect(addr); | 469 int rv = socket->Connect(addr); |
| 464 if (rv != OK) | 470 if (rv != OK) |
| 465 return rv; | 471 return rv; |
| 472 UMA_HISTOGRAM_COUNTS("Net.QuicEphemeralPortsSuggested", |
| 473 port_suggester->call_count()); |
| 466 | 474 |
| 467 // We should adaptively set this buffer size, but for now, we'll use a size | 475 // We should adaptively set this buffer size, but for now, we'll use a size |
| 468 // that is more than large enough for a full receive window, and yet | 476 // that is more than large enough for a full receive window, and yet |
| 469 // does not consume "too much" memory. If we see bursty packet loss, we may | 477 // does not consume "too much" memory. If we see bursty packet loss, we may |
| 470 // revisit this setting and test for its impact. | 478 // revisit this setting and test for its impact. |
| 471 const int32 kSocketBufferSize(TcpReceiver::kReceiveWindowTCP); | 479 const int32 kSocketBufferSize(TcpReceiver::kReceiveWindowTCP); |
| 472 socket->SetReceiveBufferSize(kSocketBufferSize); | 480 socket->SetReceiveBufferSize(kSocketBufferSize); |
| 473 // Set a buffer large enough to contain the initial CWND's worth of packet | 481 // Set a buffer large enough to contain the initial CWND's worth of packet |
| 474 // to work around the problem with CHLO packets being sent out with the | 482 // to work around the problem with CHLO packets being sent out with the |
| 475 // wrong encryption level, when the send buffer is full. | 483 // wrong encryption level, when the send buffer is full. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 // Copy the CachedState for the canonical server from canonical_crypto_config | 578 // Copy the CachedState for the canonical server from canonical_crypto_config |
| 571 // as the initial CachedState for the server_hostname in crypto_config. | 579 // as the initial CachedState for the server_hostname in crypto_config. |
| 572 crypto_config->InitializeFrom(server_hostname, | 580 crypto_config->InitializeFrom(server_hostname, |
| 573 canonical_host_port_proxy_pair.first.host(), | 581 canonical_host_port_proxy_pair.first.host(), |
| 574 canonical_crypto_config); | 582 canonical_crypto_config); |
| 575 // Update canonical version to point at the "most recent" crypto_config. | 583 // Update canonical version to point at the "most recent" crypto_config. |
| 576 canonical_hostname_to_origin_map_[canonical_host_port] = host_port_proxy_pair; | 584 canonical_hostname_to_origin_map_[canonical_host_port] = host_port_proxy_pair; |
| 577 } | 585 } |
| 578 | 586 |
| 579 } // namespace net | 587 } // namespace net |
| OLD | NEW |