| 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/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/common/p2p_messages.h" | 10 #include "content/common/p2p_messages.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return handled; | 141 return handled; |
| 142 } | 142 } |
| 143 | 143 |
| 144 void P2PSocketDispatcherHost::OnIPAddressChanged() { | 144 void P2PSocketDispatcherHost::OnIPAddressChanged() { |
| 145 // Notify the renderer about changes to list of network interfaces. | 145 // Notify the renderer about changes to list of network interfaces. |
| 146 BrowserThread::PostTask( | 146 BrowserThread::PostTask( |
| 147 BrowserThread::FILE, FROM_HERE, base::Bind( | 147 BrowserThread::FILE, FROM_HERE, base::Bind( |
| 148 &P2PSocketDispatcherHost::DoGetNetworkList, this)); | 148 &P2PSocketDispatcherHost::DoGetNetworkList, this)); |
| 149 } | 149 } |
| 150 | 150 |
| 151 #if defined(ENABLE_WEBRTC) |
| 151 void P2PSocketDispatcherHost::StartRtpDump( | 152 void P2PSocketDispatcherHost::StartRtpDump( |
| 152 bool incoming, | 153 bool incoming, |
| 153 bool outgoing, | 154 bool outgoing, |
| 154 const RenderProcessHost::WebRtcRtpPacketCallback& packet_callback) { | 155 const RenderProcessHost::WebRtcRtpPacketCallback& packet_callback) { |
| 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 156 | 157 |
| 157 if ((!dump_incoming_rtp_packet_ && incoming) || | 158 if ((!dump_incoming_rtp_packet_ && incoming) || |
| 158 (!dump_outgoing_rtp_packet_ && outgoing)) { | 159 (!dump_outgoing_rtp_packet_ && outgoing)) { |
| 159 if (incoming) | 160 if (incoming) |
| 160 dump_incoming_rtp_packet_ = true; | 161 dump_incoming_rtp_packet_ = true; |
| 161 | 162 |
| 162 if (outgoing) | 163 if (outgoing) |
| 163 dump_outgoing_rtp_packet_ = true; | 164 dump_outgoing_rtp_packet_ = true; |
| 164 | 165 |
| 165 packet_callback_ = packet_callback; | 166 packet_callback_ = packet_callback; |
| 166 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it) | 167 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it) |
| 167 it->second->StartRtpDump(incoming, outgoing, packet_callback); | 168 it->second->StartRtpDump(incoming, outgoing, packet_callback); |
| 168 } | 169 } |
| 169 } | 170 } |
| 171 #endif |
| 170 | 172 |
| 173 #if defined(ENABLE_WEBRTC) |
| 171 void P2PSocketDispatcherHost::StopRtpDumpOnUIThread(bool incoming, | 174 void P2PSocketDispatcherHost::StopRtpDumpOnUIThread(bool incoming, |
| 172 bool outgoing) { | 175 bool outgoing) { |
| 173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 174 BrowserThread::PostTask( | 177 BrowserThread::PostTask( |
| 175 BrowserThread::IO, | 178 BrowserThread::IO, |
| 176 FROM_HERE, | 179 FROM_HERE, |
| 177 base::Bind(&P2PSocketDispatcherHost::StopRtpDumpOnIOThread, | 180 base::Bind(&P2PSocketDispatcherHost::StopRtpDumpOnIOThread, |
| 178 this, | 181 this, |
| 179 incoming, | 182 incoming, |
| 180 outgoing)); | 183 outgoing)); |
| 181 } | 184 } |
| 185 #endif |
| 182 | 186 |
| 183 P2PSocketDispatcherHost::~P2PSocketDispatcherHost() { | 187 P2PSocketDispatcherHost::~P2PSocketDispatcherHost() { |
| 184 DCHECK(sockets_.empty()); | 188 DCHECK(sockets_.empty()); |
| 185 DCHECK(dns_requests_.empty()); | 189 DCHECK(dns_requests_.empty()); |
| 186 | 190 |
| 187 if (monitoring_networks_) | 191 if (monitoring_networks_) |
| 188 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | 192 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
| 189 } | 193 } |
| 190 | 194 |
| 191 P2PSocketHost* P2PSocketDispatcherHost::LookupSocket(int socket_id) { | 195 P2PSocketHost* P2PSocketDispatcherHost::LookupSocket(int socket_id) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 350 |
| 347 if (!dump_incoming_rtp_packet_ && !dump_outgoing_rtp_packet_) | 351 if (!dump_incoming_rtp_packet_ && !dump_outgoing_rtp_packet_) |
| 348 packet_callback_.Reset(); | 352 packet_callback_.Reset(); |
| 349 | 353 |
| 350 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it) | 354 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it) |
| 351 it->second->StopRtpDump(incoming, outgoing); | 355 it->second->StopRtpDump(incoming, outgoing); |
| 352 } | 356 } |
| 353 } | 357 } |
| 354 | 358 |
| 355 } // namespace content | 359 } // namespace content |
| OLD | NEW |