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 "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "net/base/test_data_directory.h" | 9 #include "net/base/test_data_directory.h" |
10 #include "net/cert/cert_verifier.h" | 10 #include "net/cert/cert_verifier.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 class QuicStreamFactoryPeer { | 42 class QuicStreamFactoryPeer { |
43 public: | 43 public: |
44 static QuicCryptoClientConfig* GetCryptoConfig(QuicStreamFactory* factory) { | 44 static QuicCryptoClientConfig* GetCryptoConfig(QuicStreamFactory* factory) { |
45 return &factory->crypto_config_; | 45 return &factory->crypto_config_; |
46 } | 46 } |
47 | 47 |
48 static bool HasActiveSession(QuicStreamFactory* factory, | 48 static bool HasActiveSession(QuicStreamFactory* factory, |
49 const HostPortPair& host_port_pair, | 49 const HostPortPair& host_port_pair, |
50 bool is_https) { | 50 bool is_https) { |
51 QuicSessionKey server_key(host_port_pair, is_https, kPrivacyModeDisabled); | 51 QuicSessionKey server_key(host_port_pair, is_https, PRIVACY_MODE_DISABLED); |
52 return factory->HasActiveSession(server_key); | 52 return factory->HasActiveSession(server_key); |
53 } | 53 } |
54 | 54 |
55 static QuicClientSession* GetActiveSession( | 55 static QuicClientSession* GetActiveSession( |
56 QuicStreamFactory* factory, | 56 QuicStreamFactory* factory, |
57 const HostPortPair& host_port_pair, | 57 const HostPortPair& host_port_pair, |
58 bool is_https) { | 58 bool is_https) { |
59 QuicSessionKey server_key(host_port_pair, is_https, kPrivacyModeDisabled); | 59 QuicSessionKey server_key(host_port_pair, is_https, PRIVACY_MODE_DISABLED); |
60 DCHECK(factory->HasActiveSession(server_key)); | 60 DCHECK(factory->HasActiveSession(server_key)); |
61 return factory->active_sessions_[server_key]; | 61 return factory->active_sessions_[server_key]; |
62 } | 62 } |
63 | 63 |
64 static scoped_ptr<QuicHttpStream> CreateIfSessionExists( | 64 static scoped_ptr<QuicHttpStream> CreateIfSessionExists( |
65 QuicStreamFactory* factory, | 65 QuicStreamFactory* factory, |
66 const HostPortPair& host_port_pair, | 66 const HostPortPair& host_port_pair, |
67 bool is_https, | 67 bool is_https, |
68 const BoundNetLog& net_log) { | 68 const BoundNetLog& net_log) { |
69 QuicSessionKey server_key(host_port_pair, is_https, kPrivacyModeDisabled); | 69 QuicSessionKey server_key(host_port_pair, is_https, PRIVACY_MODE_DISABLED); |
70 return factory->CreateIfSessionExists(server_key, net_log); | 70 return factory->CreateIfSessionExists(server_key, net_log); |
71 } | 71 } |
72 | 72 |
73 static bool IsLiveSession(QuicStreamFactory* factory, | 73 static bool IsLiveSession(QuicStreamFactory* factory, |
74 QuicClientSession* session) { | 74 QuicClientSession* session) { |
75 for (QuicStreamFactory::SessionSet::iterator it = | 75 for (QuicStreamFactory::SessionSet::iterator it = |
76 factory->all_sessions_.begin(); | 76 factory->all_sessions_.begin(); |
77 it != factory->all_sessions_.end(); ++it) { | 77 it != factory->all_sessions_.end(); ++it) { |
78 if (*it == session) | 78 if (*it == session) |
79 return true; | 79 return true; |
(...skipping 10 matching lines...) Expand all Loading... |
90 clock_(new MockClock()), | 90 clock_(new MockClock()), |
91 cert_verifier_(CertVerifier::CreateDefault()), | 91 cert_verifier_(CertVerifier::CreateDefault()), |
92 factory_(&host_resolver_, &socket_factory_, | 92 factory_(&host_resolver_, &socket_factory_, |
93 base::WeakPtr<HttpServerProperties>(), | 93 base::WeakPtr<HttpServerProperties>(), |
94 cert_verifier_.get(), | 94 cert_verifier_.get(), |
95 &crypto_client_stream_factory_, | 95 &crypto_client_stream_factory_, |
96 &random_generator_, clock_, kDefaultMaxPacketSize, | 96 &random_generator_, clock_, kDefaultMaxPacketSize, |
97 SupportedVersions(GetParam()), true, true), | 97 SupportedVersions(GetParam()), true, true), |
98 host_port_pair_(kDefaultServerHostName, kDefaultServerPort), | 98 host_port_pair_(kDefaultServerHostName, kDefaultServerPort), |
99 is_https_(false), | 99 is_https_(false), |
100 privacy_mode_(kPrivacyModeDisabled) { | 100 privacy_mode_(PRIVACY_MODE_DISABLED) { |
101 factory_.set_require_confirmation(false); | 101 factory_.set_require_confirmation(false); |
102 } | 102 } |
103 | 103 |
104 scoped_ptr<QuicHttpStream> CreateIfSessionExists( | 104 scoped_ptr<QuicHttpStream> CreateIfSessionExists( |
105 const HostPortPair& host_port_pair, | 105 const HostPortPair& host_port_pair, |
106 const BoundNetLog& net_log) { | 106 const BoundNetLog& net_log) { |
107 return QuicStreamFactoryPeer::CreateIfSessionExists( | 107 return QuicStreamFactoryPeer::CreateIfSessionExists( |
108 &factory_, host_port_pair, false, net_log_); | 108 &factory_, host_port_pair, false, net_log_); |
109 } | 109 } |
110 | 110 |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 QuicCryptoClientConfig::CachedState* cached2 = | 1142 QuicCryptoClientConfig::CachedState* cached2 = |
1143 crypto_config->LookupOrCreate(server_key2); | 1143 crypto_config->LookupOrCreate(server_key2); |
1144 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); | 1144 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); |
1145 EXPECT_TRUE(cached2->source_address_token().empty()); | 1145 EXPECT_TRUE(cached2->source_address_token().empty()); |
1146 EXPECT_FALSE(cached2->proof_valid()); | 1146 EXPECT_FALSE(cached2->proof_valid()); |
1147 } | 1147 } |
1148 } | 1148 } |
1149 | 1149 |
1150 } // namespace test | 1150 } // namespace test |
1151 } // namespace net | 1151 } // namespace net |
OLD | NEW |