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/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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 // written. Otherwise return the error code. | 241 // written. Otherwise return the error code. |
242 int result = | 242 int result = |
243 next_write.result == OK ? next_write.data_len : next_write.result; | 243 next_write.result == OK ? next_write.data_len : next_write.result; |
244 return MockWriteResult(next_write.mode, result); | 244 return MockWriteResult(next_write.mode, result); |
245 } | 245 } |
246 | 246 |
247 void StaticSocketDataProvider::Reset() { | 247 void StaticSocketDataProvider::Reset() { |
248 helper_.Reset(); | 248 helper_.Reset(); |
249 } | 249 } |
250 | 250 |
| 251 bool StaticSocketDataProvider::AllReadDataConsumed() const { |
| 252 return helper_.at_read_eof(); |
| 253 } |
| 254 |
| 255 bool StaticSocketDataProvider::AllWriteDataConsumed() const { |
| 256 return helper_.at_write_eof(); |
| 257 } |
| 258 |
251 DynamicSocketDataProvider::DynamicSocketDataProvider() | 259 DynamicSocketDataProvider::DynamicSocketDataProvider() |
252 : short_read_limit_(0), | 260 : short_read_limit_(0), |
253 allow_unconsumed_reads_(false) { | 261 allow_unconsumed_reads_(false) { |
254 } | 262 } |
255 | 263 |
256 DynamicSocketDataProvider::~DynamicSocketDataProvider() {} | 264 DynamicSocketDataProvider::~DynamicSocketDataProvider() {} |
257 | 265 |
258 MockRead DynamicSocketDataProvider::OnRead() { | 266 MockRead DynamicSocketDataProvider::OnRead() { |
259 if (reads_.empty()) | 267 if (reads_.empty()) |
260 return MockRead(SYNCHRONOUS, ERR_UNEXPECTED); | 268 return MockRead(SYNCHRONOUS, ERR_UNEXPECTED); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 } | 601 } |
594 | 602 |
595 void SequencedSocketData::Reset() { | 603 void SequencedSocketData::Reset() { |
596 helper_.Reset(); | 604 helper_.Reset(); |
597 sequence_number_ = 0; | 605 sequence_number_ = 0; |
598 read_state_ = IDLE; | 606 read_state_ = IDLE; |
599 write_state_ = IDLE; | 607 write_state_ = IDLE; |
600 weak_factory_.InvalidateWeakPtrs(); | 608 weak_factory_.InvalidateWeakPtrs(); |
601 } | 609 } |
602 | 610 |
| 611 bool SequencedSocketData::AllReadDataConsumed() const { |
| 612 return helper_.at_read_eof(); |
| 613 } |
| 614 |
| 615 bool SequencedSocketData::AllWriteDataConsumed() const { |
| 616 return helper_.at_write_eof(); |
| 617 } |
| 618 |
603 bool SequencedSocketData::at_read_eof() const { | 619 bool SequencedSocketData::at_read_eof() const { |
604 return helper_.at_read_eof(); | 620 return helper_.at_read_eof(); |
605 } | 621 } |
606 | 622 |
607 bool SequencedSocketData::at_write_eof() const { | 623 bool SequencedSocketData::at_write_eof() const { |
608 return helper_.at_read_eof(); | 624 return helper_.at_read_eof(); |
609 } | 625 } |
610 | 626 |
611 void SequencedSocketData::MaybePostReadCompleteTask() { | 627 void SequencedSocketData::MaybePostReadCompleteTask() { |
612 NET_TRACE(1, " ****** ") << " current: " << sequence_number_; | 628 NET_TRACE(1, " ****** ") << " current: " << sequence_number_; |
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2199 | 2215 |
2200 const char kSOCKS5OkRequest[] = | 2216 const char kSOCKS5OkRequest[] = |
2201 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 2217 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
2202 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 2218 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
2203 | 2219 |
2204 const char kSOCKS5OkResponse[] = | 2220 const char kSOCKS5OkResponse[] = |
2205 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 2221 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
2206 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 2222 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
2207 | 2223 |
2208 } // namespace net | 2224 } // namespace net |
OLD | NEW |