| 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 "content/common/p2p_messages.h" | 10 #include "content/common/p2p_messages.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 public: | 24 public: |
| 25 MockIPCSender(); | 25 MockIPCSender(); |
| 26 virtual ~MockIPCSender(); | 26 virtual ~MockIPCSender(); |
| 27 | 27 |
| 28 MOCK_METHOD1(Send, bool(IPC::Message* msg)); | 28 MOCK_METHOD1(Send, bool(IPC::Message* msg)); |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 class FakeSocket : public net::StreamSocket { | 31 class FakeSocket : public net::StreamSocket { |
| 32 public: | 32 public: |
| 33 FakeSocket(std::string* written_data); | 33 FakeSocket(std::string* written_data); |
| 34 virtual ~FakeSocket(); | 34 ~FakeSocket() override; |
| 35 | 35 |
| 36 void set_async_write(bool async_write) { async_write_ = async_write; } | 36 void set_async_write(bool async_write) { async_write_ = async_write; } |
| 37 void AppendInputData(const char* data, int data_size); | 37 void AppendInputData(const char* data, int data_size); |
| 38 int input_pos() const { return input_pos_; } | 38 int input_pos() const { return input_pos_; } |
| 39 bool read_pending() const { return read_pending_; } | 39 bool read_pending() const { return read_pending_; } |
| 40 void SetPeerAddress(const net::IPEndPoint& peer_address); | 40 void SetPeerAddress(const net::IPEndPoint& peer_address); |
| 41 void SetLocalAddress(const net::IPEndPoint& local_address); | 41 void SetLocalAddress(const net::IPEndPoint& local_address); |
| 42 | 42 |
| 43 // net::Socket implementation. | 43 // net::Socket implementation. |
| 44 virtual int Read(net::IOBuffer* buf, int buf_len, | 44 int Read(net::IOBuffer* buf, |
| 45 const net::CompletionCallback& callback) override; | 45 int buf_len, |
| 46 virtual int Write(net::IOBuffer* buf, int buf_len, | 46 const net::CompletionCallback& callback) override; |
| 47 const net::CompletionCallback& callback) override; | 47 int Write(net::IOBuffer* buf, |
| 48 virtual int SetReceiveBufferSize(int32 size) override; | 48 int buf_len, |
| 49 virtual int SetSendBufferSize(int32 size) override; | 49 const net::CompletionCallback& callback) override; |
| 50 virtual int Connect(const net::CompletionCallback& callback) override; | 50 int SetReceiveBufferSize(int32 size) override; |
| 51 virtual void Disconnect() override; | 51 int SetSendBufferSize(int32 size) override; |
| 52 virtual bool IsConnected() const override; | 52 int Connect(const net::CompletionCallback& callback) override; |
| 53 virtual bool IsConnectedAndIdle() const override; | 53 void Disconnect() override; |
| 54 virtual int GetPeerAddress(net::IPEndPoint* address) const override; | 54 bool IsConnected() const override; |
| 55 virtual int GetLocalAddress(net::IPEndPoint* address) const override; | 55 bool IsConnectedAndIdle() const override; |
| 56 virtual const net::BoundNetLog& NetLog() const override; | 56 int GetPeerAddress(net::IPEndPoint* address) const override; |
| 57 virtual void SetSubresourceSpeculation() override; | 57 int GetLocalAddress(net::IPEndPoint* address) const override; |
| 58 virtual void SetOmniboxSpeculation() override; | 58 const net::BoundNetLog& NetLog() const override; |
| 59 virtual bool WasEverUsed() const override; | 59 void SetSubresourceSpeculation() override; |
| 60 virtual bool UsingTCPFastOpen() const override; | 60 void SetOmniboxSpeculation() override; |
| 61 virtual bool WasNpnNegotiated() const override; | 61 bool WasEverUsed() const override; |
| 62 virtual net::NextProto GetNegotiatedProtocol() const override; | 62 bool UsingTCPFastOpen() const override; |
| 63 virtual bool GetSSLInfo(net::SSLInfo* ssl_info) override; | 63 bool WasNpnNegotiated() const override; |
| 64 net::NextProto GetNegotiatedProtocol() const override; |
| 65 bool GetSSLInfo(net::SSLInfo* ssl_info) override; |
| 64 | 66 |
| 65 private: | 67 private: |
| 66 void DoAsyncWrite(scoped_refptr<net::IOBuffer> buf, int buf_len, | 68 void DoAsyncWrite(scoped_refptr<net::IOBuffer> buf, int buf_len, |
| 67 const net::CompletionCallback& callback); | 69 const net::CompletionCallback& callback); |
| 68 | 70 |
| 69 bool read_pending_; | 71 bool read_pending_; |
| 70 scoped_refptr<net::IOBuffer> read_buffer_; | 72 scoped_refptr<net::IOBuffer> read_buffer_; |
| 71 int read_buffer_size_; | 73 int read_buffer_size_; |
| 72 net::CompletionCallback read_callback_; | 74 net::CompletionCallback read_callback_; |
| 73 | 75 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 MATCHER_P(MatchIncomingSocketMessage, address, "") { | 108 MATCHER_P(MatchIncomingSocketMessage, address, "") { |
| 107 if (arg->type() != P2PMsg_OnIncomingTcpConnection::ID) | 109 if (arg->type() != P2PMsg_OnIncomingTcpConnection::ID) |
| 108 return false; | 110 return false; |
| 109 P2PMsg_OnIncomingTcpConnection::Param params; | 111 P2PMsg_OnIncomingTcpConnection::Param params; |
| 110 P2PMsg_OnIncomingTcpConnection::Read( | 112 P2PMsg_OnIncomingTcpConnection::Read( |
| 111 arg, ¶ms); | 113 arg, ¶ms); |
| 112 return params.b == address; | 114 return params.b == address; |
| 113 } | 115 } |
| 114 | 116 |
| 115 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ | 117 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TEST_UTILS_H_ |
| OLD | NEW |