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" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // The suggested initial congestion windows for a server to use. | 63 // The suggested initial congestion windows for a server to use. |
64 // TODO: This should be tested and optimized, and even better, suggest a window | 64 // TODO: This should be tested and optimized, and even better, suggest a window |
65 // that corresponds to historical bandwidth and min-RTT. | 65 // that corresponds to historical bandwidth and min-RTT. |
66 // Larger initial congestion windows can, if we don't overshoot, reduce latency | 66 // Larger initial congestion windows can, if we don't overshoot, reduce latency |
67 // by avoiding the RTT needed for slow start to double (and re-double) from a | 67 // by avoiding the RTT needed for slow start to double (and re-double) from a |
68 // default of 10. | 68 // default of 10. |
69 // We match SPDY's use of 32 when secure (since we'd compete with SPDY). | 69 // We match SPDY's use of 32 when secure (since we'd compete with SPDY). |
70 const int32 kServerSecureInitialCongestionWindow = 32; | 70 const int32 kServerSecureInitialCongestionWindow = 32; |
71 // Be conservative, and just use double a typical TCP ICWND for HTTP. | 71 // Be conservative, and just use double a typical TCP ICWND for HTTP. |
72 const int32 kServerInecureInitialCongestionWindow = 20; | 72 const int32 kServerInecureInitialCongestionWindow = 20; |
| 73 // Set the maximum number of undecryptable packets the connection will store. |
| 74 const int32 kMaxUndecryptablePackets = 100; |
73 | 75 |
74 const char kDummyHostname[] = "quic.global.props"; | 76 const char kDummyHostname[] = "quic.global.props"; |
75 const uint16 kDummyPort = 0; | 77 const uint16 kDummyPort = 0; |
76 | 78 |
77 void HistogramCreateSessionFailure(enum CreateSessionFailure error) { | 79 void HistogramCreateSessionFailure(enum CreateSessionFailure error) { |
78 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error, | 80 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error, |
79 CREATION_ERROR_MAX); | 81 CREATION_ERROR_MAX); |
80 } | 82 } |
81 | 83 |
82 bool IsEcdsaSupported() { | 84 bool IsEcdsaSupported() { |
83 #if defined(OS_WIN) | 85 #if defined(OS_WIN) |
84 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 86 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
85 return false; | 87 return false; |
86 #endif | 88 #endif |
87 | 89 |
88 return true; | 90 return true; |
89 } | 91 } |
90 | 92 |
91 QuicConfig InitializeQuicConfig(const QuicTagVector& connection_options) { | 93 QuicConfig InitializeQuicConfig(const QuicTagVector& connection_options) { |
92 QuicConfig config; | 94 QuicConfig config; |
93 config.SetDefaults(); | |
94 config.SetIdleConnectionStateLifetime( | 95 config.SetIdleConnectionStateLifetime( |
95 QuicTime::Delta::FromSeconds(kIdleConnectionTimeoutSeconds), | 96 QuicTime::Delta::FromSeconds(kIdleConnectionTimeoutSeconds), |
96 QuicTime::Delta::FromSeconds(kIdleConnectionTimeoutSeconds)); | 97 QuicTime::Delta::FromSeconds(kIdleConnectionTimeoutSeconds)); |
97 config.SetConnectionOptionsToSend(connection_options); | 98 config.SetConnectionOptionsToSend(connection_options); |
98 return config; | 99 return config; |
99 } | 100 } |
100 | 101 |
101 class DefaultPacketWriterFactory : public QuicConnection::PacketWriterFactory { | 102 class DefaultPacketWriterFactory : public QuicConnection::PacketWriterFactory { |
102 public: | 103 public: |
103 explicit DefaultPacketWriterFactory(DatagramClientSocket* socket) | 104 explicit DefaultPacketWriterFactory(DatagramClientSocket* socket) |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 config_(InitializeQuicConfig(connection_options)), | 505 config_(InitializeQuicConfig(connection_options)), |
505 supported_versions_(supported_versions), | 506 supported_versions_(supported_versions), |
506 enable_port_selection_(enable_port_selection), | 507 enable_port_selection_(enable_port_selection), |
507 always_require_handshake_confirmation_( | 508 always_require_handshake_confirmation_( |
508 always_require_handshake_confirmation), | 509 always_require_handshake_confirmation), |
509 disable_connection_pooling_(disable_connection_pooling), | 510 disable_connection_pooling_(disable_connection_pooling), |
510 port_seed_(random_generator_->RandUint64()), | 511 port_seed_(random_generator_->RandUint64()), |
511 check_persisted_supports_quic_(true), | 512 check_persisted_supports_quic_(true), |
512 weak_factory_(this) { | 513 weak_factory_(this) { |
513 DCHECK(transport_security_state_); | 514 DCHECK(transport_security_state_); |
514 crypto_config_.SetDefaults(); | |
515 crypto_config_.set_user_agent_id(user_agent_id); | 515 crypto_config_.set_user_agent_id(user_agent_id); |
516 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); | 516 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); |
517 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); | 517 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); |
518 crypto_config_.SetProofVerifier( | 518 crypto_config_.SetProofVerifier( |
519 new ProofVerifierChromium(cert_verifier, transport_security_state)); | 519 new ProofVerifierChromium(cert_verifier, transport_security_state)); |
520 crypto_config_.SetChannelIDSource( | 520 crypto_config_.SetChannelIDSource( |
521 new ChannelIDSourceChromium(channel_id_service)); | 521 new ChannelIDSourceChromium(channel_id_service)); |
522 base::CPU cpu; | 522 base::CPU cpu; |
523 if (cpu.has_aesni() && cpu.has_avx()) | 523 if (cpu.has_aesni() && cpu.has_avx()) |
524 crypto_config_.PreferAesGcm(); | 524 crypto_config_.PreferAesGcm(); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 false /* is_server */, | 895 false /* is_server */, |
896 supported_versions_); | 896 supported_versions_); |
897 connection->set_max_packet_length(max_packet_length_); | 897 connection->set_max_packet_length(max_packet_length_); |
898 | 898 |
899 InitializeCachedStateInCryptoConfig(server_id, server_info); | 899 InitializeCachedStateInCryptoConfig(server_id, server_info); |
900 | 900 |
901 QuicConfig config = config_; | 901 QuicConfig config = config_; |
902 config.SetInitialCongestionWindowToSend( | 902 config.SetInitialCongestionWindowToSend( |
903 server_id.is_https() ? kServerSecureInitialCongestionWindow | 903 server_id.is_https() ? kServerSecureInitialCongestionWindow |
904 : kServerInecureInitialCongestionWindow); | 904 : kServerInecureInitialCongestionWindow); |
| 905 config.set_max_undecryptable_packets(kMaxUndecryptablePackets); |
905 config.SetInitialFlowControlWindowToSend(kInitialReceiveWindowSize); | 906 config.SetInitialFlowControlWindowToSend(kInitialReceiveWindowSize); |
906 config.SetInitialStreamFlowControlWindowToSend(kInitialReceiveWindowSize); | 907 config.SetInitialStreamFlowControlWindowToSend(kInitialReceiveWindowSize); |
907 config.SetInitialSessionFlowControlWindowToSend(kInitialReceiveWindowSize); | 908 config.SetInitialSessionFlowControlWindowToSend(kInitialReceiveWindowSize); |
908 if (http_server_properties_) { | 909 if (http_server_properties_) { |
909 const HttpServerProperties::NetworkStats* stats = | 910 const HttpServerProperties::NetworkStats* stats = |
910 http_server_properties_->GetServerNetworkStats( | 911 http_server_properties_->GetServerNetworkStats( |
911 server_id.host_port_pair()); | 912 server_id.host_port_pair()); |
912 if (stats != nullptr) { | 913 if (stats != nullptr) { |
913 config.SetInitialRoundTripTimeUsToSend(stats->srtt.InMicroseconds()); | 914 config.SetInitialRoundTripTimeUsToSend(stats->srtt.InMicroseconds()); |
914 } | 915 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 http_server_properties_->ClearAlternateProtocol(server); | 1026 http_server_properties_->ClearAlternateProtocol(server); |
1026 http_server_properties_->SetAlternateProtocol( | 1027 http_server_properties_->SetAlternateProtocol( |
1027 server, alternate.port, alternate.protocol, 1); | 1028 server, alternate.port, alternate.protocol, 1); |
1028 DCHECK_EQ(QUIC, | 1029 DCHECK_EQ(QUIC, |
1029 http_server_properties_->GetAlternateProtocol(server).protocol); | 1030 http_server_properties_->GetAlternateProtocol(server).protocol); |
1030 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( | 1031 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( |
1031 server)); | 1032 server)); |
1032 } | 1033 } |
1033 | 1034 |
1034 } // namespace net | 1035 } // namespace net |
OLD | NEW |