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