Ignore non-active fullscreen windows for shelf state.
[chromium-blink-merge.git] / content / browser / renderer_host / p2p / socket_dispatcher_host.h
blob813da993b9a58eae6b504855db48d0d5a1f7cf7b
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/public/browser/browser_message_filter.h"
15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/common/p2p_socket_type.h"
17 #include "net/base/ip_endpoint.h"
18 #include "net/base/network_change_notifier.h"
20 namespace net {
21 class URLRequestContextGetter;
24 namespace content {
26 class P2PSocketHost;
27 class ResourceContext;
29 class P2PSocketDispatcherHost
30 : public content::BrowserMessageFilter,
31 public net::NetworkChangeNotifier::IPAddressObserver {
32 public:
33 P2PSocketDispatcherHost(content::ResourceContext* resource_context,
34 net::URLRequestContextGetter* url_context);
36 // content::BrowserMessageFilter overrides.
37 virtual void OnChannelClosing() OVERRIDE;
38 virtual void OnDestruct() const OVERRIDE;
39 virtual bool OnMessageReceived(const IPC::Message& message,
40 bool* message_was_ok) OVERRIDE;
42 // net::NetworkChangeNotifier::IPAddressObserver interface.
43 virtual void OnIPAddressChanged() OVERRIDE;
45 protected:
46 virtual ~P2PSocketDispatcherHost();
48 private:
49 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
50 friend class base::DeleteHelper<P2PSocketDispatcherHost>;
52 typedef std::map<int, P2PSocketHost*> SocketsMap;
54 class DnsRequest;
56 P2PSocketHost* LookupSocket(int socket_id);
58 // Handlers for the messages coming from the renderer.
59 void OnStartNetworkNotifications(const IPC::Message& msg);
60 void OnStopNetworkNotifications(const IPC::Message& msg);
62 void OnGetHostAddress(const std::string& host_name,
63 int32 request_id);
65 void OnCreateSocket(P2PSocketType type,
66 int socket_id,
67 const net::IPEndPoint& local_address,
68 const net::IPEndPoint& remote_address);
69 void OnAcceptIncomingTcpConnection(int listen_socket_id,
70 const net::IPEndPoint& remote_address,
71 int connected_socket_id);
72 void OnSend(int socket_id,
73 const net::IPEndPoint& socket_address,
74 const std::vector<char>& data,
75 net::DiffServCodePoint dscp,
76 uint64 packet_id);
77 void OnDestroySocket(int socket_id);
79 void DoGetNetworkList();
80 void SendNetworkList(const net::NetworkInterfaceList& list);
82 void OnAddressResolved(DnsRequest* request,
83 const net::IPAddressNumber& result);
85 content::ResourceContext* resource_context_;
86 scoped_refptr<net::URLRequestContextGetter> url_context_;
88 SocketsMap sockets_;
90 bool monitoring_networks_;
92 std::set<DnsRequest*> dns_requests_;
93 P2PMessageThrottler throttler_;
95 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcherHost);
98 } // namespace content
100 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_DISPATCHER_HOST_H_