Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / renderer_host / p2p / socket_dispatcher_host.h
blob18b18df22721a047bd76d035057fe2e4f81d816a
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 "content/public/browser/render_process_host.h"
18 #include "net/base/ip_endpoint.h"
19 #include "net/base/network_change_notifier.h"
21 namespace net {
22 class URLRequestContextGetter;
25 namespace rtc {
26 struct PacketOptions;
29 namespace content {
31 class P2PSocketHost;
32 class ResourceContext;
34 class P2PSocketDispatcherHost
35 : public content::BrowserMessageFilter,
36 public net::NetworkChangeNotifier::IPAddressObserver {
37 public:
38 P2PSocketDispatcherHost(content::ResourceContext* resource_context,
39 net::URLRequestContextGetter* url_context);
41 // content::BrowserMessageFilter overrides.
42 void OnChannelClosing() override;
43 void OnDestruct() const override;
44 bool OnMessageReceived(const IPC::Message& message) override;
46 // net::NetworkChangeNotifier::IPAddressObserver interface.
47 void OnIPAddressChanged() override;
49 // Starts the RTP packet header dumping. Must be called on the IO thread.
50 void StartRtpDump(
51 bool incoming,
52 bool outgoing,
53 const RenderProcessHost::WebRtcRtpPacketCallback& packet_callback);
55 // Stops the RTP packet header dumping. Must be Called on the UI thread.
56 void StopRtpDumpOnUIThread(bool incoming, bool outgoing);
58 protected:
59 ~P2PSocketDispatcherHost() override;
61 private:
62 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
63 friend class base::DeleteHelper<P2PSocketDispatcherHost>;
65 typedef std::map<int, P2PSocketHost*> SocketsMap;
67 class DnsRequest;
69 P2PSocketHost* LookupSocket(int socket_id);
71 // Handlers for the messages coming from the renderer.
72 void OnStartNetworkNotifications();
73 void OnStopNetworkNotifications();
74 void OnGetHostAddress(const std::string& host_name,
75 int32 request_id);
77 void OnCreateSocket(P2PSocketType type,
78 int socket_id,
79 const net::IPEndPoint& local_address,
80 const P2PHostAndIPEndPoint& remote_address);
81 void OnAcceptIncomingTcpConnection(int listen_socket_id,
82 const net::IPEndPoint& remote_address,
83 int connected_socket_id);
84 void OnSend(int socket_id,
85 const net::IPEndPoint& socket_address,
86 const std::vector<char>& data,
87 const rtc::PacketOptions& options,
88 uint64 packet_id);
89 void OnSetOption(int socket_id, P2PSocketOption option, int value);
90 void OnDestroySocket(int socket_id);
92 void DoGetNetworkList();
93 void SendNetworkList(const net::NetworkInterfaceList& list);
95 void OnAddressResolved(DnsRequest* request,
96 const net::IPAddressList& addresses);
98 void StopRtpDumpOnIOThread(bool incoming, bool outgoing);
100 content::ResourceContext* resource_context_;
101 scoped_refptr<net::URLRequestContextGetter> url_context_;
103 SocketsMap sockets_;
105 bool monitoring_networks_;
107 std::set<DnsRequest*> dns_requests_;
108 P2PMessageThrottler throttler_;
110 bool dump_incoming_rtp_packet_;
111 bool dump_outgoing_rtp_packet_;
112 RenderProcessHost::WebRtcRtpPacketCallback packet_callback_;
114 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcherHost);
117 } // namespace content
119 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_DISPATCHER_HOST_H_