| 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" |
| 11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
| 12 #include "base/metrics/field_trial.h" |
| 12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 13 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.h" |
| 14 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
| 15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| 18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 19 #include "net/cert/cert_verifier.h" | 20 #include "net/cert/cert_verifier.h" |
| 20 #include "net/dns/host_resolver.h" | 21 #include "net/dns/host_resolver.h" |
| 21 #include "net/dns/single_request_host_resolver.h" | 22 #include "net/dns/single_request_host_resolver.h" |
| 22 #include "net/http/http_server_properties.h" | 23 #include "net/http/http_server_properties.h" |
| 23 #include "net/quic/congestion_control/tcp_receiver.h" | 24 #include "net/quic/congestion_control/tcp_receiver.h" |
| 24 #include "net/quic/crypto/channel_id_chromium.h" | 25 #include "net/quic/crypto/channel_id_chromium.h" |
| 25 #include "net/quic/crypto/proof_verifier_chromium.h" | 26 #include "net/quic/crypto/proof_verifier_chromium.h" |
| 26 #include "net/quic/crypto/quic_random.h" | 27 #include "net/quic/crypto/quic_random.h" |
| 27 #include "net/quic/crypto/quic_server_info.h" | 28 #include "net/quic/crypto/quic_server_info.h" |
| 28 #include "net/quic/port_suggester.h" | 29 #include "net/quic/port_suggester.h" |
| 29 #include "net/quic/quic_client_session.h" | 30 #include "net/quic/quic_client_session.h" |
| 30 #include "net/quic/quic_clock.h" | 31 #include "net/quic/quic_clock.h" |
| 31 #include "net/quic/quic_connection.h" | 32 #include "net/quic/quic_connection.h" |
| 32 #include "net/quic/quic_connection_helper.h" | 33 #include "net/quic/quic_connection_helper.h" |
| 33 #include "net/quic/quic_crypto_client_stream_factory.h" | 34 #include "net/quic/quic_crypto_client_stream_factory.h" |
| 34 #include "net/quic/quic_default_packet_writer.h" | 35 #include "net/quic/quic_default_packet_writer.h" |
| 36 #include "net/quic/quic_flags.h" |
| 35 #include "net/quic/quic_http_stream.h" | 37 #include "net/quic/quic_http_stream.h" |
| 36 #include "net/quic/quic_protocol.h" | 38 #include "net/quic/quic_protocol.h" |
| 37 #include "net/quic/quic_server_id.h" | 39 #include "net/quic/quic_server_id.h" |
| 38 #include "net/socket/client_socket_factory.h" | 40 #include "net/socket/client_socket_factory.h" |
| 39 | 41 |
| 40 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 41 #include "base/win/windows_version.h" | 43 #include "base/win/windows_version.h" |
| 42 #endif | 44 #endif |
| 43 | 45 |
| 44 namespace net { | 46 namespace net { |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 QuicClock* clock, | 560 QuicClock* clock, |
| 559 size_t max_packet_length, | 561 size_t max_packet_length, |
| 560 const std::string& user_agent_id, | 562 const std::string& user_agent_id, |
| 561 const QuicVersionVector& supported_versions, | 563 const QuicVersionVector& supported_versions, |
| 562 bool enable_port_selection, | 564 bool enable_port_selection, |
| 563 bool always_require_handshake_confirmation, | 565 bool always_require_handshake_confirmation, |
| 564 bool disable_connection_pooling, | 566 bool disable_connection_pooling, |
| 565 int load_server_info_timeout, | 567 int load_server_info_timeout, |
| 566 bool disable_loading_server_info_for_new_servers, | 568 bool disable_loading_server_info_for_new_servers, |
| 567 float load_server_info_timeout_srtt_multiplier, | 569 float load_server_info_timeout_srtt_multiplier, |
| 570 bool enable_truncated_connection_ids, |
| 568 const QuicTagVector& connection_options) | 571 const QuicTagVector& connection_options) |
| 569 : require_confirmation_(true), | 572 : require_confirmation_(true), |
| 570 host_resolver_(host_resolver), | 573 host_resolver_(host_resolver), |
| 571 client_socket_factory_(client_socket_factory), | 574 client_socket_factory_(client_socket_factory), |
| 572 http_server_properties_(http_server_properties), | 575 http_server_properties_(http_server_properties), |
| 573 transport_security_state_(transport_security_state), | 576 transport_security_state_(transport_security_state), |
| 574 quic_server_info_factory_(nullptr), | 577 quic_server_info_factory_(nullptr), |
| 575 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 578 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
| 576 random_generator_(random_generator), | 579 random_generator_(random_generator), |
| 577 clock_(clock), | 580 clock_(clock), |
| 578 max_packet_length_(max_packet_length), | 581 max_packet_length_(max_packet_length), |
| 579 config_(InitializeQuicConfig(connection_options)), | 582 config_(InitializeQuicConfig(connection_options)), |
| 580 supported_versions_(supported_versions), | 583 supported_versions_(supported_versions), |
| 581 enable_port_selection_(enable_port_selection), | 584 enable_port_selection_(enable_port_selection), |
| 582 always_require_handshake_confirmation_( | 585 always_require_handshake_confirmation_( |
| 583 always_require_handshake_confirmation), | 586 always_require_handshake_confirmation), |
| 584 disable_connection_pooling_(disable_connection_pooling), | 587 disable_connection_pooling_(disable_connection_pooling), |
| 585 load_server_info_timeout_ms_(load_server_info_timeout), | 588 load_server_info_timeout_ms_(load_server_info_timeout), |
| 586 disable_loading_server_info_for_new_servers_( | 589 disable_loading_server_info_for_new_servers_( |
| 587 disable_loading_server_info_for_new_servers), | 590 disable_loading_server_info_for_new_servers), |
| 588 load_server_info_timeout_srtt_multiplier_( | 591 load_server_info_timeout_srtt_multiplier_( |
| 589 load_server_info_timeout_srtt_multiplier), | 592 load_server_info_timeout_srtt_multiplier), |
| 593 enable_truncated_connection_ids_(enable_truncated_connection_ids), |
| 590 port_seed_(random_generator_->RandUint64()), | 594 port_seed_(random_generator_->RandUint64()), |
| 591 check_persisted_supports_quic_(true), | 595 check_persisted_supports_quic_(true), |
| 592 task_runner_(nullptr), | 596 task_runner_(nullptr), |
| 593 weak_factory_(this) { | 597 weak_factory_(this) { |
| 594 DCHECK(transport_security_state_); | 598 DCHECK(transport_security_state_); |
| 595 crypto_config_.set_user_agent_id(user_agent_id); | 599 crypto_config_.set_user_agent_id(user_agent_id); |
| 596 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); | 600 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); |
| 597 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); | 601 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); |
| 598 crypto_config_.SetProofVerifier( | 602 crypto_config_.SetProofVerifier( |
| 599 new ProofVerifierChromium(cert_verifier, transport_security_state)); | 603 new ProofVerifierChromium(cert_verifier, transport_security_state)); |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 | 1042 |
| 1039 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 1043 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 1040 tracked_objects::ScopedTracker tracking_profile5( | 1044 tracked_objects::ScopedTracker tracking_profile5( |
| 1041 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1045 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1042 "422516 QuicStreamFactory::CreateSession5")); | 1046 "422516 QuicStreamFactory::CreateSession5")); |
| 1043 | 1047 |
| 1044 InitializeCachedStateInCryptoConfig(server_id, server_info); | 1048 InitializeCachedStateInCryptoConfig(server_id, server_info); |
| 1045 | 1049 |
| 1046 QuicConfig config = config_; | 1050 QuicConfig config = config_; |
| 1047 config.set_max_undecryptable_packets(kMaxUndecryptablePackets); | 1051 config.set_max_undecryptable_packets(kMaxUndecryptablePackets); |
| 1048 config.SetInitialFlowControlWindowToSend(kInitialReceiveWindowSize); | |
| 1049 config.SetInitialStreamFlowControlWindowToSend(kInitialReceiveWindowSize); | 1052 config.SetInitialStreamFlowControlWindowToSend(kInitialReceiveWindowSize); |
| 1050 config.SetInitialSessionFlowControlWindowToSend(kInitialReceiveWindowSize); | 1053 config.SetInitialSessionFlowControlWindowToSend(kInitialReceiveWindowSize); |
| 1051 int64 srtt = GetServerNetworkStatsSmoothedRttInMicroseconds(server_id); | 1054 int64 srtt = GetServerNetworkStatsSmoothedRttInMicroseconds(server_id); |
| 1052 if (srtt > 0) | 1055 if (srtt > 0) |
| 1053 config.SetInitialRoundTripTimeUsToSend(static_cast<uint32>(srtt)); | 1056 config.SetInitialRoundTripTimeUsToSend(static_cast<uint32>(srtt)); |
| 1057 if (FLAGS_allow_truncated_connection_ids_for_quic && |
| 1058 enable_truncated_connection_ids_) |
| 1059 config.SetBytesForConnectionIdToSend(0); |
| 1054 | 1060 |
| 1055 if (quic_server_info_factory_ && !server_info) { | 1061 if (quic_server_info_factory_ && !server_info) { |
| 1056 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 1062 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 1057 tracked_objects::ScopedTracker tracking_profile6( | 1063 tracked_objects::ScopedTracker tracking_profile6( |
| 1058 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1064 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1059 "422516 QuicStreamFactory::CreateSession6")); | 1065 "422516 QuicStreamFactory::CreateSession6")); |
| 1060 | 1066 |
| 1061 // Start the disk cache loading so that we can persist the newer QUIC server | 1067 // Start the disk cache loading so that we can persist the newer QUIC server |
| 1062 // information and/or inform the disk cache that we have reused | 1068 // information and/or inform the disk cache that we have reused |
| 1063 // |server_info|. | 1069 // |server_info|. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 http_server_properties_->ClearAlternateProtocol(server); | 1223 http_server_properties_->ClearAlternateProtocol(server); |
| 1218 http_server_properties_->SetAlternateProtocol( | 1224 http_server_properties_->SetAlternateProtocol( |
| 1219 server, alternate.port, alternate.protocol, 1); | 1225 server, alternate.port, alternate.protocol, 1); |
| 1220 DCHECK_EQ(QUIC, | 1226 DCHECK_EQ(QUIC, |
| 1221 http_server_properties_->GetAlternateProtocol(server).protocol); | 1227 http_server_properties_->GetAlternateProtocol(server).protocol); |
| 1222 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( | 1228 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( |
| 1223 server)); | 1229 server)); |
| 1224 } | 1230 } |
| 1225 | 1231 |
| 1226 } // namespace net | 1232 } // namespace net |
| OLD | NEW |