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 CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "content/common/p2p_messages.h" | 10 #include "content/common/p2p_messages.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 void SetPeerAddress(const net::IPEndPoint& peer_address); | 55 void SetPeerAddress(const net::IPEndPoint& peer_address); |
56 void SetLocalAddress(const net::IPEndPoint& local_address); | 56 void SetLocalAddress(const net::IPEndPoint& local_address); |
57 | 57 |
58 // net::Socket implementation. | 58 // net::Socket implementation. |
59 virtual int Read(net::IOBuffer* buf, int buf_len, | 59 virtual int Read(net::IOBuffer* buf, int buf_len, |
60 net::OldCompletionCallback* callback) OVERRIDE; | 60 net::OldCompletionCallback* callback) OVERRIDE; |
61 virtual int Read(net::IOBuffer* buf, int buf_len, | 61 virtual int Read(net::IOBuffer* buf, int buf_len, |
62 const net::CompletionCallback& callback) OVERRIDE; | 62 const net::CompletionCallback& callback) OVERRIDE; |
63 virtual int Write(net::IOBuffer* buf, int buf_len, | 63 virtual int Write(net::IOBuffer* buf, int buf_len, |
64 net::OldCompletionCallback* callback) OVERRIDE; | 64 net::OldCompletionCallback* callback) OVERRIDE; |
| 65 virtual int Write(net::IOBuffer* buf, int buf_len, |
| 66 const net::CompletionCallback& callback) OVERRIDE; |
65 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; | 67 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; |
66 virtual bool SetSendBufferSize(int32 size) OVERRIDE; | 68 virtual bool SetSendBufferSize(int32 size) OVERRIDE; |
67 virtual int Connect(net::OldCompletionCallback* callback) OVERRIDE; | 69 virtual int Connect(net::OldCompletionCallback* callback) OVERRIDE; |
68 virtual int Connect(const net::CompletionCallback& callback) OVERRIDE; | 70 virtual int Connect(const net::CompletionCallback& callback) OVERRIDE; |
69 virtual void Disconnect() OVERRIDE; | 71 virtual void Disconnect() OVERRIDE; |
70 virtual bool IsConnected() const OVERRIDE; | 72 virtual bool IsConnected() const OVERRIDE; |
71 virtual bool IsConnectedAndIdle() const OVERRIDE; | 73 virtual bool IsConnectedAndIdle() const OVERRIDE; |
72 virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE; | 74 virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE; |
73 virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE; | 75 virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE; |
74 virtual const net::BoundNetLog& NetLog() const OVERRIDE; | 76 virtual const net::BoundNetLog& NetLog() const OVERRIDE; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 174 |
173 int FakeSocket::Write(net::IOBuffer* buf, int buf_len, | 175 int FakeSocket::Write(net::IOBuffer* buf, int buf_len, |
174 net::OldCompletionCallback* callback) { | 176 net::OldCompletionCallback* callback) { |
175 DCHECK(buf); | 177 DCHECK(buf); |
176 if (written_data_) { | 178 if (written_data_) { |
177 written_data_->insert(written_data_->end(), | 179 written_data_->insert(written_data_->end(), |
178 buf->data(), buf->data() + buf_len); | 180 buf->data(), buf->data() + buf_len); |
179 } | 181 } |
180 return buf_len; | 182 return buf_len; |
181 } | 183 } |
| 184 int FakeSocket::Write(net::IOBuffer* buf, int buf_len, |
| 185 const net::CompletionCallback& callback) { |
| 186 DCHECK(buf); |
| 187 if (written_data_) { |
| 188 written_data_->insert(written_data_->end(), |
| 189 buf->data(), buf->data() + buf_len); |
| 190 } |
| 191 return buf_len; |
| 192 } |
182 | 193 |
183 | 194 |
184 bool FakeSocket::SetReceiveBufferSize(int32 size) { | 195 bool FakeSocket::SetReceiveBufferSize(int32 size) { |
185 NOTIMPLEMENTED(); | 196 NOTIMPLEMENTED(); |
186 return false; | 197 return false; |
187 } | 198 } |
188 bool FakeSocket::SetSendBufferSize(int32 size) { | 199 bool FakeSocket::SetSendBufferSize(int32 size) { |
189 NOTIMPLEMENTED(); | 200 NOTIMPLEMENTED(); |
190 return false; | 201 return false; |
191 } | 202 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 return false; | 315 return false; |
305 P2PMsg_OnIncomingTcpConnection::Param params; | 316 P2PMsg_OnIncomingTcpConnection::Param params; |
306 P2PMsg_OnIncomingTcpConnection::Read( | 317 P2PMsg_OnIncomingTcpConnection::Read( |
307 arg, ¶ms); | 318 arg, ¶ms); |
308 return params.b == address; | 319 return params.b == address; |
309 } | 320 } |
310 | 321 |
311 } // namespace | 322 } // namespace |
312 | 323 |
313 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ | 324 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ |
OLD | NEW |