Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: content/renderer/p2p/socket_dispatcher.h

Issue 45183002: Expose the p2p client in content/public (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix gyp file Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/p2p/socket_client_impl.cc ('k') | content/renderer/p2p/socket_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.
(...skipping 11 matching lines...) Expand all
22 #define CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ 22 #define CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_
23 23
24 #include <vector> 24 #include <vector>
25 25
26 #include "base/callback_forward.h" 26 #include "base/callback_forward.h"
27 #include "base/compiler_specific.h" 27 #include "base/compiler_specific.h"
28 #include "base/id_map.h" 28 #include "base/id_map.h"
29 #include "base/observer_list_threadsafe.h" 29 #include "base/observer_list_threadsafe.h"
30 #include "base/synchronization/lock.h" 30 #include "base/synchronization/lock.h"
31 #include "content/common/content_export.h" 31 #include "content/common/content_export.h"
32 #include "content/common/p2p_sockets.h" 32 #include "content/public/common/p2p_socket_type.h"
33 #include "ipc/ipc_channel_proxy.h" 33 #include "ipc/ipc_channel_proxy.h"
34 #include "net/base/net_util.h" 34 #include "net/base/net_util.h"
35 35
36 namespace base { 36 namespace base {
37 class MessageLoopProxy; 37 class MessageLoopProxy;
38 } // namespace base 38 } // namespace base
39 39
40 namespace net { 40 namespace net {
41 class IPEndPoint; 41 class IPEndPoint;
42 } // namespace net 42 } // namespace net
43 43
44 namespace content { 44 namespace content {
45 45
46 class NetworkListObserver; 46 class NetworkListObserver;
47 class RenderViewImpl; 47 class RenderViewImpl;
48 class P2PHostAddressRequest; 48 class P2PHostAddressRequest;
49 class P2PSocketClient; 49 class P2PSocketClientImpl;
50 50
51 class CONTENT_EXPORT P2PSocketDispatcher 51 class CONTENT_EXPORT P2PSocketDispatcher
52 : public IPC::ChannelProxy::MessageFilter { 52 : public IPC::ChannelProxy::MessageFilter {
53 public: 53 public:
54 P2PSocketDispatcher(base::MessageLoopProxy* ipc_message_loop); 54 P2PSocketDispatcher(base::MessageLoopProxy* ipc_message_loop);
55 55
56 // Add a new network list observer. Each observer is called 56 // Add a new network list observer. Each observer is called
57 // immidiately after it is registered and then later whenever 57 // immidiately after it is registered and then later whenever
58 // network configuration changes. Can be called on any thread. The 58 // network configuration changes. Can be called on any thread. The
59 // observer is always called on the thread it was added. 59 // observer is always called on the thread it was added.
60 void AddNetworkListObserver(NetworkListObserver* network_list_observer); 60 void AddNetworkListObserver(NetworkListObserver* network_list_observer);
61 61
62 // Removes network list observer. Must be called on the thread on 62 // Removes network list observer. Must be called on the thread on
63 // which the observer was added. 63 // which the observer was added.
64 void RemoveNetworkListObserver(NetworkListObserver* network_list_observer); 64 void RemoveNetworkListObserver(NetworkListObserver* network_list_observer);
65 65
66 protected: 66 protected:
67 virtual ~P2PSocketDispatcher(); 67 virtual ~P2PSocketDispatcher();
68 68
69 private: 69 private:
70 friend class P2PHostAddressRequest; 70 friend class P2PHostAddressRequest;
71 friend class P2PSocketClient; 71 friend class P2PSocketClientImpl;
72 72
73 // Send a message asynchronously. 73 // Send a message asynchronously.
74 virtual void Send(IPC::Message* message); 74 virtual void Send(IPC::Message* message);
75 75
76 // IPC::ChannelProxy::MessageFilter override. Called on IO thread. 76 // IPC::ChannelProxy::MessageFilter override. Called on IO thread.
77 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 77 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
78 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; 78 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
79 virtual void OnFilterRemoved() OVERRIDE; 79 virtual void OnFilterRemoved() OVERRIDE;
80 virtual void OnChannelClosing() OVERRIDE; 80 virtual void OnChannelClosing() OVERRIDE;
81 81
82 // Returns the IO message loop. 82 // Returns the IO message loop.
83 base::MessageLoopProxy* message_loop(); 83 base::MessageLoopProxy* message_loop();
84 84
85 // Called by P2PSocketClient. 85 // Called by P2PSocketClient.
86 int RegisterClient(P2PSocketClient* client); 86 int RegisterClient(P2PSocketClientImpl* client);
87 void UnregisterClient(int id); 87 void UnregisterClient(int id);
88 void SendP2PMessage(IPC::Message* msg); 88 void SendP2PMessage(IPC::Message* msg);
89 89
90 // Called by DnsRequest. 90 // Called by DnsRequest.
91 int RegisterHostAddressRequest(P2PHostAddressRequest* request); 91 int RegisterHostAddressRequest(P2PHostAddressRequest* request);
92 void UnregisterHostAddressRequest(int id); 92 void UnregisterHostAddressRequest(int id);
93 93
94 // Incoming message handlers. 94 // Incoming message handlers.
95 void OnNetworkListChanged(const net::NetworkInterfaceList& networks); 95 void OnNetworkListChanged(const net::NetworkInterfaceList& networks);
96 void OnGetHostAddressResult(int32 request_id, 96 void OnGetHostAddressResult(int32 request_id,
97 const net::IPAddressNumber& address); 97 const net::IPAddressNumber& address);
98 void OnSocketCreated(int socket_id, const net::IPEndPoint& address); 98 void OnSocketCreated(int socket_id, const net::IPEndPoint& address);
99 void OnIncomingTcpConnection(int socket_id, const net::IPEndPoint& address); 99 void OnIncomingTcpConnection(int socket_id, const net::IPEndPoint& address);
100 void OnSendComplete(int socket_id); 100 void OnSendComplete(int socket_id);
101 void OnError(int socket_id); 101 void OnError(int socket_id);
102 void OnDataReceived(int socket_id, const net::IPEndPoint& address, 102 void OnDataReceived(int socket_id, const net::IPEndPoint& address,
103 const std::vector<char>& data); 103 const std::vector<char>& data);
104 104
105 P2PSocketClient* GetClient(int socket_id); 105 P2PSocketClientImpl* GetClient(int socket_id);
106 106
107 scoped_refptr<base::MessageLoopProxy> message_loop_; 107 scoped_refptr<base::MessageLoopProxy> message_loop_;
108 IDMap<P2PSocketClient> clients_; 108 IDMap<P2PSocketClientImpl> clients_;
109 109
110 IDMap<P2PHostAddressRequest> host_address_requests_; 110 IDMap<P2PHostAddressRequest> host_address_requests_;
111 111
112 bool network_notifications_started_; 112 bool network_notifications_started_;
113 scoped_refptr<ObserverListThreadSafe<NetworkListObserver> > 113 scoped_refptr<ObserverListThreadSafe<NetworkListObserver> >
114 network_list_observers_; 114 network_list_observers_;
115 115
116 IPC::Channel* channel_; 116 IPC::Channel* channel_;
117 117
118 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher); 118 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher);
119 }; 119 };
120 120
121 } // namespace content 121 } // namespace content
122 122
123 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ 123 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_
OLDNEW
« no previous file with comments | « content/renderer/p2p/socket_client_impl.cc ('k') | content/renderer/p2p/socket_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698