Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: net/tools/quic/test_tools/quic_test_client.cc

Issue 47283002: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compilation error Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/time/time.h" 7 #include "base/time/time.h"
8 #include "net/base/completion_callback.h" 8 #include "net/base/completion_callback.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/cert/cert_verify_result.h" 10 #include "net/cert/cert_verify_result.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return headers; 94 return headers;
95 } 95 }
96 96
97 // A quic client which allows mocking out writes. 97 // A quic client which allows mocking out writes.
98 class QuicEpollClient : public QuicClient { 98 class QuicEpollClient : public QuicClient {
99 public: 99 public:
100 typedef QuicClient Super; 100 typedef QuicClient Super;
101 101
102 QuicEpollClient(IPEndPoint server_address, 102 QuicEpollClient(IPEndPoint server_address,
103 const string& server_hostname, 103 const string& server_hostname,
104 const QuicVersion version) 104 const QuicVersionVector& supported_versions)
105 : Super(server_address, server_hostname, version, false), 105 : Super(server_address, server_hostname, supported_versions, false),
106 override_guid_(0), test_writer_(NULL) { 106 override_guid_(0), test_writer_(NULL) {
107 } 107 }
108 108
109 QuicEpollClient(IPEndPoint server_address, 109 QuicEpollClient(IPEndPoint server_address,
110 const string& server_hostname, 110 const string& server_hostname,
111 const QuicConfig& config, 111 const QuicConfig& config,
112 const QuicVersion version) 112 const QuicVersionVector& supported_versions)
113 : Super(server_address, server_hostname, config, version), 113 : Super(server_address, server_hostname, config, supported_versions),
114 override_guid_(0), test_writer_(NULL) { 114 override_guid_(0), test_writer_(NULL) {
115 } 115 }
116 116
117 virtual ~QuicEpollClient() { 117 virtual ~QuicEpollClient() {
118 if (connected()) { 118 if (connected()) {
119 Disconnect(); 119 Disconnect();
120 } 120 }
121 } 121 }
122 122
123 virtual QuicPacketWriter* CreateQuicPacketWriter() OVERRIDE { 123 virtual QuicPacketWriter* CreateQuicPacketWriter() OVERRIDE {
(...skipping 15 matching lines...) Expand all
139 void UseGuid(QuicGuid guid) { 139 void UseGuid(QuicGuid guid) {
140 override_guid_ = guid; 140 override_guid_ = guid;
141 } 141 }
142 142
143 private: 143 private:
144 QuicGuid override_guid_; // GUID to use, if nonzero 144 QuicGuid override_guid_; // GUID to use, if nonzero
145 QuicTestWriter* test_writer_; 145 QuicTestWriter* test_writer_;
146 }; 146 };
147 147
148 QuicTestClient::QuicTestClient(IPEndPoint address, const string& hostname, 148 QuicTestClient::QuicTestClient(IPEndPoint address, const string& hostname,
149 const QuicVersion version) 149 const QuicVersionVector& supported_versions)
150 : client_(new QuicEpollClient(address, hostname, version)) { 150 : client_(new QuicEpollClient(address, hostname, supported_versions)) {
151 Initialize(address, hostname, true); 151 Initialize(address, hostname, true);
152 } 152 }
153 153
154 QuicTestClient::QuicTestClient(IPEndPoint address, 154 QuicTestClient::QuicTestClient(IPEndPoint address,
155 const string& hostname, 155 const string& hostname,
156 bool secure, 156 bool secure,
157 const QuicVersion version) 157 const QuicVersionVector& supported_versions)
158 : client_(new QuicEpollClient(address, hostname, version)) { 158 : client_(new QuicEpollClient(address, hostname, supported_versions)) {
159 Initialize(address, hostname, secure); 159 Initialize(address, hostname, secure);
160 } 160 }
161 161
162 QuicTestClient::QuicTestClient(IPEndPoint address, 162 QuicTestClient::QuicTestClient(IPEndPoint address,
163 const string& hostname, 163 const string& hostname,
164 bool secure, 164 bool secure,
165 const QuicConfig& config, 165 const QuicConfig& config,
166 const QuicVersion version) 166 const QuicVersionVector& supported_versions)
167 : client_(new QuicEpollClient(address, hostname, config, version)) { 167 : client_(new QuicEpollClient(address, hostname, config,
168 supported_versions)) {
168 Initialize(address, hostname, secure); 169 Initialize(address, hostname, secure);
169 } 170 }
170 171
171 void QuicTestClient::Initialize(IPEndPoint address, 172 void QuicTestClient::Initialize(IPEndPoint address,
172 const string& hostname, 173 const string& hostname,
173 bool secure) { 174 bool secure) {
174 server_address_ = address; 175 server_address_ = address;
175 stream_ = NULL; 176 stream_ = NULL;
176 stream_error_ = QUIC_STREAM_NO_ERROR; 177 stream_error_ = QUIC_STREAM_NO_ERROR;
177 priority_ = 3; 178 priority_ = 3;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 client_->Connect(); 297 client_->Connect();
297 connect_attempted_ = true; 298 connect_attempted_ = true;
298 } 299 }
299 300
300 void QuicTestClient::ResetConnection() { 301 void QuicTestClient::ResetConnection() {
301 Disconnect(); 302 Disconnect();
302 Connect(); 303 Connect();
303 } 304 }
304 305
305 void QuicTestClient::Disconnect() { 306 void QuicTestClient::Disconnect() {
306 client_->Disconnect(); 307 if (client_->connected()) {
308 client_->Disconnect();
309 }
307 connect_attempted_ = false; 310 connect_attempted_ = false;
308 } 311 }
309 312
310 IPEndPoint QuicTestClient::LocalSocketAddress() const { 313 IPEndPoint QuicTestClient::LocalSocketAddress() const {
311 return client_->client_address(); 314 return client_->client_address();
312 } 315 }
313 316
314 void QuicTestClient::ClearPerRequestState() { 317 void QuicTestClient::ClearPerRequestState() {
315 stream_error_ = QUIC_STREAM_NO_ERROR; 318 stream_error_ = QUIC_STREAM_NO_ERROR;
316 stream_ = NULL; 319 stream_ = NULL;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 399 }
397 400
398 void QuicTestClient::UseGuid(QuicGuid guid) { 401 void QuicTestClient::UseGuid(QuicGuid guid) {
399 DCHECK(!connected()); 402 DCHECK(!connected());
400 reinterpret_cast<QuicEpollClient*>(client_.get())->UseGuid(guid); 403 reinterpret_cast<QuicEpollClient*>(client_.get())->UseGuid(guid);
401 } 404 }
402 405
403 } // namespace test 406 } // namespace test
404 } // namespace tools 407 } // namespace tools
405 } // namespace net 408 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/quic_test_client.h ('k') | net/tools/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698