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

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

Issue 7599003: Add IPC for DNS host address resolution. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 4 months 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/host_address_request.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) 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 // 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 18
19 #ifndef CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ 19 #ifndef CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_
20 #define CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ 20 #define CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_
21 21
22 #include <vector> 22 #include <vector>
23 23
24 #include "base/callback.h" 24 #include "base/callback.h"
25 #include "base/compiler_specific.h" 25 #include "base/compiler_specific.h"
26 #include "base/id_map.h" 26 #include "base/id_map.h"
27 #include "base/observer_list_threadsafe.h" 27 #include "base/observer_list_threadsafe.h"
28 #include "base/synchronization/lock.h" 28 #include "base/synchronization/lock.h"
29 #include "content/common/p2p_sockets.h" 29 #include "content/common/p2p_sockets.h"
30 #include "content/renderer/p2p/socket_client.h"
31 #include "content/renderer/render_view_observer.h" 30 #include "content/renderer/render_view_observer.h"
31 #include "net/base/net_util.h"
32 32
33 namespace base { 33 namespace base {
34 class MessageLoopProxy; 34 class MessageLoopProxy;
35 } // namespace base 35 } // namespace base
36 36
37 namespace net {
38 class IPEndPoint;
39 } // namespace net
40
41 class P2PHostAddressRequest;
42 class P2PSocketClient;
43
37 // P2PSocketDispatcher works on the renderer thread. It dispatches all 44 // P2PSocketDispatcher works on the renderer thread. It dispatches all
38 // messages on that thread, and all its methods must be called on the 45 // messages on that thread, and all its methods must be called on the
39 // same thread. 46 // same thread.
40 class P2PSocketDispatcher : public RenderViewObserver { 47 class P2PSocketDispatcher : public RenderViewObserver {
41 public: 48 public:
42 class NetworkListObserver { 49 class NetworkListObserver {
43 public: 50 public:
44 virtual ~NetworkListObserver() { } 51 virtual ~NetworkListObserver() { }
45 52
46 virtual void OnNetworkListChanged( 53 virtual void OnNetworkListChanged(
(...skipping 14 matching lines...) Expand all
61 // network configuration changes. 68 // network configuration changes.
62 void AddNetworkListObserver(NetworkListObserver* network_list_observer); 69 void AddNetworkListObserver(NetworkListObserver* network_list_observer);
63 70
64 // Removes network list observer. 71 // Removes network list observer.
65 void RemoveNetworkListObserver(NetworkListObserver* network_list_observer); 72 void RemoveNetworkListObserver(NetworkListObserver* network_list_observer);
66 73
67 // RenderViewObserver overrides. 74 // RenderViewObserver overrides.
68 virtual bool OnMessageReceived(const IPC::Message& message); 75 virtual bool OnMessageReceived(const IPC::Message& message);
69 76
70 private: 77 private:
78 friend class P2PHostAddressRequest;
71 friend class P2PSocketClient; 79 friend class P2PSocketClient;
72 80
81 base::MessageLoopProxy* message_loop();
82
73 // Called by P2PSocketClient. 83 // Called by P2PSocketClient.
74 int RegisterClient(P2PSocketClient* client); 84 int RegisterClient(P2PSocketClient* client);
75 void UnregisterClient(int id); 85 void UnregisterClient(int id);
76 void SendP2PMessage(IPC::Message* msg); 86 void SendP2PMessage(IPC::Message* msg);
77 base::MessageLoopProxy* message_loop(); 87
88 // Called by DnsRequest.
89 int RegisterHostAddressRequest(P2PHostAddressRequest* request);
90 void UnregisterHostAddressRequest(int id);
78 91
79 // Incoming message handlers. 92 // Incoming message handlers.
80 void OnNetworkListChanged(const net::NetworkInterfaceList& networks); 93 void OnNetworkListChanged(const net::NetworkInterfaceList& networks);
94 void OnGetHostAddressResult(int32 request_id,
95 const net::IPAddressNumber& address);
81 void OnSocketCreated(int socket_id, const net::IPEndPoint& address); 96 void OnSocketCreated(int socket_id, const net::IPEndPoint& address);
82 void OnIncomingTcpConnection(int socket_id, const net::IPEndPoint& address); 97 void OnIncomingTcpConnection(int socket_id, const net::IPEndPoint& address);
83 void OnError(int socket_id); 98 void OnError(int socket_id);
84 void OnDataReceived(int socket_id, const net::IPEndPoint& address, 99 void OnDataReceived(int socket_id, const net::IPEndPoint& address,
85 const std::vector<char>& data); 100 const std::vector<char>& data);
86 101
87 P2PSocketClient* GetClient(int socket_id); 102 P2PSocketClient* GetClient(int socket_id);
88 103
89 scoped_refptr<base::MessageLoopProxy> message_loop_; 104 scoped_refptr<base::MessageLoopProxy> message_loop_;
90 IDMap<P2PSocketClient> clients_; 105 IDMap<P2PSocketClient> clients_;
91 106
107 IDMap<P2PHostAddressRequest> host_address_requests_;
108
92 bool network_notifications_started_; 109 bool network_notifications_started_;
93 scoped_refptr<ObserverListThreadSafe<NetworkListObserver> > 110 scoped_refptr<ObserverListThreadSafe<NetworkListObserver> >
94 network_list_observers_; 111 network_list_observers_;
95 112
96 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher); 113 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher);
97 }; 114 };
98 115
99 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ 116 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_
OLDNEW
« no previous file with comments | « content/renderer/p2p/host_address_request.cc ('k') | content/renderer/p2p/socket_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698