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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 virtual void Disconnect() OVERRIDE; | 66 virtual void Disconnect() OVERRIDE; |
67 virtual bool IsConnected() const OVERRIDE; | 67 virtual bool IsConnected() const OVERRIDE; |
68 virtual bool IsConnectedAndIdle() const OVERRIDE; | 68 virtual bool IsConnectedAndIdle() const OVERRIDE; |
69 virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE; | 69 virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE; |
70 virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE; | 70 virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE; |
71 virtual const net::BoundNetLog& NetLog() const OVERRIDE; | 71 virtual const net::BoundNetLog& NetLog() const OVERRIDE; |
72 virtual void SetSubresourceSpeculation() OVERRIDE; | 72 virtual void SetSubresourceSpeculation() OVERRIDE; |
73 virtual void SetOmniboxSpeculation() OVERRIDE; | 73 virtual void SetOmniboxSpeculation() OVERRIDE; |
74 virtual bool WasEverUsed() const OVERRIDE; | 74 virtual bool WasEverUsed() const OVERRIDE; |
75 virtual bool UsingTCPFastOpen() const OVERRIDE; | 75 virtual bool UsingTCPFastOpen() const OVERRIDE; |
| 76 virtual int64 NumBytesRead() const OVERRIDE; |
| 77 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; |
76 | 78 |
77 private: | 79 private: |
78 bool read_pending_; | 80 bool read_pending_; |
79 scoped_refptr<net::IOBuffer> read_buffer_; | 81 scoped_refptr<net::IOBuffer> read_buffer_; |
80 int read_buffer_size_; | 82 int read_buffer_size_; |
81 net::CompletionCallback* read_callback_; | 83 net::CompletionCallback* read_callback_; |
82 | 84 |
83 std::string* written_data_; | 85 std::string* written_data_; |
84 std::string input_data_; | 86 std::string input_data_; |
85 int input_pos_; | 87 int input_pos_; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 204 } |
203 | 205 |
204 bool FakeSocket::WasEverUsed() const { | 206 bool FakeSocket::WasEverUsed() const { |
205 return true; | 207 return true; |
206 } | 208 } |
207 | 209 |
208 bool FakeSocket::UsingTCPFastOpen() const { | 210 bool FakeSocket::UsingTCPFastOpen() const { |
209 return false; | 211 return false; |
210 } | 212 } |
211 | 213 |
| 214 int64 FakeSocket::NumBytesRead() const { |
| 215 return -1; |
| 216 } |
| 217 |
| 218 base::TimeDelta FakeSocket::GetConnectTimeMicros() const { |
| 219 return base::TimeDelta::FromMicroseconds(-1); |
| 220 } |
| 221 |
212 void CreateRandomPacket(std::vector<char>* packet) { | 222 void CreateRandomPacket(std::vector<char>* packet) { |
213 size_t size = kStunHeaderSize + rand() % 1000; | 223 size_t size = kStunHeaderSize + rand() % 1000; |
214 packet->resize(size); | 224 packet->resize(size); |
215 for (size_t i = 0; i < size; i++) { | 225 for (size_t i = 0; i < size; i++) { |
216 (*packet)[i] = rand() % 256; | 226 (*packet)[i] = rand() % 256; |
217 } | 227 } |
218 // Always set the first bit to ensure that generated packet is not | 228 // Always set the first bit to ensure that generated packet is not |
219 // valid STUN packet. | 229 // valid STUN packet. |
220 (*packet)[0] = (*packet)[0] | 0x80; | 230 (*packet)[0] = (*packet)[0] | 0x80; |
221 } | 231 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 return false; | 273 return false; |
264 P2PMsg_OnIncomingTcpConnection::Param params; | 274 P2PMsg_OnIncomingTcpConnection::Param params; |
265 IPC::MessageWithTuple<P2PMsg_OnIncomingTcpConnection::Param>::Read( | 275 IPC::MessageWithTuple<P2PMsg_OnIncomingTcpConnection::Param>::Read( |
266 arg, ¶ms); | 276 arg, ¶ms); |
267 return params.b == address; | 277 return params.b == address; |
268 } | 278 } |
269 | 279 |
270 } // namespace | 280 } // namespace |
271 | 281 |
272 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ | 282 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ |
OLD | NEW |