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

Side by Side Diff: content/browser/renderer_host/p2p/socket_dispatcher_host.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
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 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_DISPATCHER_HOST_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "content/browser/browser_message_filter.h" 10 #include "content/browser/browser_message_filter.h"
11 #include "content/common/p2p_sockets.h" 11 #include "content/common/p2p_sockets.h"
12 #include "net/base/ip_endpoint.h" 12 #include "net/base/ip_endpoint.h"
13 #include "net/base/network_change_notifier.h" 13 #include "net/base/network_change_notifier.h"
14 14
15 namespace content {
16 class ResourceContext;
17 } // namespace content
18
15 class P2PSocketHost; 19 class P2PSocketHost;
16 20
17 class P2PSocketDispatcherHost 21 class P2PSocketDispatcherHost
18 : public BrowserMessageFilter, 22 : public BrowserMessageFilter,
19 public net::NetworkChangeNotifier::IPAddressObserver { 23 public net::NetworkChangeNotifier::IPAddressObserver {
20 public: 24 public:
21 P2PSocketDispatcherHost(); 25 P2PSocketDispatcherHost(const content::ResourceContext* resource_context);
22 virtual ~P2PSocketDispatcherHost(); 26 virtual ~P2PSocketDispatcherHost();
23 27
24 // BrowserMessageFilter overrides. 28 // BrowserMessageFilter overrides.
25 virtual void OnChannelClosing() OVERRIDE; 29 virtual void OnChannelClosing() OVERRIDE;
26 virtual void OnDestruct() const OVERRIDE; 30 virtual void OnDestruct() const OVERRIDE;
27 virtual bool OnMessageReceived(const IPC::Message& message, 31 virtual bool OnMessageReceived(const IPC::Message& message,
28 bool* message_was_ok) OVERRIDE; 32 bool* message_was_ok) OVERRIDE;
29 33
30 // net::NetworkChangeNotifier::IPAddressObserver interface. 34 // net::NetworkChangeNotifier::IPAddressObserver interface.
31 virtual void OnIPAddressChanged() OVERRIDE; 35 virtual void OnIPAddressChanged() OVERRIDE;
32 36
33 private: 37 private:
34 typedef std::pair<int32, int> ExtendedSocketId; 38 typedef std::pair<int32, int> ExtendedSocketId;
35 typedef std::map<ExtendedSocketId, P2PSocketHost*> SocketsMap; 39 typedef std::map<ExtendedSocketId, P2PSocketHost*> SocketsMap;
36 40
41 class DnsRequest;
42
37 P2PSocketHost* LookupSocket(int32 routing_id, int socket_id); 43 P2PSocketHost* LookupSocket(int32 routing_id, int socket_id);
38 44
39 // Handlers for the messages coming from the renderer. 45 // Handlers for the messages coming from the renderer.
40 void OnStartNetworkNotifications(const IPC::Message& msg); 46 void OnStartNetworkNotifications(const IPC::Message& msg);
41 void OnStopNetworkNotifications(const IPC::Message& msg); 47 void OnStopNetworkNotifications(const IPC::Message& msg);
42 48
49 void OnGetHostAddress(const IPC::Message& msg,
50 const std::string& host_name,
51 int32 request_id);
52
43 void OnCreateSocket(const IPC::Message& msg, 53 void OnCreateSocket(const IPC::Message& msg,
44 P2PSocketType type, 54 P2PSocketType type,
45 int socket_id, 55 int socket_id,
46 const net::IPEndPoint& local_address, 56 const net::IPEndPoint& local_address,
47 const net::IPEndPoint& remote_address); 57 const net::IPEndPoint& remote_address);
48 void OnAcceptIncomingTcpConnection(const IPC::Message& msg, 58 void OnAcceptIncomingTcpConnection(const IPC::Message& msg,
49 int listen_socket_id, 59 int listen_socket_id,
50 const net::IPEndPoint& remote_address, 60 const net::IPEndPoint& remote_address,
51 int connected_socket_id); 61 int connected_socket_id);
52 void OnSend(const IPC::Message& msg, int socket_id, 62 void OnSend(const IPC::Message& msg, int socket_id,
53 const net::IPEndPoint& socket_address, 63 const net::IPEndPoint& socket_address,
54 const std::vector<char>& data); 64 const std::vector<char>& data);
55 void OnDestroySocket(const IPC::Message& msg, int socket_id); 65 void OnDestroySocket(const IPC::Message& msg, int socket_id);
56 66
57 void DoGetNetworkList(); 67 void DoGetNetworkList();
58 void SendNetworkList(const net::NetworkInterfaceList& list); 68 void SendNetworkList(const net::NetworkInterfaceList& list);
59 69
70 void OnAddressResolved(DnsRequest* request,
71 const net::IPAddressNumber& result);
72
73 const content::ResourceContext* resource_context_;
74
60 SocketsMap sockets_; 75 SocketsMap sockets_;
61 76
62 bool monitoring_networks_; 77 bool monitoring_networks_;
63 78
64 // List or routing IDs for the hosts that have subscribed to the 79 // List or routing IDs for the hosts that have subscribed to the
65 // network list notifications. 80 // network list notifications.
66 std::set<int> notifications_routing_ids_; 81 std::set<int> notifications_routing_ids_;
67 82
83 std::set<DnsRequest*> dns_requests_;
84
68 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcherHost); 85 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcherHost);
69 }; 86 };
70 87
71 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_DISPATCHER_HOST_H_ 88 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698