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/p2p_sockets.h" | 8 #include "content/common/p2p_sockets.h" |
9 | 9 |
| 10 #include "net/base/ip_endpoint.h" |
| 11 |
10 class P2PSocketsHost; | 12 class P2PSocketsHost; |
11 | 13 |
12 // Base class for P2P sockets used by P2PSocketsHost. | 14 // Base class for P2P sockets used by P2PSocketsHost. |
13 class P2PSocketHost { | 15 class P2PSocketHost { |
14 public: | 16 public: |
15 // Creates P2PSocketHost for the current platform. Must be | 17 // Creates P2PSocketHost for the current platform. Must be |
16 // implemented in a platform-specific file. | 18 // implemented in a platform-specific file. |
17 static P2PSocketHost* Create(P2PSocketsHost* host, int routing_id, int id, | 19 static P2PSocketHost* Create(P2PSocketsHost* host, int routing_id, int id, |
18 P2PSocketType type); | 20 P2PSocketType type); |
19 | 21 |
20 virtual ~P2PSocketHost(); | 22 virtual ~P2PSocketHost(); |
21 | 23 |
22 // Initalizes the socket. Returns false when initiazations fails. | 24 // Initalizes the socket. Returns false when initiazations fails. |
23 virtual bool Init() = 0; | 25 virtual bool Init() = 0; |
24 | 26 |
25 // Sends |data| on the socket to |socket_address|. | 27 // Sends |data| on the socket to |socket_address|. |
26 virtual void Send(const P2PSocketAddress& socket_address, | 28 virtual void Send(const net::IPEndPoint& socket_address, |
27 const std::vector<char>& data) = 0; | 29 const std::vector<char>& data) = 0; |
28 | 30 |
29 protected: | 31 protected: |
30 P2PSocketHost(P2PSocketsHost* host, int routing_id, int id); | 32 P2PSocketHost(P2PSocketsHost* host, int routing_id, int id); |
31 | 33 |
32 P2PSocketsHost* host_; | 34 P2PSocketsHost* host_; |
33 int routing_id_; | 35 int routing_id_; |
34 int id_; | 36 int id_; |
35 | 37 |
36 DISALLOW_COPY_AND_ASSIGN(P2PSocketHost); | 38 DISALLOW_COPY_AND_ASSIGN(P2PSocketHost); |
37 }; | 39 }; |
38 | 40 |
39 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ | 41 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ |
OLD | NEW |