OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_RENDERER_P2P_SOCKETS_DISPATCHER_H_ | |
6 #define CHROME_RENDERER_P2P_SOCKETS_DISPATCHER_H_ | |
7 | |
awong
2011/03/01 20:21:55
We need a comment showing how these classes intera
Sergey Ulanov
2011/03/02 16:12:29
Done.
| |
8 #include <vector> | |
9 | |
10 #include "base/id_map.h" | |
11 #include "chrome/common/p2p_sockets.h" | |
12 #include "chrome/renderer/p2p/socket_client.h" | |
13 #include "ipc/ipc_channel_proxy.h" | |
14 | |
15 class P2PSocketsDispatcher : public IPC::ChannelProxy::MessageFilter { | |
awong
2011/03/01 20:21:55
Aren't these usually named XXXXFilter? So P2pSock
Alpha Left Google
2011/03/01 21:32:20
Looks like this lives on the IO thread, please com
Sergey Ulanov
2011/03/02 16:12:29
Done.
Sergey Ulanov
2011/03/02 16:12:29
There are many that are named Dispatcher. I think
| |
16 public: | |
17 explicit P2PSocketsDispatcher(int32 routing_id); | |
18 virtual ~P2PSocketsDispatcher(); | |
19 | |
20 P2PSocketClient* CreateSocket(P2PSocketType type, P2PSocketAddress address, | |
21 P2PSocketClient::Delegate* delegate); | |
22 | |
23 // IPC::ChannelProxy::MessageFilter implementation. | |
24 virtual bool OnMessageReceived(const IPC::Message& message); | |
25 virtual void OnFilterAdded(IPC::Channel* channel); | |
26 virtual void OnFilterRemoved(); | |
27 virtual void OnChannelClosing(); | |
28 | |
29 private: | |
30 friend class P2PSocketClient; | |
31 | |
32 // Called by P2PSocketClient. | |
33 int RegisterClient(P2PSocketClient* client); | |
34 void UnregisterClient(int id); | |
35 void Send(IPC::Message* msg); | |
36 MessageLoop* message_loop(); | |
37 | |
38 // Incoming message handlers. | |
39 void OnSocketCreated(int socket_id, P2PSocketAddress address); | |
40 void OnError(int socket_id); | |
41 void OnDataReceived(int socket_id, P2PSocketAddress address, | |
42 const std::vector<char>& data); | |
43 | |
44 P2PSocketClient* GetClient(int socket_id); | |
45 | |
46 IPC::Channel* channel_; | |
47 int32 routing_id_; | |
48 MessageLoop* message_loop_; | |
49 IDMap<P2PSocketClient> clients_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(P2PSocketsDispatcher); | |
52 }; | |
53 | |
54 #endif // CHROME_RENDERER_P2P_SOCKETS_DISPATCHER_H_ | |
OLD | NEW |