OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 | 11 |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "net/base/completion_callback.h" |
13 #include "net/socket/socket.h" | 14 #include "net/socket/socket.h" |
14 #include "net/socket/stream_socket.h" | 15 #include "net/socket/stream_socket.h" |
15 #include "remoting/protocol/session.h" | 16 #include "remoting/protocol/session.h" |
16 | 17 |
17 class MessageLoop; | 18 class MessageLoop; |
18 | 19 |
19 namespace remoting { | 20 namespace remoting { |
20 namespace protocol { | 21 namespace protocol { |
21 | 22 |
22 extern const char kTestJid[]; | 23 extern const char kTestJid[]; |
(...skipping 10 matching lines...) Expand all Loading... |
33 | 34 |
34 const std::string& written_data() const { return written_data_; } | 35 const std::string& written_data() const { return written_data_; } |
35 | 36 |
36 void AppendInputData(const char* data, int data_size); | 37 void AppendInputData(const char* data, int data_size); |
37 int input_pos() const { return input_pos_; } | 38 int input_pos() const { return input_pos_; } |
38 bool read_pending() const { return read_pending_; } | 39 bool read_pending() const { return read_pending_; } |
39 | 40 |
40 // net::Socket implementation. | 41 // net::Socket implementation. |
41 virtual int Read(net::IOBuffer* buf, int buf_len, | 42 virtual int Read(net::IOBuffer* buf, int buf_len, |
42 net::OldCompletionCallback* callback) OVERRIDE; | 43 net::OldCompletionCallback* callback) OVERRIDE; |
| 44 virtual int Read(net::IOBuffer* buf, int buf_len, |
| 45 const net::CompletionCallback& callback) OVERRIDE; |
43 virtual int Write(net::IOBuffer* buf, int buf_len, | 46 virtual int Write(net::IOBuffer* buf, int buf_len, |
44 net::OldCompletionCallback* callback) OVERRIDE; | 47 net::OldCompletionCallback* callback) OVERRIDE; |
45 | 48 |
46 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; | 49 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; |
47 virtual bool SetSendBufferSize(int32 size) OVERRIDE; | 50 virtual bool SetSendBufferSize(int32 size) OVERRIDE; |
48 | 51 |
49 // net::StreamSocket implementation. | 52 // net::StreamSocket implementation. |
50 virtual int Connect(net::OldCompletionCallback* callback) OVERRIDE; | 53 virtual int Connect(net::OldCompletionCallback* callback) OVERRIDE; |
51 virtual int Connect(const net::CompletionCallback& callback) OVERRIDE; | 54 virtual int Connect(const net::CompletionCallback& callback) OVERRIDE; |
52 virtual void Disconnect() OVERRIDE; | 55 virtual void Disconnect() OVERRIDE; |
53 virtual bool IsConnected() const OVERRIDE; | 56 virtual bool IsConnected() const OVERRIDE; |
54 virtual bool IsConnectedAndIdle() const OVERRIDE; | 57 virtual bool IsConnectedAndIdle() const OVERRIDE; |
55 virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE; | 58 virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE; |
56 virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE; | 59 virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE; |
57 virtual const net::BoundNetLog& NetLog() const OVERRIDE; | 60 virtual const net::BoundNetLog& NetLog() const OVERRIDE; |
58 virtual void SetSubresourceSpeculation() OVERRIDE; | 61 virtual void SetSubresourceSpeculation() OVERRIDE; |
59 virtual void SetOmniboxSpeculation() OVERRIDE; | 62 virtual void SetOmniboxSpeculation() OVERRIDE; |
60 virtual bool WasEverUsed() const OVERRIDE; | 63 virtual bool WasEverUsed() const OVERRIDE; |
61 virtual bool UsingTCPFastOpen() const OVERRIDE; | 64 virtual bool UsingTCPFastOpen() const OVERRIDE; |
62 virtual int64 NumBytesRead() const OVERRIDE; | 65 virtual int64 NumBytesRead() const OVERRIDE; |
63 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; | 66 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; |
64 | 67 |
65 private: | 68 private: |
66 bool read_pending_; | 69 bool read_pending_; |
67 scoped_refptr<net::IOBuffer> read_buffer_; | 70 scoped_refptr<net::IOBuffer> read_buffer_; |
68 int read_buffer_size_; | 71 int read_buffer_size_; |
69 net::OldCompletionCallback* read_callback_; | 72 net::OldCompletionCallback* old_read_callback_; |
| 73 net::CompletionCallback read_callback_; |
70 | 74 |
71 std::string written_data_; | 75 std::string written_data_; |
72 std::string input_data_; | 76 std::string input_data_; |
73 int input_pos_; | 77 int input_pos_; |
74 | 78 |
75 net::BoundNetLog net_log_; | 79 net::BoundNetLog net_log_; |
76 | 80 |
77 MessageLoop* message_loop_; | 81 MessageLoop* message_loop_; |
78 | 82 |
79 DISALLOW_COPY_AND_ASSIGN(FakeSocket); | 83 DISALLOW_COPY_AND_ASSIGN(FakeSocket); |
(...skipping 10 matching lines...) Expand all Loading... |
90 const std::vector<std::string>& written_packets() const { | 94 const std::vector<std::string>& written_packets() const { |
91 return written_packets_; | 95 return written_packets_; |
92 } | 96 } |
93 | 97 |
94 void AppendInputPacket(const char* data, int data_size); | 98 void AppendInputPacket(const char* data, int data_size); |
95 int input_pos() const { return input_pos_; } | 99 int input_pos() const { return input_pos_; } |
96 | 100 |
97 // net::Socket implementation. | 101 // net::Socket implementation. |
98 virtual int Read(net::IOBuffer* buf, int buf_len, | 102 virtual int Read(net::IOBuffer* buf, int buf_len, |
99 net::OldCompletionCallback* callback) OVERRIDE; | 103 net::OldCompletionCallback* callback) OVERRIDE; |
| 104 virtual int Read(net::IOBuffer* buf, int buf_len, |
| 105 const net::CompletionCallback& callback) OVERRIDE; |
100 virtual int Write(net::IOBuffer* buf, int buf_len, | 106 virtual int Write(net::IOBuffer* buf, int buf_len, |
101 net::OldCompletionCallback* callback) OVERRIDE; | 107 net::OldCompletionCallback* callback) OVERRIDE; |
102 | 108 |
103 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; | 109 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; |
104 virtual bool SetSendBufferSize(int32 size) OVERRIDE; | 110 virtual bool SetSendBufferSize(int32 size) OVERRIDE; |
105 | 111 |
106 private: | 112 private: |
107 bool read_pending_; | 113 bool read_pending_; |
108 scoped_refptr<net::IOBuffer> read_buffer_; | 114 scoped_refptr<net::IOBuffer> read_buffer_; |
109 int read_buffer_size_; | 115 int read_buffer_size_; |
110 net::OldCompletionCallback* read_callback_; | 116 net::OldCompletionCallback* old_read_callback_; |
| 117 net::CompletionCallback read_callback_; |
111 | 118 |
112 std::vector<std::string> written_packets_; | 119 std::vector<std::string> written_packets_; |
113 std::vector<std::string> input_packets_; | 120 std::vector<std::string> input_packets_; |
114 int input_pos_; | 121 int input_pos_; |
115 | 122 |
116 MessageLoop* message_loop_; | 123 MessageLoop* message_loop_; |
117 | 124 |
118 DISALLOW_COPY_AND_ASSIGN(FakeUdpSocket); | 125 DISALLOW_COPY_AND_ASSIGN(FakeUdpSocket); |
119 }; | 126 }; |
120 | 127 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 Session::Error error_; | 180 Session::Error error_; |
174 bool closed_; | 181 bool closed_; |
175 | 182 |
176 DISALLOW_COPY_AND_ASSIGN(FakeSession); | 183 DISALLOW_COPY_AND_ASSIGN(FakeSession); |
177 }; | 184 }; |
178 | 185 |
179 } // namespace protocol | 186 } // namespace protocol |
180 } // namespace remoting | 187 } // namespace remoting |
181 | 188 |
182 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ | 189 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ |
OLD | NEW |