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 #include "content/renderer/p2p/socket_dispatcher.h" | 5 #include "content/renderer/p2p/socket_dispatcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "content/child/child_process.h" | 9 #include "content/child/child_process.h" |
10 #include "content/common/p2p_messages.h" | 10 #include "content/common/p2p_messages.h" |
11 #include "content/renderer/p2p/host_address_request.h" | 11 #include "content/renderer/p2p/host_address_request.h" |
12 #include "content/renderer/p2p/network_list_observer.h" | 12 #include "content/renderer/p2p/network_list_observer.h" |
13 #include "content/renderer/p2p/socket_client_impl.h" | 13 #include "content/renderer/p2p/socket_client_impl.h" |
14 #include "content/renderer/render_view_impl.h" | 14 #include "content/renderer/render_view_impl.h" |
15 #include "ipc/ipc_sender.h" | 15 #include "ipc/ipc_sender.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 P2PSocketDispatcher::P2PSocketDispatcher( | 19 P2PSocketDispatcher::P2PSocketDispatcher( |
20 base::SingleThreadTaskRunner* ipc_task_runner) | 20 base::SingleThreadTaskRunner* ipc_task_runner) |
21 : ipc_task_runner_(ipc_task_runner), | 21 : ipc_task_runner_(ipc_task_runner), |
22 network_notifications_started_(false), | 22 network_notifications_started_(false), |
23 network_list_observers_( | 23 network_list_observers_( |
24 new base::ObserverListThreadSafe<NetworkListObserver>()), | 24 new base::ObserverListThreadSafe<NetworkListObserver>()), |
25 sender_(NULL) { | 25 sender_(NULL) { |
26 } | 26 } |
27 | 27 |
28 P2PSocketDispatcher::~P2PSocketDispatcher() { | 28 P2PSocketDispatcher::~P2PSocketDispatcher() { |
29 network_list_observers_->AssertEmpty(); | 29 network_list_observers_->AssertEmpty(); |
30 for (IDMap<P2PSocketClientImpl>::iterator i(&clients_); !i.IsAtEnd(); | 30 for (IDMap<P2PSocketClientImpl*>::iterator i(&clients_); !i.IsAtEnd(); |
31 i.Advance()) { | 31 i.Advance()) { |
32 i.GetCurrentValue()->Detach(); | 32 i.GetCurrentValue()->Detach(); |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 void P2PSocketDispatcher::AddNetworkListObserver( | 36 void P2PSocketDispatcher::AddNetworkListObserver( |
37 NetworkListObserver* network_list_observer) { | 37 NetworkListObserver* network_list_observer) { |
38 network_list_observers_->AddObserver(network_list_observer); | 38 network_list_observers_->AddObserver(network_list_observer); |
39 network_notifications_started_ = true; | 39 network_notifications_started_ = true; |
40 SendP2PMessage(new P2PHostMsg_StartNetworkNotifications()); | 40 SendP2PMessage(new P2PHostMsg_StartNetworkNotifications()); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // hasn't processed the close message by the time it sends the | 195 // hasn't processed the close message by the time it sends the |
196 // message to the renderer. | 196 // message to the renderer. |
197 DVLOG(1) << "Received P2P message for socket that doesn't exist."; | 197 DVLOG(1) << "Received P2P message for socket that doesn't exist."; |
198 return NULL; | 198 return NULL; |
199 } | 199 } |
200 | 200 |
201 return client; | 201 return client; |
202 } | 202 } |
203 | 203 |
204 } // namespace content | 204 } // namespace content |
OLD | NEW |