OLD | NEW |
---|---|
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. |
11 // | 11 // |
12 // P2PSocketHost P2PSocketClient | 12 // P2PSocketHost P2PSocketClient |
13 // ^ ^ | 13 // ^ ^ |
14 // | | | 14 // | | |
15 // v IPC v | 15 // v IPC v |
16 // P2PSocketDispatcherHost <---------> P2PSocketDispatcher | 16 // P2PSocketDispatcherHost <---------> P2PSocketDispatcher |
17 // | 17 // |
18 // P2PSocketDispatcher receives and dispatches messages on the | |
19 // renderer thread. | |
18 | 20 |
19 #ifndef CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ | 21 #ifndef CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ |
20 #define CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ | 22 #define CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ |
21 | 23 |
22 #include <vector> | 24 #include <vector> |
23 | 25 |
24 #include "base/callback_forward.h" | 26 #include "base/callback_forward.h" |
25 #include "base/compiler_specific.h" | 27 #include "base/compiler_specific.h" |
26 #include "base/id_map.h" | 28 #include "base/id_map.h" |
27 #include "base/observer_list_threadsafe.h" | 29 #include "base/observer_list_threadsafe.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
43 | 45 |
44 namespace webkit_glue { | 46 namespace webkit_glue { |
45 class NetworkListObserver; | 47 class NetworkListObserver; |
46 } // webkit_glue | 48 } // webkit_glue |
47 | 49 |
48 namespace content { | 50 namespace content { |
49 | 51 |
50 class P2PHostAddressRequest; | 52 class P2PHostAddressRequest; |
51 class P2PSocketClient; | 53 class P2PSocketClient; |
52 | 54 |
53 // P2PSocketDispatcher works on the renderer thread. It dispatches all | |
54 // messages on that thread, and all its methods must be called on the | |
55 // same thread. | |
56 class CONTENT_EXPORT P2PSocketDispatcher : public content::RenderViewObserver { | 55 class CONTENT_EXPORT P2PSocketDispatcher : public content::RenderViewObserver { |
57 public: | 56 public: |
58 explicit P2PSocketDispatcher(RenderViewImpl* render_view); | 57 explicit P2PSocketDispatcher(RenderViewImpl* render_view); |
59 virtual ~P2PSocketDispatcher(); | 58 virtual ~P2PSocketDispatcher(); |
60 | 59 |
61 // Add a new network list observer. Each observer is called | 60 // Add a new network list observer. Each observer is called |
62 // immidiately after it is registered and then later whenever | 61 // immidiately after it is registered and then later whenever |
63 // network configuration changes. | 62 // network configuration changes. Can be called on any thread. |
perkj_chrome
2012/04/17 07:22:59
On what thread is the callback called? On the same
Sergey Ulanov
2012/04/17 17:34:37
Done.
| |
64 void AddNetworkListObserver( | 63 void AddNetworkListObserver( |
65 webkit_glue::NetworkListObserver* network_list_observer); | 64 webkit_glue::NetworkListObserver* network_list_observer); |
66 | 65 |
67 // Removes network list observer. | 66 // Removes network list observer. Can be called on any thread. |
68 void RemoveNetworkListObserver( | 67 void RemoveNetworkListObserver( |
69 webkit_glue::NetworkListObserver* network_list_observer); | 68 webkit_glue::NetworkListObserver* network_list_observer); |
70 | 69 |
71 // RenderViewObserver overrides. | 70 // RenderViewObserver overrides. |
72 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 71 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
73 | 72 |
74 private: | 73 private: |
75 friend class P2PHostAddressRequest; | 74 friend class P2PHostAddressRequest; |
76 friend class P2PSocketClient; | 75 friend class P2PSocketClient; |
77 class AsyncMessageSender; | 76 class AsyncMessageSender; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 network_list_observers_; | 108 network_list_observers_; |
110 | 109 |
111 scoped_refptr<AsyncMessageSender> async_message_sender_; | 110 scoped_refptr<AsyncMessageSender> async_message_sender_; |
112 | 111 |
113 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher); | 112 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher); |
114 }; | 113 }; |
115 | 114 |
116 } // namespace content | 115 } // namespace content |
117 | 116 |
118 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ | 117 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ |
OLD | NEW |