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/tools/quic/test_tools/quic_test_client.h" | 5 #include "net/tools/quic/test_tools/quic_test_client.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/time/time.h" | 9 #include "base/time/time.h" |
8 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
9 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
10 #include "net/cert/cert_verify_result.h" | 12 #include "net/cert/cert_verify_result.h" |
11 #include "net/cert/x509_certificate.h" | 13 #include "net/cert/x509_certificate.h" |
12 #include "net/quic/crypto/proof_verifier.h" | 14 #include "net/quic/crypto/proof_verifier.h" |
13 #include "net/quic/quic_flags.h" | 15 #include "net/quic/quic_flags.h" |
14 #include "net/quic/quic_server_id.h" | 16 #include "net/quic/quic_server_id.h" |
15 #include "net/quic/test_tools/quic_connection_peer.h" | 17 #include "net/quic/test_tools/quic_connection_peer.h" |
16 #include "net/quic/test_tools/quic_spdy_session_peer.h" | 18 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 const string& server_hostname, | 179 const string& server_hostname, |
178 const QuicConfig& config, | 180 const QuicConfig& config, |
179 const QuicVersionVector& supported_versions) | 181 const QuicVersionVector& supported_versions) |
180 : client_(new MockableQuicClient(server_address, | 182 : client_(new MockableQuicClient(server_address, |
181 QuicServerId(server_hostname, | 183 QuicServerId(server_hostname, |
182 server_address.port(), | 184 server_address.port(), |
183 PRIVACY_MODE_DISABLED), | 185 PRIVACY_MODE_DISABLED), |
184 config, | 186 config, |
185 supported_versions, | 187 supported_versions, |
186 &epoll_server_)), | 188 &epoll_server_)), |
187 allow_bidirectional_data_(false), | 189 allow_bidirectional_data_(false) { |
188 num_requests_(0), | |
189 num_responses_(0) { | |
190 Initialize(); | 190 Initialize(); |
191 } | 191 } |
192 | 192 |
193 QuicTestClient::QuicTestClient() : allow_bidirectional_data_(false) {} | 193 QuicTestClient::QuicTestClient() : allow_bidirectional_data_(false) {} |
194 | 194 |
195 QuicTestClient::~QuicTestClient() { | 195 QuicTestClient::~QuicTestClient() { |
196 if (stream_) { | 196 if (stream_) { |
197 stream_->set_visitor(nullptr); | 197 stream_->set_visitor(nullptr); |
198 } | 198 } |
199 client_->Disconnect(); | 199 client_->Disconnect(); |
200 } | 200 } |
201 | 201 |
202 void QuicTestClient::Initialize() { | 202 void QuicTestClient::Initialize() { |
203 priority_ = 3; | 203 priority_ = 3; |
204 connect_attempted_ = false; | 204 connect_attempted_ = false; |
205 auto_reconnect_ = false; | 205 auto_reconnect_ = false; |
206 buffer_body_ = true; | 206 buffer_body_ = true; |
| 207 num_requests_ = 0; |
| 208 num_responses_ = 0; |
207 ClearPerRequestState(); | 209 ClearPerRequestState(); |
208 // As chrome will generally do this, we want it to be the default when it's | 210 // As chrome will generally do this, we want it to be the default when it's |
209 // not overridden. | 211 // not overridden. |
210 if (!client_->config()->HasSetBytesForConnectionIdToSend()) { | 212 if (!client_->config()->HasSetBytesForConnectionIdToSend()) { |
211 client_->config()->SetBytesForConnectionIdToSend(0); | 213 client_->config()->SetBytesForConnectionIdToSend(0); |
212 } | 214 } |
213 } | 215 } |
214 | 216 |
215 void QuicTestClient::SetUserAgentID(const string& user_agent_id) { | 217 void QuicTestClient::SetUserAgentID(const string& user_agent_id) { |
216 client_->SetUserAgentID(user_agent_id); | 218 client_->SetUserAgentID(user_agent_id); |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 CHECK(message); | 669 CHECK(message); |
668 message->headers()->SetRequestVersion( | 670 message->headers()->SetRequestVersion( |
669 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1)); | 671 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1)); |
670 message->headers()->SetRequestMethod( | 672 message->headers()->SetRequestMethod( |
671 HTTPMessage::MethodToString(HttpConstants::GET)); | 673 HTTPMessage::MethodToString(HttpConstants::GET)); |
672 message->headers()->SetRequestUri(uri); | 674 message->headers()->SetRequestUri(uri); |
673 } | 675 } |
674 | 676 |
675 } // namespace test | 677 } // namespace test |
676 } // namespace net | 678 } // namespace net |
OLD | NEW |