OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/test_tools/quic_stream_factory_peer.h" | 5 #include "net/quic/test_tools/quic_stream_factory_peer.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "net/cert/x509_certificate.h" | |
11 #include "net/quic/crypto/quic_crypto_client_config.h" | 10 #include "net/quic/crypto/quic_crypto_client_config.h" |
12 #include "net/quic/quic_chromium_client_session.h" | 11 #include "net/quic/quic_chromium_client_session.h" |
13 #include "net/quic/quic_clock.h" | 12 #include "net/quic/quic_clock.h" |
14 #include "net/quic/quic_http_stream.h" | 13 #include "net/quic/quic_http_stream.h" |
15 #include "net/quic/quic_stream_factory.h" | 14 #include "net/quic/quic_stream_factory.h" |
16 #include "net/test/cert_test_util.h" | |
17 #include "net/test/test_data_directory.h" | |
18 | 15 |
19 using std::string; | 16 using std::string; |
20 using std::vector; | 17 using std::vector; |
21 | 18 |
22 namespace net { | 19 namespace net { |
23 namespace test { | 20 namespace test { |
24 | 21 |
25 const QuicConfig* QuicStreamFactoryPeer::GetConfig(QuicStreamFactory* factory) { | 22 const QuicConfig* QuicStreamFactoryPeer::GetConfig(QuicStreamFactory* factory) { |
26 return &factory->config_; | 23 return &factory->config_; |
27 } | 24 } |
28 | 25 |
29 QuicCryptoClientConfig* QuicStreamFactoryPeer::GetCryptoConfig( | 26 QuicCryptoClientConfig* QuicStreamFactoryPeer::GetCryptoConfig( |
30 QuicStreamFactory* factory) { | 27 QuicStreamFactory* factory) { |
31 return &factory->crypto_config_; | 28 return &factory->crypto_config_; |
32 } | 29 } |
33 | 30 |
34 bool QuicStreamFactoryPeer::HasActiveSession(QuicStreamFactory* factory, | 31 bool QuicStreamFactoryPeer::HasActiveSession(QuicStreamFactory* factory, |
35 const QuicServerId& server_id) { | 32 const QuicServerId& server_id) { |
36 return factory->HasActiveSession(server_id); | 33 return factory->HasActiveSession(server_id); |
37 } | 34 } |
38 | 35 |
39 bool QuicStreamFactoryPeer::HasActiveCertVerifierJob( | |
40 QuicStreamFactory* factory, | |
41 const QuicServerId& server_id) { | |
42 return factory->HasActiveCertVerifierJob(server_id); | |
43 } | |
44 | |
45 QuicChromiumClientSession* QuicStreamFactoryPeer::GetActiveSession( | 36 QuicChromiumClientSession* QuicStreamFactoryPeer::GetActiveSession( |
46 QuicStreamFactory* factory, | 37 QuicStreamFactory* factory, |
47 const QuicServerId& server_id) { | 38 const QuicServerId& server_id) { |
48 DCHECK(factory->HasActiveSession(server_id)); | 39 DCHECK(factory->HasActiveSession(server_id)); |
49 return factory->active_sessions_[server_id]; | 40 return factory->active_sessions_[server_id]; |
50 } | 41 } |
51 | 42 |
52 std::unique_ptr<QuicHttpStream> QuicStreamFactoryPeer::CreateFromSession( | 43 std::unique_ptr<QuicHttpStream> QuicStreamFactoryPeer::CreateFromSession( |
53 QuicStreamFactory* factory, | 44 QuicStreamFactory* factory, |
54 QuicChromiumClientSession* session) { | 45 QuicChromiumClientSession* session) { |
(...skipping 29 matching lines...) Expand all Loading... |
84 | 75 |
85 bool QuicStreamFactoryPeer::GetDelayTcpRace(QuicStreamFactory* factory) { | 76 bool QuicStreamFactoryPeer::GetDelayTcpRace(QuicStreamFactory* factory) { |
86 return factory->delay_tcp_race_; | 77 return factory->delay_tcp_race_; |
87 } | 78 } |
88 | 79 |
89 void QuicStreamFactoryPeer::SetDelayTcpRace(QuicStreamFactory* factory, | 80 void QuicStreamFactoryPeer::SetDelayTcpRace(QuicStreamFactory* factory, |
90 bool delay_tcp_race) { | 81 bool delay_tcp_race) { |
91 factory->delay_tcp_race_ = delay_tcp_race; | 82 factory->delay_tcp_race_ = delay_tcp_race; |
92 } | 83 } |
93 | 84 |
94 bool QuicStreamFactoryPeer::GetRaceCertVerification( | |
95 QuicStreamFactory* factory) { | |
96 return factory->race_cert_verification_; | |
97 } | |
98 | |
99 void QuicStreamFactoryPeer::SetRaceCertVerification( | |
100 QuicStreamFactory* factory, | |
101 bool race_cert_verification) { | |
102 factory->race_cert_verification_ = race_cert_verification; | |
103 } | |
104 | |
105 QuicAsyncStatus QuicStreamFactoryPeer::StartCertVerifyJob( | |
106 QuicStreamFactory* factory, | |
107 const QuicServerId& server_id, | |
108 int cert_verify_flags, | |
109 const BoundNetLog& net_log) { | |
110 return factory->StartCertVerifyJob(server_id, cert_verify_flags, net_log); | |
111 } | |
112 | |
113 void QuicStreamFactoryPeer::SetYieldAfterPackets(QuicStreamFactory* factory, | 85 void QuicStreamFactoryPeer::SetYieldAfterPackets(QuicStreamFactory* factory, |
114 int yield_after_packets) { | 86 int yield_after_packets) { |
115 factory->yield_after_packets_ = yield_after_packets; | 87 factory->yield_after_packets_ = yield_after_packets; |
116 } | 88 } |
117 | 89 |
118 void QuicStreamFactoryPeer::SetYieldAfterDuration( | 90 void QuicStreamFactoryPeer::SetYieldAfterDuration( |
119 QuicStreamFactory* factory, | 91 QuicStreamFactory* factory, |
120 QuicTime::Delta yield_after_duration) { | 92 QuicTime::Delta yield_after_duration) { |
121 factory->yield_after_duration_ = yield_after_duration; | 93 factory->yield_after_duration_ = yield_after_duration; |
122 } | 94 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // EXPY | 142 // EXPY |
171 0x45, 0x58, 0x50, 0x59, | 143 0x45, 0x58, 0x50, 0x59, |
172 // EXPY end offset | 144 // EXPY end offset |
173 0x08, 0x00, 0x00, 0x00, | 145 0x08, 0x00, 0x00, 0x00, |
174 // Value | 146 // Value |
175 '1', '2', '3', '4', '5', '6', '7', '8'}; | 147 '1', '2', '3', '4', '5', '6', '7', '8'}; |
176 | 148 |
177 string server_config(reinterpret_cast<const char*>(&scfg), sizeof(scfg)); | 149 string server_config(reinterpret_cast<const char*>(&scfg), sizeof(scfg)); |
178 string source_address_token("test_source_address_token"); | 150 string source_address_token("test_source_address_token"); |
179 string signature("test_signature"); | 151 string signature("test_signature"); |
180 | 152 string test_cert("test_cert"); |
181 vector<string> certs; | 153 vector<string> certs; |
182 // Load a certificate that is valid for *.example.org | 154 certs.push_back(test_cert); |
183 scoped_refptr<X509Certificate> cert( | |
184 ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem")); | |
185 DCHECK(cert); | |
186 std::string der_bytes; | |
187 DCHECK(X509Certificate::GetDEREncoded(cert->os_cert_handle(), &der_bytes)); | |
188 certs.push_back(der_bytes); | |
189 | 155 |
190 QuicCryptoClientConfig* crypto_config = &factory->crypto_config_; | 156 QuicCryptoClientConfig* crypto_config = &factory->crypto_config_; |
191 QuicCryptoClientConfig::CachedState* cached = | 157 QuicCryptoClientConfig::CachedState* cached = |
192 crypto_config->LookupOrCreate(quic_server_id); | 158 crypto_config->LookupOrCreate(quic_server_id); |
193 QuicClock clock; | 159 QuicClock clock; |
194 cached->Initialize(server_config, source_address_token, certs, "", "", | 160 cached->Initialize(server_config, source_address_token, certs, "", "", |
195 signature, clock.WallNow()); | 161 signature, clock.WallNow()); |
196 } | 162 } |
197 | 163 |
198 QuicClientPushPromiseIndex* QuicStreamFactoryPeer::GetPushPromiseIndex( | 164 QuicClientPushPromiseIndex* QuicStreamFactoryPeer::GetPushPromiseIndex( |
199 QuicStreamFactory* factory) { | 165 QuicStreamFactory* factory) { |
200 return &factory->push_promise_index_; | 166 return &factory->push_promise_index_; |
201 } | 167 } |
202 | 168 |
203 int QuicStreamFactoryPeer::GetNumPushStreamsCreated( | 169 int QuicStreamFactoryPeer::GetNumPushStreamsCreated( |
204 QuicStreamFactory* factory) { | 170 QuicStreamFactory* factory) { |
205 return factory->num_push_streams_created_; | 171 return factory->num_push_streams_created_; |
206 } | 172 } |
207 | 173 |
208 } // namespace test | 174 } // namespace test |
209 } // namespace net | 175 } // namespace net |
OLD | NEW |