| 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 17 matching lines...) Expand all Loading... |
| 28 #include "net/quic/quic_clock.h" | 28 #include "net/quic/quic_clock.h" |
| 29 #include "net/quic/quic_connection.h" | 29 #include "net/quic/quic_connection.h" |
| 30 #include "net/quic/quic_connection_helper.h" | 30 #include "net/quic/quic_connection_helper.h" |
| 31 #include "net/quic/quic_crypto_client_stream_factory.h" | 31 #include "net/quic/quic_crypto_client_stream_factory.h" |
| 32 #include "net/quic/quic_default_packet_writer.h" | 32 #include "net/quic/quic_default_packet_writer.h" |
| 33 #include "net/quic/quic_http_stream.h" | 33 #include "net/quic/quic_http_stream.h" |
| 34 #include "net/quic/quic_protocol.h" | 34 #include "net/quic/quic_protocol.h" |
| 35 #include "net/quic/quic_session_key.h" | 35 #include "net/quic/quic_session_key.h" |
| 36 #include "net/socket/client_socket_factory.h" | 36 #include "net/socket/client_socket_factory.h" |
| 37 | 37 |
| 38 #if defined(OS_WIN) |
| 39 #include "base/win/windows_version.h" |
| 40 #endif |
| 41 |
| 38 using std::string; | 42 using std::string; |
| 39 using std::vector; | 43 using std::vector; |
| 40 | 44 |
| 41 namespace net { | 45 namespace net { |
| 42 | 46 |
| 43 namespace { | 47 namespace { |
| 44 | 48 |
| 45 enum CreateSessionFailure { | 49 enum CreateSessionFailure { |
| 46 CREATION_ERROR_CONNECTING_SOCKET, | 50 CREATION_ERROR_CONNECTING_SOCKET, |
| 47 CREATION_ERROR_SETTING_RECEIVE_BUFFER, | 51 CREATION_ERROR_SETTING_RECEIVE_BUFFER, |
| 48 CREATION_ERROR_SETTING_SEND_BUFFER, | 52 CREATION_ERROR_SETTING_SEND_BUFFER, |
| 49 CREATION_ERROR_MAX | 53 CREATION_ERROR_MAX |
| 50 }; | 54 }; |
| 51 | 55 |
| 52 const uint64 kBrokenAlternateProtocolDelaySecs = 300; | 56 const uint64 kBrokenAlternateProtocolDelaySecs = 300; |
| 53 | 57 |
| 54 void HistogramCreateSessionFailure(enum CreateSessionFailure error) { | 58 void HistogramCreateSessionFailure(enum CreateSessionFailure error) { |
| 55 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error, | 59 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error, |
| 56 CREATION_ERROR_MAX); | 60 CREATION_ERROR_MAX); |
| 57 } | 61 } |
| 58 | 62 |
| 63 bool IsEcdsaSupported() { |
| 64 #if defined(OS_WIN) |
| 65 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
| 66 return false; |
| 67 #endif |
| 68 |
| 69 return true; |
| 70 } |
| 71 |
| 59 } // namespace | 72 } // namespace |
| 60 | 73 |
| 61 QuicStreamFactory::IpAliasKey::IpAliasKey() {} | 74 QuicStreamFactory::IpAliasKey::IpAliasKey() {} |
| 62 | 75 |
| 63 QuicStreamFactory::IpAliasKey::IpAliasKey(IPEndPoint ip_endpoint, | 76 QuicStreamFactory::IpAliasKey::IpAliasKey(IPEndPoint ip_endpoint, |
| 64 bool is_https) | 77 bool is_https) |
| 65 : ip_endpoint(ip_endpoint), | 78 : ip_endpoint(ip_endpoint), |
| 66 is_https(is_https) {} | 79 is_https(is_https) {} |
| 67 | 80 |
| 68 QuicStreamFactory::IpAliasKey::~IpAliasKey() {} | 81 QuicStreamFactory::IpAliasKey::~IpAliasKey() {} |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 config_.EnablePacing(enable_pacing_); | 403 config_.EnablePacing(enable_pacing_); |
| 391 config_.set_idle_connection_state_lifetime( | 404 config_.set_idle_connection_state_lifetime( |
| 392 QuicTime::Delta::FromSeconds(30), | 405 QuicTime::Delta::FromSeconds(30), |
| 393 QuicTime::Delta::FromSeconds(30)); | 406 QuicTime::Delta::FromSeconds(30)); |
| 394 | 407 |
| 395 crypto_config_.SetDefaults(); | 408 crypto_config_.SetDefaults(); |
| 396 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); | 409 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); |
| 397 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); | 410 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); |
| 398 crypto_config_.SetProofVerifier(new ProofVerifierChromium(cert_verifier)); | 411 crypto_config_.SetProofVerifier(new ProofVerifierChromium(cert_verifier)); |
| 399 base::CPU cpu; | 412 base::CPU cpu; |
| 400 if (cpu.has_aesni() && cpu.has_avx()) { | 413 if (cpu.has_aesni() && cpu.has_avx()) |
| 401 crypto_config_.PreferAesGcm(); | 414 crypto_config_.PreferAesGcm(); |
| 402 } | 415 if (!IsEcdsaSupported()) |
| 416 crypto_config_.DisableEcdsa(); |
| 403 } | 417 } |
| 404 | 418 |
| 405 QuicStreamFactory::~QuicStreamFactory() { | 419 QuicStreamFactory::~QuicStreamFactory() { |
| 406 CloseAllSessions(ERR_ABORTED); | 420 CloseAllSessions(ERR_ABORTED); |
| 407 STLDeleteElements(&all_sessions_); | 421 STLDeleteElements(&all_sessions_); |
| 408 STLDeleteValues(&active_jobs_); | 422 STLDeleteValues(&active_jobs_); |
| 409 } | 423 } |
| 410 | 424 |
| 411 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, | 425 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, |
| 412 bool is_https, | 426 bool is_https, |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 base::TimeTicks when = broken_alternate_protocol_list_.front().when; | 831 base::TimeTicks when = broken_alternate_protocol_list_.front().when; |
| 818 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 832 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
| 819 base::MessageLoop::current()->PostDelayedTask( | 833 base::MessageLoop::current()->PostDelayedTask( |
| 820 FROM_HERE, | 834 FROM_HERE, |
| 821 base::Bind(&QuicStreamFactory::ExpireBrokenAlternateProtocolMappings, | 835 base::Bind(&QuicStreamFactory::ExpireBrokenAlternateProtocolMappings, |
| 822 weak_factory_.GetWeakPtr()), | 836 weak_factory_.GetWeakPtr()), |
| 823 delay); | 837 delay); |
| 824 } | 838 } |
| 825 | 839 |
| 826 } // namespace net | 840 } // namespace net |
| OLD | NEW |