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

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

Issue 1142063003: content/child: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix. Created 5 years, 7 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
« no previous file with comments | « content/renderer/p2p/socket_client_impl.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) 2012 The Chromium Authors. All rights reserved. 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 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.
(...skipping 17 matching lines...) Expand all
28 #include "base/id_map.h" 28 #include "base/id_map.h"
29 #include "base/observer_list_threadsafe.h" 29 #include "base/observer_list_threadsafe.h"
30 #include "base/synchronization/lock.h" 30 #include "base/synchronization/lock.h"
31 #include "content/common/content_export.h" 31 #include "content/common/content_export.h"
32 #include "content/common/p2p_socket_type.h" 32 #include "content/common/p2p_socket_type.h"
33 #include "content/renderer/p2p/network_list_manager.h" 33 #include "content/renderer/p2p/network_list_manager.h"
34 #include "ipc/message_filter.h" 34 #include "ipc/message_filter.h"
35 #include "net/base/net_util.h" 35 #include "net/base/net_util.h"
36 36
37 namespace base { 37 namespace base {
38 class MessageLoopProxy; 38 class SingleThreadTaskRunner;
39 } // namespace base 39 } // namespace base
40 40
41 namespace net { 41 namespace net {
42 class IPEndPoint; 42 class IPEndPoint;
43 } // namespace net 43 } // namespace net
44 44
45 namespace content { 45 namespace content {
46 46
47 class NetworkListObserver; 47 class NetworkListObserver;
48 class P2PAsyncAddressResolver; 48 class P2PAsyncAddressResolver;
49 class P2PSocketClientImpl; 49 class P2PSocketClientImpl;
50 class RenderViewImpl; 50 class RenderViewImpl;
51 51
52 class CONTENT_EXPORT P2PSocketDispatcher : public IPC::MessageFilter, 52 class CONTENT_EXPORT P2PSocketDispatcher : public IPC::MessageFilter,
53 public NetworkListManager { 53 public NetworkListManager {
54 public: 54 public:
55 explicit P2PSocketDispatcher(base::MessageLoopProxy* ipc_message_loop); 55 explicit P2PSocketDispatcher(base::SingleThreadTaskRunner* ipc_task_runner);
56 56
57 // NetworkListManager interface: 57 // NetworkListManager interface:
58 void AddNetworkListObserver( 58 void AddNetworkListObserver(
59 NetworkListObserver* network_list_observer) override; 59 NetworkListObserver* network_list_observer) override;
60 void RemoveNetworkListObserver( 60 void RemoveNetworkListObserver(
61 NetworkListObserver* network_list_observer) override; 61 NetworkListObserver* network_list_observer) override;
62 62
63 protected: 63 protected:
64 ~P2PSocketDispatcher() override; 64 ~P2PSocketDispatcher() override;
65 65
66 private: 66 private:
67 friend class P2PAsyncAddressResolver; 67 friend class P2PAsyncAddressResolver;
68 friend class P2PSocketClientImpl; 68 friend class P2PSocketClientImpl;
69 69
70 // Send a message asynchronously. 70 // Send a message asynchronously.
71 virtual void Send(IPC::Message* message); 71 virtual void Send(IPC::Message* message);
72 72
73 // IPC::MessageFilter override. Called on IO thread. 73 // IPC::MessageFilter override. Called on IO thread.
74 bool OnMessageReceived(const IPC::Message& message) override; 74 bool OnMessageReceived(const IPC::Message& message) override;
75 void OnFilterAdded(IPC::Sender* sender) override; 75 void OnFilterAdded(IPC::Sender* sender) override;
76 void OnFilterRemoved() override; 76 void OnFilterRemoved() override;
77 void OnChannelClosing() override; 77 void OnChannelClosing() override;
78 78
79 // Returns the IO message loop. 79 base::SingleThreadTaskRunner* task_runner();
80 base::MessageLoopProxy* message_loop();
81 80
82 // Called by P2PSocketClient. 81 // Called by P2PSocketClient.
83 int RegisterClient(P2PSocketClientImpl* client); 82 int RegisterClient(P2PSocketClientImpl* client);
84 void UnregisterClient(int id); 83 void UnregisterClient(int id);
85 void SendP2PMessage(IPC::Message* msg); 84 void SendP2PMessage(IPC::Message* msg);
86 85
87 // Called by DnsRequest. 86 // Called by DnsRequest.
88 int RegisterHostAddressRequest(P2PAsyncAddressResolver* request); 87 int RegisterHostAddressRequest(P2PAsyncAddressResolver* request);
89 void UnregisterHostAddressRequest(int id); 88 void UnregisterHostAddressRequest(int id);
90 89
91 // Incoming message handlers. 90 // Incoming message handlers.
92 void OnNetworkListChanged(const net::NetworkInterfaceList& networks); 91 void OnNetworkListChanged(const net::NetworkInterfaceList& networks);
93 void OnGetHostAddressResult(int32 request_id, 92 void OnGetHostAddressResult(int32 request_id,
94 const net::IPAddressList& addresses); 93 const net::IPAddressList& addresses);
95 void OnSocketCreated(int socket_id, 94 void OnSocketCreated(int socket_id,
96 const net::IPEndPoint& local_address, 95 const net::IPEndPoint& local_address,
97 const net::IPEndPoint& remote_address); 96 const net::IPEndPoint& remote_address);
98 void OnIncomingTcpConnection(int socket_id, const net::IPEndPoint& address); 97 void OnIncomingTcpConnection(int socket_id, const net::IPEndPoint& address);
99 void OnSendComplete(int socket_id, const P2PSendPacketMetrics& send_metrics); 98 void OnSendComplete(int socket_id, const P2PSendPacketMetrics& send_metrics);
100 void OnError(int socket_id); 99 void OnError(int socket_id);
101 void OnDataReceived(int socket_id, const net::IPEndPoint& address, 100 void OnDataReceived(int socket_id, const net::IPEndPoint& address,
102 const std::vector<char>& data, 101 const std::vector<char>& data,
103 const base::TimeTicks& timestamp); 102 const base::TimeTicks& timestamp);
104 103
105 P2PSocketClientImpl* GetClient(int socket_id); 104 P2PSocketClientImpl* GetClient(int socket_id);
106 105
107 scoped_refptr<base::MessageLoopProxy> message_loop_; 106 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_;
108 IDMap<P2PSocketClientImpl> clients_; 107 IDMap<P2PSocketClientImpl> clients_;
109 108
110 IDMap<P2PAsyncAddressResolver> host_address_requests_; 109 IDMap<P2PAsyncAddressResolver> host_address_requests_;
111 110
112 bool network_notifications_started_; 111 bool network_notifications_started_;
113 scoped_refptr<ObserverListThreadSafe<NetworkListObserver> > 112 scoped_refptr<ObserverListThreadSafe<NetworkListObserver> >
114 network_list_observers_; 113 network_list_observers_;
115 114
116 IPC::Sender* sender_; 115 IPC::Sender* sender_;
117 116
118 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher); 117 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher);
119 }; 118 };
120 119
121 } // namespace content 120 } // namespace content
122 121
123 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ 122 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_
OLDNEW
« no previous file with comments | « content/renderer/p2p/socket_client_impl.cc ('k') | content/renderer/p2p/socket_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698