OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ | 5 #ifndef REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ |
6 #define REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ | 6 #define REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 // Returns all data written to the socket. | 39 // Returns all data written to the socket. |
40 const std::string& written_data() const { return written_data_; } | 40 const std::string& written_data() const { return written_data_; } |
41 | 41 |
42 // Sets maximum number of bytes written by each Write() call. | 42 // Sets maximum number of bytes written by each Write() call. |
43 void set_write_limit(int write_limit) { write_limit_ = write_limit; } | 43 void set_write_limit(int write_limit) { write_limit_ = write_limit; } |
44 | 44 |
45 // Enables asynchronous Write(). | 45 // Enables asynchronous Write(). |
46 void set_async_write(bool async_write) { async_write_ = async_write; } | 46 void set_async_write(bool async_write) { async_write_ = async_write; } |
47 | 47 |
48 // Set error codes for the next Read() and Write() calls. Once returned the | 48 // Set error codes for the next Write() call. Once returned the |
49 // values are automatically reset to net::OK . | 49 // value is automatically reset to net::OK . |
50 void set_next_read_error(int error) { next_read_error_ = error; } | |
51 void set_next_write_error(int error) { next_write_error_ = error; } | 50 void set_next_write_error(int error) { next_write_error_ = error; } |
52 | 51 |
53 // Appends |data| to the read buffer. | 52 // Appends |data| to the read buffer. |
54 void AppendInputData(const std::string& data); | 53 void AppendInputData(const std::string& data); |
55 | 54 |
| 55 // Causes Read() to fail with |error| once the read buffer is exhausted. If |
| 56 // there is a currently pending Read, it is interrupted. |
| 57 void AppendReadError(int error); |
| 58 |
56 // Pairs the socket with |peer_socket|. Deleting either of the paired sockets | 59 // Pairs the socket with |peer_socket|. Deleting either of the paired sockets |
57 // unpairs them. | 60 // unpairs them. |
58 void PairWith(FakeStreamSocket* peer_socket); | 61 void PairWith(FakeStreamSocket* peer_socket); |
59 | 62 |
60 // Current input position in bytes. | 63 // Current input position in bytes. |
61 int input_pos() const { return input_pos_; } | 64 int input_pos() const { return input_pos_; } |
62 | 65 |
63 // True if a Read() call is currently pending. | 66 // True if a Read() call is currently pending. |
64 bool read_pending() const { return !read_callback_.is_null(); } | 67 bool read_pending() const { return !read_callback_.is_null(); } |
65 | 68 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 154 |
152 base::WeakPtrFactory<FakeStreamChannelFactory> weak_factory_; | 155 base::WeakPtrFactory<FakeStreamChannelFactory> weak_factory_; |
153 | 156 |
154 DISALLOW_COPY_AND_ASSIGN(FakeStreamChannelFactory); | 157 DISALLOW_COPY_AND_ASSIGN(FakeStreamChannelFactory); |
155 }; | 158 }; |
156 | 159 |
157 } // namespace protocol | 160 } // namespace protocol |
158 } // namespace remoting | 161 } // namespace remoting |
159 | 162 |
160 #endif // REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ | 163 #endif // REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ |
OLD | NEW |