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. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 namespace webkit_glue { | 46 namespace webkit_glue { |
47 class NetworkListObserver; | 47 class NetworkListObserver; |
48 } // webkit_glue | 48 } // webkit_glue |
49 | 49 |
50 namespace content { | 50 namespace content { |
51 | 51 |
52 class P2PHostAddressRequest; | 52 class P2PHostAddressRequest; |
53 class P2PSocketClient; | 53 class P2PSocketClient; |
54 | 54 |
| 55 // Callback interface that allows the implementor to be notified before a |
| 56 // P2PSocketDispatcher is destroyed. |
| 57 // P2PSocketDispatcher requires that all NetworkListObservers are |
| 58 // unregistered when SocketDispatcherGone is called. |
| 59 class P2PSocketDispatcherDestructionObserver { |
| 60 public: |
| 61 virtual void OnSocketDispatcherDestroyed() = 0; |
| 62 |
| 63 protected: |
| 64 virtual ~P2PSocketDispatcherDestructionObserver() {} |
| 65 }; |
| 66 |
55 class CONTENT_EXPORT P2PSocketDispatcher : public content::RenderViewObserver { | 67 class CONTENT_EXPORT P2PSocketDispatcher : public content::RenderViewObserver { |
56 public: | 68 public: |
57 explicit P2PSocketDispatcher(RenderViewImpl* render_view); | 69 explicit P2PSocketDispatcher(RenderViewImpl* render_view); |
58 virtual ~P2PSocketDispatcher(); | 70 virtual ~P2PSocketDispatcher(); |
59 | 71 |
60 // Add a new network list observer. Each observer is called | 72 // Add a new network list observer. Each observer is called |
61 // immidiately after it is registered and then later whenever | 73 // immidiately after it is registered and then later whenever |
62 // network configuration changes. Can be called on any thread. The | 74 // network configuration changes. Can be called on any thread. The |
63 // observer is always called on the thread it was added. | 75 // observer is always called on the thread it was added. |
64 void AddNetworkListObserver( | 76 void AddNetworkListObserver( |
65 webkit_glue::NetworkListObserver* network_list_observer); | 77 webkit_glue::NetworkListObserver* network_list_observer); |
66 | 78 |
67 // Removes network list observer. Must be called on the thread on | 79 // Removes network list observer. Must be called on the thread on |
68 // which the observer was added. | 80 // which the observer was added. |
69 void RemoveNetworkListObserver( | 81 void RemoveNetworkListObserver( |
70 webkit_glue::NetworkListObserver* network_list_observer); | 82 webkit_glue::NetworkListObserver* network_list_observer); |
71 | 83 |
| 84 void AddDestructionObserver(P2PSocketDispatcherDestructionObserver* observer); |
| 85 void RemoveDestructionObserver( |
| 86 P2PSocketDispatcherDestructionObserver* observer); |
| 87 |
72 // RenderViewObserver overrides. | 88 // RenderViewObserver overrides. |
73 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 89 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
74 | 90 |
75 private: | 91 private: |
76 friend class P2PHostAddressRequest; | 92 friend class P2PHostAddressRequest; |
77 friend class P2PSocketClient; | 93 friend class P2PSocketClient; |
78 class AsyncMessageSender; | 94 class AsyncMessageSender; |
79 | 95 |
80 base::MessageLoopProxy* message_loop(); | 96 base::MessageLoopProxy* message_loop(); |
81 | 97 |
(...skipping 22 matching lines...) Expand all Loading... |
104 IDMap<P2PSocketClient> clients_; | 120 IDMap<P2PSocketClient> clients_; |
105 | 121 |
106 IDMap<P2PHostAddressRequest> host_address_requests_; | 122 IDMap<P2PHostAddressRequest> host_address_requests_; |
107 | 123 |
108 bool network_notifications_started_; | 124 bool network_notifications_started_; |
109 scoped_refptr<ObserverListThreadSafe<webkit_glue::NetworkListObserver> > | 125 scoped_refptr<ObserverListThreadSafe<webkit_glue::NetworkListObserver> > |
110 network_list_observers_; | 126 network_list_observers_; |
111 | 127 |
112 scoped_refptr<AsyncMessageSender> async_message_sender_; | 128 scoped_refptr<AsyncMessageSender> async_message_sender_; |
113 | 129 |
| 130 ObserverList<P2PSocketDispatcherDestructionObserver> destruction_observer_; |
| 131 |
114 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher); | 132 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher); |
115 }; | 133 }; |
116 | 134 |
117 } // namespace content | 135 } // namespace content |
118 | 136 |
119 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ | 137 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ |
OLD | NEW |