| 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::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; | 76   virtual int64 NumBytesRead() const OVERRIDE; | 
| 77   virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; | 77   virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; | 
|  | 78   virtual net::NextProto GetNegotiatedProtocol() const OVERRIDE; | 
| 78 | 79 | 
| 79  private: | 80  private: | 
| 80   bool read_pending_; | 81   bool read_pending_; | 
| 81   scoped_refptr<net::IOBuffer> read_buffer_; | 82   scoped_refptr<net::IOBuffer> read_buffer_; | 
| 82   int read_buffer_size_; | 83   int read_buffer_size_; | 
| 83   net::CompletionCallback read_callback_; | 84   net::CompletionCallback read_callback_; | 
| 84 | 85 | 
| 85   std::string* written_data_; | 86   std::string* written_data_; | 
| 86   std::string input_data_; | 87   std::string input_data_; | 
| 87   int input_pos_; | 88   int input_pos_; | 
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 212 } | 213 } | 
| 213 | 214 | 
| 214 int64 FakeSocket::NumBytesRead() const { | 215 int64 FakeSocket::NumBytesRead() const { | 
| 215   return -1; | 216   return -1; | 
| 216 } | 217 } | 
| 217 | 218 | 
| 218 base::TimeDelta FakeSocket::GetConnectTimeMicros() const { | 219 base::TimeDelta FakeSocket::GetConnectTimeMicros() const { | 
| 219   return base::TimeDelta::FromMicroseconds(-1); | 220   return base::TimeDelta::FromMicroseconds(-1); | 
| 220 } | 221 } | 
| 221 | 222 | 
|  | 223 net::NextProto FakeSocket::GetNegotiatedProtocol() const { | 
|  | 224   return net::kProtoUnknown; | 
|  | 225 } | 
|  | 226 | 
| 222 void CreateRandomPacket(std::vector<char>* packet) { | 227 void CreateRandomPacket(std::vector<char>* packet) { | 
| 223   size_t size = kStunHeaderSize + rand() % 1000; | 228   size_t size = kStunHeaderSize + rand() % 1000; | 
| 224   packet->resize(size); | 229   packet->resize(size); | 
| 225   for (size_t i = 0; i < size; i++) { | 230   for (size_t i = 0; i < size; i++) { | 
| 226     (*packet)[i] = rand() % 256; | 231     (*packet)[i] = rand() % 256; | 
| 227   } | 232   } | 
| 228   // Always set the first bit to ensure that generated packet is not | 233   // Always set the first bit to ensure that generated packet is not | 
| 229   // valid STUN packet. | 234   // valid STUN packet. | 
| 230   (*packet)[0] = (*packet)[0] | 0x80; | 235   (*packet)[0] = (*packet)[0] | 0x80; | 
| 231 } | 236 } | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 274     return false; | 279     return false; | 
| 275   P2PMsg_OnIncomingTcpConnection::Param params; | 280   P2PMsg_OnIncomingTcpConnection::Param params; | 
| 276   P2PMsg_OnIncomingTcpConnection::Read( | 281   P2PMsg_OnIncomingTcpConnection::Read( | 
| 277       arg, ¶ms); | 282       arg, ¶ms); | 
| 278   return params.b == address; | 283   return params.b == address; | 
| 279 } | 284 } | 
| 280 | 285 | 
| 281 }  // namespace | 286 }  // namespace | 
| 282 | 287 | 
| 283 #endif  // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ | 288 #endif  // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ | 
| OLD | NEW | 
|---|