| 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_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ |
| 7 | 7 |
| 8 #include "content/common/content_export.h" | 8 #include "content/common/content_export.h" |
| 9 #include "content/common/p2p_sockets.h" | 9 #include "content/common/p2p_sockets.h" |
| 10 | 10 |
| 11 #include "ipc/ipc_message.h" | 11 #include "ipc/ipc_message.h" |
| 12 #include "net/base/ip_endpoint.h" | 12 #include "net/base/ip_endpoint.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 // Base class for P2P sockets. | 16 // Base class for P2P sockets. |
| 17 class CONTENT_EXPORT P2PSocketHost { | 17 class CONTENT_EXPORT P2PSocketHost { |
| 18 public: | 18 public: |
| 19 // Creates P2PSocketHost of the specific type. | 19 // Creates P2PSocketHost of the specific type. |
| 20 static P2PSocketHost* Create(IPC::Sender* message_sender, | 20 static P2PSocketHost* Create(IPC::Sender* message_sender, |
| 21 int routing_id, int id, P2PSocketType type); | 21 int id, P2PSocketType type); |
| 22 | 22 |
| 23 virtual ~P2PSocketHost(); | 23 virtual ~P2PSocketHost(); |
| 24 | 24 |
| 25 // Initalizes the socket. Returns false when initiazations fails. | 25 // Initalizes the socket. Returns false when initiazations fails. |
| 26 virtual bool Init(const net::IPEndPoint& local_address, | 26 virtual bool Init(const net::IPEndPoint& local_address, |
| 27 const net::IPEndPoint& remote_address) = 0; | 27 const net::IPEndPoint& remote_address) = 0; |
| 28 | 28 |
| 29 // Sends |data| on the socket to |to|. | 29 // Sends |data| on the socket to |to|. |
| 30 virtual void Send(const net::IPEndPoint& to, | 30 virtual void Send(const net::IPEndPoint& to, |
| 31 const std::vector<char>& data) = 0; | 31 const std::vector<char>& data) = 0; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 61 | 61 |
| 62 // Maximum size of send buffers. Must be big enough to fit data for | 62 // Maximum size of send buffers. Must be big enough to fit data for |
| 63 // one data burst. Send buffers size needs to be limited to prevent | 63 // one data burst. Send buffers size needs to be limited to prevent |
| 64 // from consuming too much memory with misbehaving renderer process. | 64 // from consuming too much memory with misbehaving renderer process. |
| 65 // | 65 // |
| 66 // TODO(sergeyu): Consider implementing congestion notifications to | 66 // TODO(sergeyu): Consider implementing congestion notifications to |
| 67 // minimize buffering. This will require some fixes in libjingle, | 67 // minimize buffering. This will require some fixes in libjingle, |
| 68 // see crbug.com/91495 . | 68 // see crbug.com/91495 . |
| 69 static const int kMaxSendBufferSize = 256 * 1024; | 69 static const int kMaxSendBufferSize = 256 * 1024; |
| 70 | 70 |
| 71 P2PSocketHost(IPC::Sender* message_sender, int routing_id, int id); | 71 P2PSocketHost(IPC::Sender* message_sender, int id); |
| 72 | 72 |
| 73 // Verifies that the packet |data| has a valid STUN header. In case | 73 // Verifies that the packet |data| has a valid STUN header. In case |
| 74 // of success stores type of the message in |type|. | 74 // of success stores type of the message in |type|. |
| 75 static bool GetStunPacketType(const char* data, int data_size, | 75 static bool GetStunPacketType(const char* data, int data_size, |
| 76 StunMessageType* type); | 76 StunMessageType* type); |
| 77 static bool IsRequestOrResponse(StunMessageType type); | 77 static bool IsRequestOrResponse(StunMessageType type); |
| 78 | 78 |
| 79 IPC::Sender* message_sender_; | 79 IPC::Sender* message_sender_; |
| 80 int routing_id_; | |
| 81 int id_; | 80 int id_; |
| 82 State state_; | 81 State state_; |
| 83 | 82 |
| 84 DISALLOW_COPY_AND_ASSIGN(P2PSocketHost); | 83 DISALLOW_COPY_AND_ASSIGN(P2PSocketHost); |
| 85 }; | 84 }; |
| 86 | 85 |
| 87 } // namespace content | 86 } // namespace content |
| 88 | 87 |
| 89 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ | 88 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ |
| OLD | NEW |