Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(989)

Side by Side Diff: content/browser/renderer_host/p2p/socket_dispatcher_host.cc

Issue 264793017: Implements RTP header dumping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix leak Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 DoneCallback done_callback_; 93 DoneCallback done_callback_;
94 }; 94 };
95 95
96 P2PSocketDispatcherHost::P2PSocketDispatcherHost( 96 P2PSocketDispatcherHost::P2PSocketDispatcherHost(
97 content::ResourceContext* resource_context, 97 content::ResourceContext* resource_context,
98 net::URLRequestContextGetter* url_context) 98 net::URLRequestContextGetter* url_context)
99 : BrowserMessageFilter(P2PMsgStart), 99 : BrowserMessageFilter(P2PMsgStart),
100 resource_context_(resource_context), 100 resource_context_(resource_context),
101 url_context_(url_context), 101 url_context_(url_context),
102 monitoring_networks_(false) { 102 monitoring_networks_(false),
103 dump_incoming_rtp_packet_(false),
104 dump_outgoing_rtp_packet_(false) {
103 } 105 }
104 106
105 void P2PSocketDispatcherHost::OnChannelClosing() { 107 void P2PSocketDispatcherHost::OnChannelClosing() {
106 // Since the IPC channel is gone, close pending connections. 108 // Since the IPC channel is gone, close pending connections.
107 STLDeleteContainerPairSecondPointers(sockets_.begin(), sockets_.end()); 109 STLDeleteContainerPairSecondPointers(sockets_.begin(), sockets_.end());
108 sockets_.clear(); 110 sockets_.clear();
109 111
110 STLDeleteContainerPointers(dns_requests_.begin(), dns_requests_.end()); 112 STLDeleteContainerPointers(dns_requests_.begin(), dns_requests_.end());
111 dns_requests_.clear(); 113 dns_requests_.clear();
112 114
(...skipping 27 matching lines...) Expand all
140 return handled; 142 return handled;
141 } 143 }
142 144
143 void P2PSocketDispatcherHost::OnIPAddressChanged() { 145 void P2PSocketDispatcherHost::OnIPAddressChanged() {
144 // Notify the renderer about changes to list of network interfaces. 146 // Notify the renderer about changes to list of network interfaces.
145 BrowserThread::PostTask( 147 BrowserThread::PostTask(
146 BrowserThread::FILE, FROM_HERE, base::Bind( 148 BrowserThread::FILE, FROM_HERE, base::Bind(
147 &P2PSocketDispatcherHost::DoGetNetworkList, this)); 149 &P2PSocketDispatcherHost::DoGetNetworkList, this));
148 } 150 }
149 151
152 void P2PSocketDispatcherHost::StartRtpDump(
153 bool incoming,
154 bool outgoing,
155 const RenderProcessHost::WebRtcRtpPacketCallback& packet_callback) {
156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
157
158 if ((!dump_incoming_rtp_packet_ && incoming) ||
159 (!dump_outgoing_rtp_packet_ && outgoing)) {
160 if (incoming)
161 dump_incoming_rtp_packet_ = true;
162
163 if (outgoing)
164 dump_outgoing_rtp_packet_ = true;
165
166 packet_callback_ = packet_callback;
167 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it)
168 it->second->StartRtpDump(incoming, outgoing, packet_callback);
169 }
170 }
171
172 void P2PSocketDispatcherHost::StopRtpDumpOnUIThread(bool incoming,
173 bool outgoing) {
174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
175 BrowserThread::PostTask(
176 BrowserThread::IO,
177 FROM_HERE,
178 base::Bind(&P2PSocketDispatcherHost::StopRtpDumpOnIOThread,
179 this,
180 incoming,
181 outgoing));
182 }
183
150 P2PSocketDispatcherHost::~P2PSocketDispatcherHost() { 184 P2PSocketDispatcherHost::~P2PSocketDispatcherHost() {
151 DCHECK(sockets_.empty()); 185 DCHECK(sockets_.empty());
152 DCHECK(dns_requests_.empty()); 186 DCHECK(dns_requests_.empty());
153 187
154 if (monitoring_networks_) 188 if (monitoring_networks_)
155 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 189 net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
156 } 190 }
157 191
158 P2PSocketHost* P2PSocketDispatcherHost::LookupSocket(int socket_id) { 192 P2PSocketHost* P2PSocketDispatcherHost::LookupSocket(int socket_id) {
159 SocketsMap::iterator it = sockets_.find(socket_id); 193 SocketsMap::iterator it = sockets_.find(socket_id);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 scoped_ptr<P2PSocketHost> socket(P2PSocketHost::Create( 237 scoped_ptr<P2PSocketHost> socket(P2PSocketHost::Create(
204 this, socket_id, type, url_context_.get(), &throttler_)); 238 this, socket_id, type, url_context_.get(), &throttler_));
205 239
206 if (!socket) { 240 if (!socket) {
207 Send(new P2PMsg_OnError(socket_id)); 241 Send(new P2PMsg_OnError(socket_id));
208 return; 242 return;
209 } 243 }
210 244
211 if (socket->Init(local_address, remote_address)) { 245 if (socket->Init(local_address, remote_address)) {
212 sockets_[socket_id] = socket.release(); 246 sockets_[socket_id] = socket.release();
247
248 if (dump_incoming_rtp_packet_ || dump_outgoing_rtp_packet_) {
249 sockets_[socket_id]->StartRtpDump(dump_incoming_rtp_packet_,
250 dump_outgoing_rtp_packet_,
251 packet_callback_);
252 }
213 } 253 }
214 } 254 }
215 255
216 void P2PSocketDispatcherHost::OnAcceptIncomingTcpConnection( 256 void P2PSocketDispatcherHost::OnAcceptIncomingTcpConnection(
217 int listen_socket_id, const net::IPEndPoint& remote_address, 257 int listen_socket_id, const net::IPEndPoint& remote_address,
218 int connected_socket_id) { 258 int connected_socket_id) {
219 P2PSocketHost* socket = LookupSocket(listen_socket_id); 259 P2PSocketHost* socket = LookupSocket(listen_socket_id);
220 if (!socket) { 260 if (!socket) {
221 LOG(ERROR) << "Received P2PHostMsg_AcceptIncomingTcpConnection " 261 LOG(ERROR) << "Received P2PHostMsg_AcceptIncomingTcpConnection "
222 "for invalid socket_id."; 262 "for invalid socket_id.";
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 330
291 void P2PSocketDispatcherHost::OnAddressResolved( 331 void P2PSocketDispatcherHost::OnAddressResolved(
292 DnsRequest* request, 332 DnsRequest* request,
293 const net::IPAddressList& addresses) { 333 const net::IPAddressList& addresses) {
294 Send(new P2PMsg_GetHostAddressResult(request->request_id(), addresses)); 334 Send(new P2PMsg_GetHostAddressResult(request->request_id(), addresses));
295 335
296 dns_requests_.erase(request); 336 dns_requests_.erase(request);
297 delete request; 337 delete request;
298 } 338 }
299 339
340 void P2PSocketDispatcherHost::StopRtpDumpOnIOThread(bool incoming,
341 bool outgoing) {
342 if ((dump_incoming_rtp_packet_ && incoming) ||
343 (dump_outgoing_rtp_packet_ && outgoing)) {
344 if (incoming)
345 dump_incoming_rtp_packet_ = false;
346
347 if (outgoing)
348 dump_outgoing_rtp_packet_ = false;
349
350 if (!dump_incoming_rtp_packet_ && !dump_outgoing_rtp_packet_)
351 packet_callback_.Reset();
352
353 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it)
354 it->second->StopRtpDump(incoming, outgoing);
355 }
356 }
357
300 } // namespace content 358 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/p2p/socket_dispatcher_host.h ('k') | content/browser/renderer_host/p2p/socket_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698