OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // P2PSocketDispatcher is a per-renderer object that dispatchers all | 5 // P2PSocketDispatcher is a per-renderer object that dispatchers all |
6 // P2P messages received from the browser and relays all P2P messages | 6 // P2P messages received from the browser and relays all P2P messages |
7 // sent to the browser. P2PSocketClient instances register themselves | 7 // sent to the browser. P2PSocketClient instances register themselves |
8 // with the dispatcher using RegisterClient() and UnregisterClient(). | 8 // with the dispatcher using RegisterClient() and UnregisterClient(). |
9 // | 9 // |
10 // Relationship of classes. | 10 // Relationship of classes. |
11 // | 11 // |
12 // P2PSocketHost P2PSocketClient | 12 // P2PSocketHost P2PSocketClient |
13 // ^ ^ | 13 // ^ ^ |
14 // | | | 14 // | | |
15 // v IPC v | 15 // v IPC v |
16 // P2PSocketDispatcherHost <---------> P2PSocketDispatcher | 16 // P2PSocketDispatcherHost <---------> P2PSocketDispatcher |
17 // | 17 // |
18 // P2PSocketDispatcher receives and dispatches messages on the | 18 // P2PSocketDispatcher receives and dispatches messages on the |
19 // IO thread. | 19 // IO thread. |
20 | 20 |
21 #ifndef CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ | 21 #ifndef CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ |
22 #define CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ | 22 #define CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ |
23 | 23 |
| 24 #include <stdint.h> |
| 25 |
24 #include <vector> | 26 #include <vector> |
25 | 27 |
26 #include "base/callback_forward.h" | 28 #include "base/callback_forward.h" |
27 #include "base/compiler_specific.h" | 29 #include "base/compiler_specific.h" |
28 #include "base/id_map.h" | 30 #include "base/id_map.h" |
| 31 #include "base/macros.h" |
29 #include "base/observer_list_threadsafe.h" | 32 #include "base/observer_list_threadsafe.h" |
30 #include "base/synchronization/lock.h" | 33 #include "base/synchronization/lock.h" |
31 #include "content/common/content_export.h" | 34 #include "content/common/content_export.h" |
32 #include "content/common/p2p_socket_type.h" | 35 #include "content/common/p2p_socket_type.h" |
33 #include "content/renderer/p2p/network_list_manager.h" | 36 #include "content/renderer/p2p/network_list_manager.h" |
34 #include "ipc/message_filter.h" | 37 #include "ipc/message_filter.h" |
35 #include "net/base/ip_address_number.h" | 38 #include "net/base/ip_address_number.h" |
36 #include "net/base/ip_endpoint.h" | 39 #include "net/base/ip_endpoint.h" |
37 #include "net/base/network_interfaces.h" | 40 #include "net/base/network_interfaces.h" |
38 | 41 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 friend class P2PSocketClientImpl; | 75 friend class P2PSocketClientImpl; |
73 | 76 |
74 // Send a message asynchronously. | 77 // Send a message asynchronously. |
75 virtual void Send(IPC::Message* message); | 78 virtual void Send(IPC::Message* message); |
76 | 79 |
77 // IPC::MessageFilter override. Called on IO thread. | 80 // IPC::MessageFilter override. Called on IO thread. |
78 bool OnMessageReceived(const IPC::Message& message) override; | 81 bool OnMessageReceived(const IPC::Message& message) override; |
79 void OnFilterAdded(IPC::Sender* sender) override; | 82 void OnFilterAdded(IPC::Sender* sender) override; |
80 void OnFilterRemoved() override; | 83 void OnFilterRemoved() override; |
81 void OnChannelClosing() override; | 84 void OnChannelClosing() override; |
82 void OnChannelConnected(int32 peer_pid) override; | 85 void OnChannelConnected(int32_t peer_pid) override; |
83 | 86 |
84 base::SingleThreadTaskRunner* task_runner(); | 87 base::SingleThreadTaskRunner* task_runner(); |
85 | 88 |
86 // Called by P2PSocketClient. | 89 // Called by P2PSocketClient. |
87 int RegisterClient(P2PSocketClientImpl* client); | 90 int RegisterClient(P2PSocketClientImpl* client); |
88 void UnregisterClient(int id); | 91 void UnregisterClient(int id); |
89 void SendP2PMessage(IPC::Message* msg); | 92 void SendP2PMessage(IPC::Message* msg); |
90 | 93 |
91 // Called by DnsRequest. | 94 // Called by DnsRequest. |
92 int RegisterHostAddressRequest(P2PAsyncAddressResolver* request); | 95 int RegisterHostAddressRequest(P2PAsyncAddressResolver* request); |
93 void UnregisterHostAddressRequest(int id); | 96 void UnregisterHostAddressRequest(int id); |
94 | 97 |
95 // Incoming message handlers. | 98 // Incoming message handlers. |
96 void OnNetworkListChanged( | 99 void OnNetworkListChanged( |
97 const net::NetworkInterfaceList& networks, | 100 const net::NetworkInterfaceList& networks, |
98 const net::IPAddressNumber& default_ipv4_local_address, | 101 const net::IPAddressNumber& default_ipv4_local_address, |
99 const net::IPAddressNumber& default_ipv6_local_address); | 102 const net::IPAddressNumber& default_ipv6_local_address); |
100 void OnGetHostAddressResult(int32 request_id, | 103 void OnGetHostAddressResult(int32_t request_id, |
101 const net::IPAddressList& addresses); | 104 const net::IPAddressList& addresses); |
102 void OnSocketCreated(int socket_id, | 105 void OnSocketCreated(int socket_id, |
103 const net::IPEndPoint& local_address, | 106 const net::IPEndPoint& local_address, |
104 const net::IPEndPoint& remote_address); | 107 const net::IPEndPoint& remote_address); |
105 void OnIncomingTcpConnection(int socket_id, const net::IPEndPoint& address); | 108 void OnIncomingTcpConnection(int socket_id, const net::IPEndPoint& address); |
106 void OnSendComplete(int socket_id, const P2PSendPacketMetrics& send_metrics); | 109 void OnSendComplete(int socket_id, const P2PSendPacketMetrics& send_metrics); |
107 void OnError(int socket_id); | 110 void OnError(int socket_id); |
108 void OnDataReceived(int socket_id, const net::IPEndPoint& address, | 111 void OnDataReceived(int socket_id, const net::IPEndPoint& address, |
109 const std::vector<char>& data, | 112 const std::vector<char>& data, |
110 const base::TimeTicks& timestamp); | 113 const base::TimeTicks& timestamp); |
(...skipping 13 matching lines...) Expand all Loading... |
124 | 127 |
125 // To indicate whether IPC could be invoked on this dispatcher. | 128 // To indicate whether IPC could be invoked on this dispatcher. |
126 bool connected_ = false; | 129 bool connected_ = false; |
127 | 130 |
128 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher); | 131 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher); |
129 }; | 132 }; |
130 | 133 |
131 } // namespace content | 134 } // namespace content |
132 | 135 |
133 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ | 136 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ |
OLD | NEW |