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

Side by Side Diff: net/socket/socket_test_util.cc

Issue 1137183005: Remove DynamicSocketDataProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 7 months 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
« no previous file with comments | « net/socket/socket_test_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/socket/socket_test_util.h" 5 #include "net/socket/socket_test_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 250 }
251 251
252 bool StaticSocketDataProvider::AllReadDataConsumed() const { 252 bool StaticSocketDataProvider::AllReadDataConsumed() const {
253 return helper_.at_read_eof(); 253 return helper_.at_read_eof();
254 } 254 }
255 255
256 bool StaticSocketDataProvider::AllWriteDataConsumed() const { 256 bool StaticSocketDataProvider::AllWriteDataConsumed() const {
257 return helper_.at_write_eof(); 257 return helper_.at_write_eof();
258 } 258 }
259 259
260 DynamicSocketDataProvider::DynamicSocketDataProvider()
261 : short_read_limit_(0),
262 allow_unconsumed_reads_(false) {
263 }
264
265 DynamicSocketDataProvider::~DynamicSocketDataProvider() {}
266
267 MockRead DynamicSocketDataProvider::OnRead() {
268 if (reads_.empty())
269 return MockRead(SYNCHRONOUS, ERR_UNEXPECTED);
270 MockRead result = reads_.front();
271 if (short_read_limit_ == 0 || result.data_len <= short_read_limit_) {
272 reads_.pop_front();
273 } else {
274 result.data_len = short_read_limit_;
275 reads_.front().data += result.data_len;
276 reads_.front().data_len -= result.data_len;
277 }
278 return result;
279 }
280
281 void DynamicSocketDataProvider::Reset() {
282 reads_.clear();
283 }
284
285 void DynamicSocketDataProvider::SimulateRead(const char* data,
286 const size_t length) {
287 if (!allow_unconsumed_reads_) {
288 EXPECT_TRUE(reads_.empty()) << "Unconsumed read: " << reads_.front().data;
289 }
290 reads_.push_back(MockRead(ASYNC, data, length));
291 }
292
293 SSLSocketDataProvider::SSLSocketDataProvider(IoMode mode, int result) 260 SSLSocketDataProvider::SSLSocketDataProvider(IoMode mode, int result)
294 : connect(mode, result), 261 : connect(mode, result),
295 next_proto_status(SSLClientSocket::kNextProtoUnsupported), 262 next_proto_status(SSLClientSocket::kNextProtoUnsupported),
296 client_cert_sent(false), 263 client_cert_sent(false),
297 cert_request_info(NULL), 264 cert_request_info(NULL),
298 channel_id_sent(false), 265 channel_id_sent(false),
299 connection_status(0) { 266 connection_status(0) {
300 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_TLS1_2, 267 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_TLS1_2,
301 &connection_status); 268 &connection_status);
302 // Set to TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 269 // Set to TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305
(...skipping 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after
2150 2117
2151 const char kSOCKS5OkRequest[] = 2118 const char kSOCKS5OkRequest[] =
2152 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; 2119 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 };
2153 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); 2120 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest);
2154 2121
2155 const char kSOCKS5OkResponse[] = 2122 const char kSOCKS5OkResponse[] =
2156 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; 2123 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 };
2157 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); 2124 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse);
2158 2125
2159 } // namespace net 2126 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socket_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698