Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / content / browser / renderer_host / p2p / socket_dispatcher_host.h
blob1f456915b24bfd20fb1cb109c5b02797119fe6b8
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_DISPATCHER_HOST_H_
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <vector>
13 #include "content/browser/renderer_host/p2p/socket_host_throttler.h"
14 #include "content/common/p2p_socket_type.h"
15 #include "content/public/browser/browser_message_filter.h"
16 #include "content/public/browser/browser_thread.h"
17 #include "net/base/ip_endpoint.h"
18 #include "net/base/network_change_notifier.h"
20 namespace net {
21 class URLRequestContextGetter;
24 namespace talk_base {
25 struct PacketOptions;
28 namespace content {
30 class P2PSocketHost;
31 class ResourceContext;
33 class P2PSocketDispatcherHost
34 : public content::BrowserMessageFilter,
35 public net::NetworkChangeNotifier::IPAddressObserver {
36 public:
37 P2PSocketDispatcherHost(content::ResourceContext* resource_context,
38 net::URLRequestContextGetter* url_context);
40 // content::BrowserMessageFilter overrides.
41 virtual void OnChannelClosing() OVERRIDE;
42 virtual void OnDestruct() const OVERRIDE;
43 virtual bool OnMessageReceived(const IPC::Message& message,
44 bool* message_was_ok) OVERRIDE;
46 // net::NetworkChangeNotifier::IPAddressObserver interface.
47 virtual void OnIPAddressChanged() OVERRIDE;
49 protected:
50 virtual ~P2PSocketDispatcherHost();
52 private:
53 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
54 friend class base::DeleteHelper<P2PSocketDispatcherHost>;
56 typedef std::map<int, P2PSocketHost*> SocketsMap;
58 class DnsRequest;
60 P2PSocketHost* LookupSocket(int socket_id);
62 // Handlers for the messages coming from the renderer.
63 void OnStartNetworkNotifications(const IPC::Message& msg);
64 void OnStopNetworkNotifications(const IPC::Message& msg);
66 void OnGetHostAddress(const std::string& host_name,
67 int32 request_id);
69 void OnCreateSocket(P2PSocketType type,
70 int socket_id,
71 const net::IPEndPoint& local_address,
72 const P2PHostAndIPEndPoint& remote_address);
73 void OnAcceptIncomingTcpConnection(int listen_socket_id,
74 const net::IPEndPoint& remote_address,
75 int connected_socket_id);
76 void OnSend(int socket_id,
77 const net::IPEndPoint& socket_address,
78 const std::vector<char>& data,
79 const talk_base::PacketOptions& options,
80 uint64 packet_id);
81 void OnSetOption(int socket_id, P2PSocketOption option, int value);
82 void OnDestroySocket(int socket_id);
84 void DoGetNetworkList();
85 void SendNetworkList(const net::NetworkInterfaceList& list);
87 void OnAddressResolved(DnsRequest* request,
88 const net::IPAddressList& addresses);
90 content::ResourceContext* resource_context_;
91 scoped_refptr<net::URLRequestContextGetter> url_context_;
93 SocketsMap sockets_;
95 bool monitoring_networks_;
97 std::set<DnsRequest*> dns_requests_;
98 P2PMessageThrottler throttler_;
100 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcherHost);
103 } // namespace content
105 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_DISPATCHER_HOST_H_