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