OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/sys_byteorder.h" | 10 #include "base/sys_byteorder.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 virtual bool IsConnectedAndIdle() const OVERRIDE; | 68 virtual bool IsConnectedAndIdle() const OVERRIDE; |
69 virtual int GetPeerAddress(net::IPEndPoint* address) const OVERRIDE; | 69 virtual int GetPeerAddress(net::IPEndPoint* 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; | 76 virtual int64 NumBytesRead() const OVERRIDE; |
77 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; | 77 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; |
| 78 virtual bool WasNpnNegotiated() const OVERRIDE; |
78 virtual net::NextProto GetNegotiatedProtocol() const OVERRIDE; | 79 virtual net::NextProto GetNegotiatedProtocol() const OVERRIDE; |
| 80 virtual bool GetSSLInfo(net::SSLInfo* ssl_info) OVERRIDE; |
79 | 81 |
80 private: | 82 private: |
81 bool read_pending_; | 83 bool read_pending_; |
82 scoped_refptr<net::IOBuffer> read_buffer_; | 84 scoped_refptr<net::IOBuffer> read_buffer_; |
83 int read_buffer_size_; | 85 int read_buffer_size_; |
84 net::CompletionCallback read_callback_; | 86 net::CompletionCallback read_callback_; |
85 | 87 |
86 std::string* written_data_; | 88 std::string* written_data_; |
87 std::string input_data_; | 89 std::string input_data_; |
88 int input_pos_; | 90 int input_pos_; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 214 } |
213 | 215 |
214 int64 FakeSocket::NumBytesRead() const { | 216 int64 FakeSocket::NumBytesRead() const { |
215 return -1; | 217 return -1; |
216 } | 218 } |
217 | 219 |
218 base::TimeDelta FakeSocket::GetConnectTimeMicros() const { | 220 base::TimeDelta FakeSocket::GetConnectTimeMicros() const { |
219 return base::TimeDelta::FromMicroseconds(-1); | 221 return base::TimeDelta::FromMicroseconds(-1); |
220 } | 222 } |
221 | 223 |
| 224 bool FakeSocket::WasNpnNegotiated() const { |
| 225 return false; |
| 226 } |
| 227 |
222 net::NextProto FakeSocket::GetNegotiatedProtocol() const { | 228 net::NextProto FakeSocket::GetNegotiatedProtocol() const { |
223 return net::kProtoUnknown; | 229 return net::kProtoUnknown; |
224 } | 230 } |
225 | 231 |
| 232 bool FakeSocket::GetSSLInfo(net::SSLInfo* ssl_info) { |
| 233 return false; |
| 234 } |
| 235 |
226 void CreateRandomPacket(std::vector<char>* packet) { | 236 void CreateRandomPacket(std::vector<char>* packet) { |
227 size_t size = kStunHeaderSize + rand() % 1000; | 237 size_t size = kStunHeaderSize + rand() % 1000; |
228 packet->resize(size); | 238 packet->resize(size); |
229 for (size_t i = 0; i < size; i++) { | 239 for (size_t i = 0; i < size; i++) { |
230 (*packet)[i] = rand() % 256; | 240 (*packet)[i] = rand() % 256; |
231 } | 241 } |
232 // Always set the first bit to ensure that generated packet is not | 242 // Always set the first bit to ensure that generated packet is not |
233 // valid STUN packet. | 243 // valid STUN packet. |
234 (*packet)[0] = (*packet)[0] | 0x80; | 244 (*packet)[0] = (*packet)[0] | 0x80; |
235 } | 245 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 return false; | 288 return false; |
279 P2PMsg_OnIncomingTcpConnection::Param params; | 289 P2PMsg_OnIncomingTcpConnection::Param params; |
280 P2PMsg_OnIncomingTcpConnection::Read( | 290 P2PMsg_OnIncomingTcpConnection::Read( |
281 arg, ¶ms); | 291 arg, ¶ms); |
282 return params.b == address; | 292 return params.b == address; |
283 } | 293 } |
284 | 294 |
285 } // namespace | 295 } // namespace |
286 | 296 |
287 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ | 297 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ |
OLD | NEW |