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