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 #ifndef REMOTING_PROTOCOL_FAKE_SESSION_H_ | 5 #ifndef REMOTING_PROTOCOL_FAKE_SESSION_H_ |
6 #define REMOTING_PROTOCOL_FAKE_SESSION_H_ | 6 #define REMOTING_PROTOCOL_FAKE_SESSION_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 22 matching lines...) Expand all Loading... |
33 // PairWith() method, e.g.: a->PairWith(b). After this all data | 33 // PairWith() method, e.g.: a->PairWith(b). After this all data |
34 // written to |a| can be read from |b| and vica versa. Two connected | 34 // written to |a| can be read from |b| and vica versa. Two connected |
35 // sockets |a| and |b| must be created and used on the same thread. | 35 // sockets |a| and |b| must be created and used on the same thread. |
36 class FakeSocket : public net::StreamSocket { | 36 class FakeSocket : public net::StreamSocket { |
37 public: | 37 public: |
38 FakeSocket(); | 38 FakeSocket(); |
39 virtual ~FakeSocket(); | 39 virtual ~FakeSocket(); |
40 | 40 |
41 const std::string& written_data() const { return written_data_; } | 41 const std::string& written_data() const { return written_data_; } |
42 | 42 |
| 43 void set_next_read_error(int error) { next_read_error_ = error; } |
43 void AppendInputData(const std::vector<char>& data); | 44 void AppendInputData(const std::vector<char>& data); |
44 void PairWith(FakeSocket* peer_socket); | 45 void PairWith(FakeSocket* peer_socket); |
45 int input_pos() const { return input_pos_; } | 46 int input_pos() const { return input_pos_; } |
46 bool read_pending() const { return read_pending_; } | 47 bool read_pending() const { return read_pending_; } |
47 | 48 |
48 // net::Socket implementation. | 49 // net::Socket implementation. |
49 virtual int Read(net::IOBuffer* buf, int buf_len, | 50 virtual int Read(net::IOBuffer* buf, int buf_len, |
50 const net::CompletionCallback& callback) OVERRIDE; | 51 const net::CompletionCallback& callback) OVERRIDE; |
51 virtual int Write(net::IOBuffer* buf, int buf_len, | 52 virtual int Write(net::IOBuffer* buf, int buf_len, |
52 const net::CompletionCallback& callback) OVERRIDE; | 53 const net::CompletionCallback& callback) OVERRIDE; |
(...skipping 11 matching lines...) Expand all Loading... |
64 virtual const net::BoundNetLog& NetLog() const OVERRIDE; | 65 virtual const net::BoundNetLog& NetLog() const OVERRIDE; |
65 virtual void SetSubresourceSpeculation() OVERRIDE; | 66 virtual void SetSubresourceSpeculation() OVERRIDE; |
66 virtual void SetOmniboxSpeculation() OVERRIDE; | 67 virtual void SetOmniboxSpeculation() OVERRIDE; |
67 virtual bool WasEverUsed() const OVERRIDE; | 68 virtual bool WasEverUsed() const OVERRIDE; |
68 virtual bool UsingTCPFastOpen() const OVERRIDE; | 69 virtual bool UsingTCPFastOpen() const OVERRIDE; |
69 virtual int64 NumBytesRead() const OVERRIDE; | 70 virtual int64 NumBytesRead() const OVERRIDE; |
70 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; | 71 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; |
71 virtual net::NextProto GetNegotiatedProtocol() const OVERRIDE; | 72 virtual net::NextProto GetNegotiatedProtocol() const OVERRIDE; |
72 | 73 |
73 private: | 74 private: |
| 75 int next_read_error_; |
74 bool read_pending_; | 76 bool read_pending_; |
75 scoped_refptr<net::IOBuffer> read_buffer_; | 77 scoped_refptr<net::IOBuffer> read_buffer_; |
76 int read_buffer_size_; | 78 int read_buffer_size_; |
77 net::CompletionCallback read_callback_; | 79 net::CompletionCallback read_callback_; |
78 base::WeakPtr<FakeSocket> peer_socket_; | 80 base::WeakPtr<FakeSocket> peer_socket_; |
79 | 81 |
80 std::string written_data_; | 82 std::string written_data_; |
81 std::string input_data_; | 83 std::string input_data_; |
82 int input_pos_; | 84 int input_pos_; |
83 | 85 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 ErrorCode error_; | 184 ErrorCode error_; |
183 bool closed_; | 185 bool closed_; |
184 | 186 |
185 DISALLOW_COPY_AND_ASSIGN(FakeSession); | 187 DISALLOW_COPY_AND_ASSIGN(FakeSession); |
186 }; | 188 }; |
187 | 189 |
188 } // namespace protocol | 190 } // namespace protocol |
189 } // namespace remoting | 191 } // namespace remoting |
190 | 192 |
191 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ | 193 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ |
OLD | NEW |