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_SERVER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "net/socket/tcp_server_socket.h" | 22 #include "net/socket/tcp_server_socket.h" |
23 | 23 |
24 namespace net { | 24 namespace net { |
25 class StreamSocket; | 25 class StreamSocket; |
26 } // namespace net | 26 } // namespace net |
27 | 27 |
28 namespace content { | 28 namespace content { |
29 | 29 |
30 class CONTENT_EXPORT P2PSocketHostTcpServer : public P2PSocketHost { | 30 class CONTENT_EXPORT P2PSocketHostTcpServer : public P2PSocketHost { |
31 public: | 31 public: |
32 typedef std::map<net::IPEndPoint, net::StreamSocket*> AcceptedSocketsMap; | |
33 | |
34 P2PSocketHostTcpServer(IPC::Sender* message_sender, | 32 P2PSocketHostTcpServer(IPC::Sender* message_sender, |
35 int socket_id, | 33 int socket_id, |
36 P2PSocketType client_type); | 34 P2PSocketType client_type); |
37 ~P2PSocketHostTcpServer() override; | 35 ~P2PSocketHostTcpServer() override; |
38 | 36 |
39 // P2PSocketHost overrides. | 37 // P2PSocketHost overrides. |
40 bool Init(const net::IPEndPoint& local_address, | 38 bool Init(const net::IPEndPoint& local_address, |
41 uint16_t min_port, | 39 uint16_t min_port, |
42 uint16_t max_port, | 40 uint16_t max_port, |
43 const P2PHostAndIPEndPoint& remote_address) override; | 41 const P2PHostAndIPEndPoint& remote_address) override; |
44 void Send(const net::IPEndPoint& to, | 42 void Send(const net::IPEndPoint& to, |
45 const std::vector<char>& data, | 43 const std::vector<char>& data, |
46 const rtc::PacketOptions& options, | 44 const rtc::PacketOptions& options, |
47 uint64_t packet_id) override; | 45 uint64_t packet_id) override; |
48 P2PSocketHost* AcceptIncomingTcpConnection( | 46 std::unique_ptr<P2PSocketHost> AcceptIncomingTcpConnection( |
49 const net::IPEndPoint& remote_address, | 47 const net::IPEndPoint& remote_address, |
50 int id) override; | 48 int id) override; |
51 bool SetOption(P2PSocketOption option, int value) override; | 49 bool SetOption(P2PSocketOption option, int value) override; |
52 | 50 |
53 private: | 51 private: |
54 friend class P2PSocketHostTcpServerTest; | 52 friend class P2PSocketHostTcpServerTest; |
55 | 53 |
56 void OnError(); | 54 void OnError(); |
57 | 55 |
58 void DoAccept(); | 56 void DoAccept(); |
59 void HandleAcceptResult(int result); | 57 void HandleAcceptResult(int result); |
60 | 58 |
61 // Callback for Accept(). | 59 // Callback for Accept(). |
62 void OnAccepted(int result); | 60 void OnAccepted(int result); |
63 | 61 |
64 const P2PSocketType client_type_; | 62 const P2PSocketType client_type_; |
65 std::unique_ptr<net::ServerSocket> socket_; | 63 std::unique_ptr<net::ServerSocket> socket_; |
66 net::IPEndPoint local_address_; | 64 net::IPEndPoint local_address_; |
67 | 65 |
68 std::unique_ptr<net::StreamSocket> accept_socket_; | 66 std::unique_ptr<net::StreamSocket> accept_socket_; |
69 AcceptedSocketsMap accepted_sockets_; | 67 std::map<net::IPEndPoint, std::unique_ptr<net::StreamSocket>> |
| 68 accepted_sockets_; |
70 | 69 |
71 net::CompletionCallback accept_callback_; | 70 net::CompletionCallback accept_callback_; |
72 | 71 |
73 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostTcpServer); | 72 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostTcpServer); |
74 }; | 73 }; |
75 | 74 |
76 } // namespace content | 75 } // namespace content |
77 | 76 |
78 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_ | 77 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_ |
OLD | NEW |