| 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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 } | 593 } |
| 594 | 594 |
| 595 void SequencedSocketData::Reset() { | 595 void SequencedSocketData::Reset() { |
| 596 helper_.Reset(); | 596 helper_.Reset(); |
| 597 sequence_number_ = 0; | 597 sequence_number_ = 0; |
| 598 read_state_ = IDLE; | 598 read_state_ = IDLE; |
| 599 write_state_ = IDLE; | 599 write_state_ = IDLE; |
| 600 weak_factory_.InvalidateWeakPtrs(); | 600 weak_factory_.InvalidateWeakPtrs(); |
| 601 } | 601 } |
| 602 | 602 |
| 603 bool SequencedSocketData::WasDataWritten() const { |
| 604 return helper_.write_index() > 0 || write_state_ != IDLE; |
| 605 } |
| 606 |
| 603 bool SequencedSocketData::at_read_eof() const { | 607 bool SequencedSocketData::at_read_eof() const { |
| 604 return helper_.at_read_eof(); | 608 return helper_.at_read_eof(); |
| 605 } | 609 } |
| 606 | 610 |
| 607 bool SequencedSocketData::at_write_eof() const { | 611 bool SequencedSocketData::at_write_eof() const { |
| 608 return helper_.at_read_eof(); | 612 return helper_.at_read_eof(); |
| 609 } | 613 } |
| 610 | 614 |
| 611 void SequencedSocketData::MaybePostReadCompleteTask() { | 615 void SequencedSocketData::MaybePostReadCompleteTask() { |
| 612 NET_TRACE(1, " ****** ") << " current: " << sequence_number_; | 616 NET_TRACE(1, " ****** ") << " current: " << sequence_number_; |
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 source_port_(123), | 1699 source_port_(123), |
| 1696 pending_read_buf_(NULL), | 1700 pending_read_buf_(NULL), |
| 1697 pending_read_buf_len_(0), | 1701 pending_read_buf_len_(0), |
| 1698 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_NONE)), | 1702 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_NONE)), |
| 1699 weak_factory_(this) { | 1703 weak_factory_(this) { |
| 1700 DCHECK(data_); | 1704 DCHECK(data_); |
| 1701 data_->Reset(); | 1705 data_->Reset(); |
| 1702 peer_addr_ = data->connect_data().peer_addr; | 1706 peer_addr_ = data->connect_data().peer_addr; |
| 1703 } | 1707 } |
| 1704 | 1708 |
| 1705 MockUDPClientSocket::~MockUDPClientSocket() {} | 1709 MockUDPClientSocket::~MockUDPClientSocket() { |
| 1710 data_->set_socket(nullptr); |
| 1711 } |
| 1706 | 1712 |
| 1707 int MockUDPClientSocket::Read(IOBuffer* buf, | 1713 int MockUDPClientSocket::Read(IOBuffer* buf, |
| 1708 int buf_len, | 1714 int buf_len, |
| 1709 const CompletionCallback& callback) { | 1715 const CompletionCallback& callback) { |
| 1710 if (!connected_) | 1716 if (!connected_) |
| 1711 return ERR_UNEXPECTED; | 1717 return ERR_UNEXPECTED; |
| 1712 | 1718 |
| 1713 // If the buffer is already in use, a read is already in progress! | 1719 // If the buffer is already in use, a read is already in progress! |
| 1714 DCHECK(pending_read_buf_.get() == NULL); | 1720 DCHECK(pending_read_buf_.get() == NULL); |
| 1715 | 1721 |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 | 2185 |
| 2180 const char kSOCKS5OkRequest[] = | 2186 const char kSOCKS5OkRequest[] = |
| 2181 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 2187 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
| 2182 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 2188 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
| 2183 | 2189 |
| 2184 const char kSOCKS5OkResponse[] = | 2190 const char kSOCKS5OkResponse[] = |
| 2185 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 2191 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
| 2186 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 2192 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
| 2187 | 2193 |
| 2188 } // namespace net | 2194 } // namespace net |
| OLD | NEW |