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_socket_type.h" | 9 #include "content/common/p2p_socket_type.h" |
10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
11 #include "net/udp/datagram_socket.h" | 11 #include "net/udp/datagram_socket.h" |
12 | 12 |
13 namespace IPC { | 13 namespace IPC { |
14 class Sender; | 14 class Sender; |
15 } | 15 } |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 class URLRequestContextGetter; | 18 class URLRequestContextGetter; |
19 } | 19 } |
20 | 20 |
| 21 namespace talk_base { |
| 22 struct PacketOptions; |
| 23 } |
| 24 |
21 namespace content { | 25 namespace content { |
22 class P2PMessageThrottler; | 26 class P2PMessageThrottler; |
23 | 27 |
24 // Base class for P2P sockets. | 28 // Base class for P2P sockets. |
25 class CONTENT_EXPORT P2PSocketHost { | 29 class CONTENT_EXPORT P2PSocketHost { |
26 public: | 30 public: |
27 static const int kStunHeaderSize = 20; | 31 static const int kStunHeaderSize = 20; |
28 // Creates P2PSocketHost of the specific type. | 32 // Creates P2PSocketHost of the specific type. |
29 static P2PSocketHost* Create(IPC::Sender* message_sender, | 33 static P2PSocketHost* Create(IPC::Sender* message_sender, |
30 int id, P2PSocketType type, | 34 int id, P2PSocketType type, |
31 net::URLRequestContextGetter* url_context, | 35 net::URLRequestContextGetter* url_context, |
32 P2PMessageThrottler* throttler); | 36 P2PMessageThrottler* throttler); |
33 | 37 |
34 virtual ~P2PSocketHost(); | 38 virtual ~P2PSocketHost(); |
35 | 39 |
36 // Initalizes the socket. Returns false when initiazations fails. | 40 // Initalizes the socket. Returns false when initiazations fails. |
37 virtual bool Init(const net::IPEndPoint& local_address, | 41 virtual bool Init(const net::IPEndPoint& local_address, |
38 const net::IPEndPoint& remote_address) = 0; | 42 const net::IPEndPoint& remote_address) = 0; |
39 | 43 |
40 // Sends |data| on the socket to |to|. | 44 // Sends |data| on the socket to |to|. |
41 virtual void Send(const net::IPEndPoint& to, | 45 virtual void Send(const net::IPEndPoint& to, |
42 const std::vector<char>& data, | 46 const std::vector<char>& data, |
43 net::DiffServCodePoint dscp, | 47 const talk_base::PacketOptions& options, |
44 uint64 packet_id) = 0; | 48 uint64 packet_id) = 0; |
45 | 49 |
46 virtual P2PSocketHost* AcceptIncomingTcpConnection( | 50 virtual P2PSocketHost* AcceptIncomingTcpConnection( |
47 const net::IPEndPoint& remote_address, int id) = 0; | 51 const net::IPEndPoint& remote_address, int id) = 0; |
48 | 52 |
49 virtual bool SetOption(P2PSocketOption option, int value) = 0; | 53 virtual bool SetOption(P2PSocketOption option, int value) = 0; |
50 | 54 |
51 protected: | 55 protected: |
52 friend class P2PSocketHostTcpTestBase; | 56 friend class P2PSocketHostTcpTestBase; |
53 | 57 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 IPC::Sender* message_sender_; | 100 IPC::Sender* message_sender_; |
97 int id_; | 101 int id_; |
98 State state_; | 102 State state_; |
99 | 103 |
100 DISALLOW_COPY_AND_ASSIGN(P2PSocketHost); | 104 DISALLOW_COPY_AND_ASSIGN(P2PSocketHost); |
101 }; | 105 }; |
102 | 106 |
103 } // namespace content | 107 } // namespace content |
104 | 108 |
105 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ | 109 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ |
OLD | NEW |