| 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 | |
| 259 DynamicSocketDataProvider::DynamicSocketDataProvider() | 251 DynamicSocketDataProvider::DynamicSocketDataProvider() |
| 260 : short_read_limit_(0), | 252 : short_read_limit_(0), |
| 261 allow_unconsumed_reads_(false) { | 253 allow_unconsumed_reads_(false) { |
| 262 } | 254 } |
| 263 | 255 |
| 264 DynamicSocketDataProvider::~DynamicSocketDataProvider() {} | 256 DynamicSocketDataProvider::~DynamicSocketDataProvider() {} |
| 265 | 257 |
| 266 MockRead DynamicSocketDataProvider::OnRead() { | 258 MockRead DynamicSocketDataProvider::OnRead() { |
| 267 if (reads_.empty()) | 259 if (reads_.empty()) |
| 268 return MockRead(SYNCHRONOUS, ERR_UNEXPECTED); | 260 return MockRead(SYNCHRONOUS, ERR_UNEXPECTED); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 } | 593 } |
| 602 | 594 |
| 603 void SequencedSocketData::Reset() { | 595 void SequencedSocketData::Reset() { |
| 604 helper_.Reset(); | 596 helper_.Reset(); |
| 605 sequence_number_ = 0; | 597 sequence_number_ = 0; |
| 606 read_state_ = IDLE; | 598 read_state_ = IDLE; |
| 607 write_state_ = IDLE; | 599 write_state_ = IDLE; |
| 608 weak_factory_.InvalidateWeakPtrs(); | 600 weak_factory_.InvalidateWeakPtrs(); |
| 609 } | 601 } |
| 610 | 602 |
| 611 bool SequencedSocketData::AllReadDataConsumed() const { | 603 bool SequencedSocketData::at_read_eof() const { |
| 612 return helper_.at_read_eof(); | 604 return helper_.at_read_eof(); |
| 613 } | 605 } |
| 614 | 606 |
| 615 bool SequencedSocketData::AllWriteDataConsumed() const { | 607 bool SequencedSocketData::at_write_eof() const { |
| 616 return helper_.at_write_eof(); | 608 return helper_.at_read_eof(); |
| 617 } | 609 } |
| 618 | 610 |
| 619 void SequencedSocketData::MaybePostReadCompleteTask() { | 611 void SequencedSocketData::MaybePostReadCompleteTask() { |
| 620 NET_TRACE(1, " ****** ") << " current: " << sequence_number_; | 612 NET_TRACE(1, " ****** ") << " current: " << sequence_number_; |
| 621 // Only trigger the next read to complete if there is already a read pending | 613 // Only trigger the next read to complete if there is already a read pending |
| 622 // which should complete at the current sequence number. | 614 // which should complete at the current sequence number. |
| 623 if (read_state_ != PENDING || | 615 if (read_state_ != PENDING || |
| 624 helper_.PeekRead().sequence_number != sequence_number_) { | 616 helper_.PeekRead().sequence_number != sequence_number_) { |
| 625 return; | 617 return; |
| 626 } | 618 } |
| (...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 | 2179 |
| 2188 const char kSOCKS5OkRequest[] = | 2180 const char kSOCKS5OkRequest[] = |
| 2189 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 2181 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
| 2190 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 2182 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
| 2191 | 2183 |
| 2192 const char kSOCKS5OkResponse[] = | 2184 const char kSOCKS5OkResponse[] = |
| 2193 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 2185 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
| 2194 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 2186 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
| 2195 | 2187 |
| 2196 } // namespace net | 2188 } // namespace net |
| OLD | NEW |