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 deleted. | |
57 // P2PSocketDispatcher requires that all NetworkListObservers are | |
58 // unregistered when SocketDispatcherGone is called. | |
59 class P2PSocketDispatcherObserver { | |
Sergey Ulanov
2012/05/17 18:20:15
Can this be defined inside of P2PSocketDispatcher?
perkj_chrome
2012/05/18 07:54:25
Yes, but last time I did it triggered this long di
Sergey Ulanov
2012/05/21 17:57:19
Well, that's very arguable rule, not everybody agr
| |
60 public: | |
61 virtual void SocketDispatcherGone() = 0; | |
Sergey Ulanov
2012/05/17 18:20:15
OnSocketDispatcherDestroyed()
perkj_chrome
2012/05/18 07:54:25
Done.
| |
62 | |
63 protected: | |
64 ~P2PSocketDispatcherObserver() {} | |
Sergey Ulanov
2012/05/17 18:20:15
virtual
perkj_chrome
2012/05/18 07:54:25
ok, this is something that comes up from time to t
Sergey Ulanov
2012/05/21 17:57:19
The style guide says that ALL interfaces must have
| |
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 AddDeletionObserver(P2PSocketDispatcherObserver* observer); | |
Sergey Ulanov
2012/05/17 18:20:15
Either the method should be called AddObserver() o
perkj_chrome
2012/05/18 07:54:25
Done.
| |
85 void RemoveDeletionObserver(P2PSocketDispatcherObserver* observer); | |
86 | |
72 // RenderViewObserver overrides. | 87 // RenderViewObserver overrides. |
73 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 88 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
74 | 89 |
75 private: | 90 private: |
76 friend class P2PHostAddressRequest; | 91 friend class P2PHostAddressRequest; |
77 friend class P2PSocketClient; | 92 friend class P2PSocketClient; |
78 class AsyncMessageSender; | 93 class AsyncMessageSender; |
79 | 94 |
80 base::MessageLoopProxy* message_loop(); | 95 base::MessageLoopProxy* message_loop(); |
81 | 96 |
(...skipping 21 matching lines...) Expand all Loading... | |
103 scoped_refptr<base::MessageLoopProxy> message_loop_; | 118 scoped_refptr<base::MessageLoopProxy> message_loop_; |
104 IDMap<P2PSocketClient> clients_; | 119 IDMap<P2PSocketClient> clients_; |
105 | 120 |
106 IDMap<P2PHostAddressRequest> host_address_requests_; | 121 IDMap<P2PHostAddressRequest> host_address_requests_; |
107 | 122 |
108 bool network_notifications_started_; | 123 bool network_notifications_started_; |
109 scoped_refptr<ObserverListThreadSafe<webkit_glue::NetworkListObserver> > | 124 scoped_refptr<ObserverListThreadSafe<webkit_glue::NetworkListObserver> > |
110 network_list_observers_; | 125 network_list_observers_; |
111 | 126 |
112 scoped_refptr<AsyncMessageSender> async_message_sender_; | 127 scoped_refptr<AsyncMessageSender> async_message_sender_; |
128 ObserverList<P2PSocketDispatcherObserver> deletion_observers_; | |
Sergey Ulanov
2012/05/17 18:20:15
nit: add empty line above this one.
perkj_chrome
2012/05/18 07:54:25
Done.
| |
113 | 129 |
114 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher); | 130 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher); |
115 }; | 131 }; |
116 | 132 |
117 } // namespace content | 133 } // namespace content |
118 | 134 |
119 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ | 135 #endif // CONTENT_RENDERER_P2P_SOCKET_DISPATCHER_H_ |
OLD | NEW |