| 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_TCP_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 const talk_base::PacketOptions& options, | 45 const talk_base::PacketOptions& options, |
| 46 uint64 packet_id) OVERRIDE; | 46 uint64 packet_id) OVERRIDE; |
| 47 virtual P2PSocketHost* AcceptIncomingTcpConnection( | 47 virtual P2PSocketHost* AcceptIncomingTcpConnection( |
| 48 const net::IPEndPoint& remote_address, int id) OVERRIDE; | 48 const net::IPEndPoint& remote_address, int id) OVERRIDE; |
| 49 virtual bool SetOption(P2PSocketOption option, int value) OVERRIDE; | 49 virtual bool SetOption(P2PSocketOption option, int value) OVERRIDE; |
| 50 | 50 |
| 51 protected: | 51 protected: |
| 52 // Derived classes will provide the implementation. | 52 // Derived classes will provide the implementation. |
| 53 virtual int ProcessInput(char* input, int input_len) = 0; | 53 virtual int ProcessInput(char* input, int input_len) = 0; |
| 54 virtual void DoSend(const net::IPEndPoint& to, | 54 virtual void DoSend(const net::IPEndPoint& to, |
| 55 const std::vector<char>& data, | 55 const std::vector<char>& data) = 0; |
| 56 const talk_base::PacketOptions& options) = 0; | |
| 57 | 56 |
| 58 void WriteOrQueue(scoped_refptr<net::DrainableIOBuffer>& buffer); | 57 void WriteOrQueue(scoped_refptr<net::DrainableIOBuffer>& buffer); |
| 59 void OnPacket(const std::vector<char>& data); | 58 void OnPacket(const std::vector<char>& data); |
| 60 void OnError(); | 59 void OnError(); |
| 61 | 60 |
| 62 private: | 61 private: |
| 63 friend class P2PSocketHostTcpTestBase; | 62 friend class P2PSocketHostTcpTestBase; |
| 64 friend class P2PSocketHostTcpServerTest; | 63 friend class P2PSocketHostTcpServerTest; |
| 65 | 64 |
| 66 // SSL/TLS connection functions. | 65 // SSL/TLS connection functions. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 public: | 101 public: |
| 103 P2PSocketHostTcp(IPC::Sender* message_sender, | 102 P2PSocketHostTcp(IPC::Sender* message_sender, |
| 104 int id, | 103 int id, |
| 105 P2PSocketType type, | 104 P2PSocketType type, |
| 106 net::URLRequestContextGetter* url_context); | 105 net::URLRequestContextGetter* url_context); |
| 107 virtual ~P2PSocketHostTcp(); | 106 virtual ~P2PSocketHostTcp(); |
| 108 | 107 |
| 109 protected: | 108 protected: |
| 110 virtual int ProcessInput(char* input, int input_len) OVERRIDE; | 109 virtual int ProcessInput(char* input, int input_len) OVERRIDE; |
| 111 virtual void DoSend(const net::IPEndPoint& to, | 110 virtual void DoSend(const net::IPEndPoint& to, |
| 112 const std::vector<char>& data, | 111 const std::vector<char>& data) OVERRIDE; |
| 113 const talk_base::PacketOptions& options) OVERRIDE; | |
| 114 private: | 112 private: |
| 115 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostTcp); | 113 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostTcp); |
| 116 }; | 114 }; |
| 117 | 115 |
| 118 // P2PSocketHostStunTcp class provides the framing of STUN messages when used | 116 // P2PSocketHostStunTcp class provides the framing of STUN messages when used |
| 119 // with TURN. These messages will not have length at front of the packet and | 117 // with TURN. These messages will not have length at front of the packet and |
| 120 // are padded to multiple of 4 bytes. | 118 // are padded to multiple of 4 bytes. |
| 121 // Formatting of messages is defined in RFC5766. | 119 // Formatting of messages is defined in RFC5766. |
| 122 class CONTENT_EXPORT P2PSocketHostStunTcp : public P2PSocketHostTcpBase { | 120 class CONTENT_EXPORT P2PSocketHostStunTcp : public P2PSocketHostTcpBase { |
| 123 public: | 121 public: |
| 124 P2PSocketHostStunTcp(IPC::Sender* message_sender, | 122 P2PSocketHostStunTcp(IPC::Sender* message_sender, |
| 125 int id, | 123 int id, |
| 126 P2PSocketType type, | 124 P2PSocketType type, |
| 127 net::URLRequestContextGetter* url_context); | 125 net::URLRequestContextGetter* url_context); |
| 128 | 126 |
| 129 virtual ~P2PSocketHostStunTcp(); | 127 virtual ~P2PSocketHostStunTcp(); |
| 130 | 128 |
| 131 protected: | 129 protected: |
| 132 virtual int ProcessInput(char* input, int input_len) OVERRIDE; | 130 virtual int ProcessInput(char* input, int input_len) OVERRIDE; |
| 133 virtual void DoSend(const net::IPEndPoint& to, | 131 virtual void DoSend(const net::IPEndPoint& to, |
| 134 const std::vector<char>& data, | 132 const std::vector<char>& data) OVERRIDE; |
| 135 const talk_base::PacketOptions& options) OVERRIDE; | |
| 136 private: | 133 private: |
| 137 int GetExpectedPacketSize(const char* data, int len, int* pad_bytes); | 134 int GetExpectedPacketSize(const char* data, int len, int* pad_bytes); |
| 138 | 135 |
| 139 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostStunTcp); | 136 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostStunTcp); |
| 140 }; | 137 }; |
| 141 | 138 |
| 142 | 139 |
| 143 } // namespace content | 140 } // namespace content |
| 144 | 141 |
| 145 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_H_ | 142 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_H_ |
| OLD | NEW |