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 void QuicStreamFactoryPeer::StartCertVerifyJob(QuicStreamFactory* factory, | |
106 const QuicServerId& server_id, | |
107 int cert_verify_flags, | |
108 const BoundNetLog& net_log) { | |
109 factory->StartCertVerifyJob(server_id, cert_verify_flags, net_log); | |
110 } | |
111 | |
112 void QuicStreamFactoryPeer::SetYieldAfterPackets(QuicStreamFactory* factory, | 85 void QuicStreamFactoryPeer::SetYieldAfterPackets(QuicStreamFactory* factory, |
113 int yield_after_packets) { | 86 int yield_after_packets) { |
114 factory->yield_after_packets_ = yield_after_packets; | 87 factory->yield_after_packets_ = yield_after_packets; |
115 } | 88 } |
116 | 89 |
117 void QuicStreamFactoryPeer::SetYieldAfterDuration( | 90 void QuicStreamFactoryPeer::SetYieldAfterDuration( |
118 QuicStreamFactory* factory, | 91 QuicStreamFactory* factory, |
119 QuicTime::Delta yield_after_duration) { | 92 QuicTime::Delta yield_after_duration) { |
120 factory->yield_after_duration_ = yield_after_duration; | 93 factory->yield_after_duration_ = yield_after_duration; |
121 } | 94 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // EXPY | 142 // EXPY |
170 0x45, 0x58, 0x50, 0x59, | 143 0x45, 0x58, 0x50, 0x59, |
171 // EXPY end offset | 144 // EXPY end offset |
172 0x08, 0x00, 0x00, 0x00, | 145 0x08, 0x00, 0x00, 0x00, |
173 // Value | 146 // Value |
174 '1', '2', '3', '4', '5', '6', '7', '8'}; | 147 '1', '2', '3', '4', '5', '6', '7', '8'}; |
175 | 148 |
176 string server_config(reinterpret_cast<const char*>(&scfg), sizeof(scfg)); | 149 string server_config(reinterpret_cast<const char*>(&scfg), sizeof(scfg)); |
177 string source_address_token("test_source_address_token"); | 150 string source_address_token("test_source_address_token"); |
178 string signature("test_signature"); | 151 string signature("test_signature"); |
179 | 152 string test_cert("test_cert"); |
180 vector<string> certs; | 153 vector<string> certs; |
181 // Load a certificate that is valid for *.example.org | 154 certs.push_back(test_cert); |
182 scoped_refptr<X509Certificate> cert( | |
183 ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem")); | |
184 DCHECK(cert); | |
185 std::string der_bytes; | |
186 DCHECK(X509Certificate::GetDEREncoded(cert->os_cert_handle(), &der_bytes)); | |
187 certs.push_back(der_bytes); | |
188 | 155 |
189 QuicCryptoClientConfig* crypto_config = &factory->crypto_config_; | 156 QuicCryptoClientConfig* crypto_config = &factory->crypto_config_; |
190 QuicCryptoClientConfig::CachedState* cached = | 157 QuicCryptoClientConfig::CachedState* cached = |
191 crypto_config->LookupOrCreate(quic_server_id); | 158 crypto_config->LookupOrCreate(quic_server_id); |
192 QuicClock clock; | 159 QuicClock clock; |
193 cached->Initialize(server_config, source_address_token, certs, "", "", | 160 cached->Initialize(server_config, source_address_token, certs, "", "", |
194 signature, clock.WallNow()); | 161 signature, clock.WallNow()); |
195 } | 162 } |
196 | 163 |
197 QuicClientPushPromiseIndex* QuicStreamFactoryPeer::GetPushPromiseIndex( | 164 QuicClientPushPromiseIndex* QuicStreamFactoryPeer::GetPushPromiseIndex( |
198 QuicStreamFactory* factory) { | 165 QuicStreamFactory* factory) { |
199 return &factory->push_promise_index_; | 166 return &factory->push_promise_index_; |
200 } | 167 } |
201 | 168 |
202 int QuicStreamFactoryPeer::GetNumPushStreamsCreated( | 169 int QuicStreamFactoryPeer::GetNumPushStreamsCreated( |
203 QuicStreamFactory* factory) { | 170 QuicStreamFactory* factory) { |
204 return factory->num_push_streams_created_; | 171 return factory->num_push_streams_created_; |
205 } | 172 } |
206 | 173 |
207 } // namespace test | 174 } // namespace test |
208 } // namespace net | 175 } // namespace net |
OLD | NEW |