| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/browser/renderer_host/p2p/socket_dispatcher_host.h" | 5 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "content/browser/renderer_host/p2p/socket_host.h" | 9 #include "content/browser/renderer_host/p2p/socket_host.h" |
| 10 #include "content/browser/resource_context.h" | 10 #include "content/browser/resource_context.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 void P2PSocketDispatcherHost::OnStartNetworkNotifications( | 161 void P2PSocketDispatcherHost::OnStartNetworkNotifications( |
| 162 const IPC::Message& msg) { | 162 const IPC::Message& msg) { |
| 163 if (!monitoring_networks_) { | 163 if (!monitoring_networks_) { |
| 164 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 164 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| 165 monitoring_networks_ = true; | 165 monitoring_networks_ = true; |
| 166 } | 166 } |
| 167 | 167 |
| 168 notifications_routing_ids_.insert(msg.routing_id()); | 168 notifications_routing_ids_.insert(msg.routing_id()); |
| 169 | 169 |
| 170 BrowserThread::PostTask( | 170 BrowserThread::PostTask( |
| 171 BrowserThread::FILE, FROM_HERE, NewRunnableMethod( | 171 BrowserThread::FILE, FROM_HERE, base::Bind( |
| 172 this, &P2PSocketDispatcherHost::DoGetNetworkList)); | 172 &P2PSocketDispatcherHost::DoGetNetworkList, this)); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void P2PSocketDispatcherHost::OnStopNetworkNotifications( | 175 void P2PSocketDispatcherHost::OnStopNetworkNotifications( |
| 176 const IPC::Message& msg) { | 176 const IPC::Message& msg) { |
| 177 notifications_routing_ids_.erase(msg.routing_id()); | 177 notifications_routing_ids_.erase(msg.routing_id()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void P2PSocketDispatcherHost::OnIPAddressChanged() { | 180 void P2PSocketDispatcherHost::OnIPAddressChanged() { |
| 181 // Notify the renderer about changes to list of network interfaces. | 181 // Notify the renderer about changes to list of network interfaces. |
| 182 BrowserThread::PostTask( | 182 BrowserThread::PostTask( |
| 183 BrowserThread::FILE, FROM_HERE, NewRunnableMethod( | 183 BrowserThread::FILE, FROM_HERE, base::Bind( |
| 184 this, &P2PSocketDispatcherHost::DoGetNetworkList)); | 184 &P2PSocketDispatcherHost::DoGetNetworkList, this)); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void P2PSocketDispatcherHost::DoGetNetworkList() { | 187 void P2PSocketDispatcherHost::DoGetNetworkList() { |
| 188 net::NetworkInterfaceList list; | 188 net::NetworkInterfaceList list; |
| 189 net::GetNetworkList(&list); | 189 net::GetNetworkList(&list); |
| 190 BrowserThread::PostTask( | 190 BrowserThread::PostTask( |
| 191 BrowserThread::IO, FROM_HERE, NewRunnableMethod( | 191 BrowserThread::IO, FROM_HERE, base::Bind( |
| 192 this, &P2PSocketDispatcherHost::SendNetworkList, list)); | 192 &P2PSocketDispatcherHost::SendNetworkList, this, list)); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void P2PSocketDispatcherHost::SendNetworkList( | 195 void P2PSocketDispatcherHost::SendNetworkList( |
| 196 const net::NetworkInterfaceList& list) { | 196 const net::NetworkInterfaceList& list) { |
| 197 for (std::set<int>::iterator it = notifications_routing_ids_.begin(); | 197 for (std::set<int>::iterator it = notifications_routing_ids_.begin(); |
| 198 it != notifications_routing_ids_.end(); ++it) { | 198 it != notifications_routing_ids_.end(); ++it) { |
| 199 Send(new P2PMsg_NetworkListChanged(*it, list)); | 199 Send(new P2PMsg_NetworkListChanged(*it, list)); |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 ExtendedSocketId(msg.routing_id(), socket_id)); | 280 ExtendedSocketId(msg.routing_id(), socket_id)); |
| 281 if (it != sockets_.end()) { | 281 if (it != sockets_.end()) { |
| 282 delete it->second; | 282 delete it->second; |
| 283 sockets_.erase(it); | 283 sockets_.erase(it); |
| 284 } else { | 284 } else { |
| 285 LOG(ERROR) << "Received P2PHostMsg_DestroySocket for invalid socket_id."; | 285 LOG(ERROR) << "Received P2PHostMsg_DestroySocket for invalid socket_id."; |
| 286 } | 286 } |
| 287 } | 287 } |
| 288 | 288 |
| 289 } // namespace content | 289 } // namespace content |
| OLD | NEW |