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

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

Issue 307063003: Revert 273745 "Implements RTP header dumping." due to memory leak (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 | Annotate | Revision Log
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) {
105 } 103 }
106 104
107 void P2PSocketDispatcherHost::OnChannelClosing() { 105 void P2PSocketDispatcherHost::OnChannelClosing() {
108 // Since the IPC channel is gone, close pending connections. 106 // Since the IPC channel is gone, close pending connections.
109 STLDeleteContainerPairSecondPointers(sockets_.begin(), sockets_.end()); 107 STLDeleteContainerPairSecondPointers(sockets_.begin(), sockets_.end());
110 sockets_.clear(); 108 sockets_.clear();
111 109
112 STLDeleteContainerPointers(dns_requests_.begin(), dns_requests_.end()); 110 STLDeleteContainerPointers(dns_requests_.begin(), dns_requests_.end());
113 dns_requests_.clear(); 111 dns_requests_.clear();
114 112
(...skipping 26 matching lines...) Expand all
141 return handled; 139 return handled;
142 } 140 }
143 141
144 void P2PSocketDispatcherHost::OnIPAddressChanged() { 142 void P2PSocketDispatcherHost::OnIPAddressChanged() {
145 // Notify the renderer about changes to list of network interfaces. 143 // Notify the renderer about changes to list of network interfaces.
146 BrowserThread::PostTask( 144 BrowserThread::PostTask(
147 BrowserThread::FILE, FROM_HERE, base::Bind( 145 BrowserThread::FILE, FROM_HERE, base::Bind(
148 &P2PSocketDispatcherHost::DoGetNetworkList, this)); 146 &P2PSocketDispatcherHost::DoGetNetworkList, this));
149 } 147 }
150 148
151 void P2PSocketDispatcherHost::StartRtpDump(
152 bool incoming,
153 bool outgoing,
154 const RenderProcessHost::WebRtcRtpPacketCallback& packet_callback) {
155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
156
157 if ((!dump_incoming_rtp_packet_ && incoming) ||
158 (!dump_outgoing_rtp_packet_ && outgoing)) {
159 if (incoming)
160 dump_incoming_rtp_packet_ = true;
161
162 if (outgoing)
163 dump_outgoing_rtp_packet_ = true;
164
165 packet_callback_ = packet_callback;
166 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it)
167 it->second->StartRtpDump(incoming, outgoing, packet_callback);
168 }
169 }
170
171 void P2PSocketDispatcherHost::StopRtpDumpOnUIThread(bool incoming,
172 bool outgoing) {
173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
174 BrowserThread::PostTask(
175 BrowserThread::IO,
176 FROM_HERE,
177 base::Bind(&P2PSocketDispatcherHost::StopRtpDumpOnIOThread,
178 this,
179 incoming,
180 outgoing));
181 }
182
183 P2PSocketDispatcherHost::~P2PSocketDispatcherHost() { 149 P2PSocketDispatcherHost::~P2PSocketDispatcherHost() {
184 DCHECK(sockets_.empty()); 150 DCHECK(sockets_.empty());
185 DCHECK(dns_requests_.empty()); 151 DCHECK(dns_requests_.empty());
186 152
187 if (monitoring_networks_) 153 if (monitoring_networks_)
188 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 154 net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
189 } 155 }
190 156
191 P2PSocketHost* P2PSocketDispatcherHost::LookupSocket(int socket_id) { 157 P2PSocketHost* P2PSocketDispatcherHost::LookupSocket(int socket_id) {
192 SocketsMap::iterator it = sockets_.find(socket_id); 158 SocketsMap::iterator it = sockets_.find(socket_id);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 scoped_ptr<P2PSocketHost> socket(P2PSocketHost::Create( 200 scoped_ptr<P2PSocketHost> socket(P2PSocketHost::Create(
235 this, socket_id, type, url_context_.get(), &throttler_)); 201 this, socket_id, type, url_context_.get(), &throttler_));
236 202
237 if (!socket) { 203 if (!socket) {
238 Send(new P2PMsg_OnError(socket_id)); 204 Send(new P2PMsg_OnError(socket_id));
239 return; 205 return;
240 } 206 }
241 207
242 if (socket->Init(local_address, remote_address)) { 208 if (socket->Init(local_address, remote_address)) {
243 sockets_[socket_id] = socket.release(); 209 sockets_[socket_id] = socket.release();
244
245 if (dump_incoming_rtp_packet_ || dump_outgoing_rtp_packet_) {
246 sockets_[socket_id]->StartRtpDump(dump_incoming_rtp_packet_,
247 dump_outgoing_rtp_packet_,
248 packet_callback_);
249 }
250 } 210 }
251 } 211 }
252 212
253 void P2PSocketDispatcherHost::OnAcceptIncomingTcpConnection( 213 void P2PSocketDispatcherHost::OnAcceptIncomingTcpConnection(
254 int listen_socket_id, const net::IPEndPoint& remote_address, 214 int listen_socket_id, const net::IPEndPoint& remote_address,
255 int connected_socket_id) { 215 int connected_socket_id) {
256 P2PSocketHost* socket = LookupSocket(listen_socket_id); 216 P2PSocketHost* socket = LookupSocket(listen_socket_id);
257 if (!socket) { 217 if (!socket) {
258 LOG(ERROR) << "Received P2PHostMsg_AcceptIncomingTcpConnection " 218 LOG(ERROR) << "Received P2PHostMsg_AcceptIncomingTcpConnection "
259 "for invalid socket_id."; 219 "for invalid socket_id.";
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 287
328 void P2PSocketDispatcherHost::OnAddressResolved( 288 void P2PSocketDispatcherHost::OnAddressResolved(
329 DnsRequest* request, 289 DnsRequest* request,
330 const net::IPAddressList& addresses) { 290 const net::IPAddressList& addresses) {
331 Send(new P2PMsg_GetHostAddressResult(request->request_id(), addresses)); 291 Send(new P2PMsg_GetHostAddressResult(request->request_id(), addresses));
332 292
333 dns_requests_.erase(request); 293 dns_requests_.erase(request);
334 delete request; 294 delete request;
335 } 295 }
336 296
337 void P2PSocketDispatcherHost::StopRtpDumpOnIOThread(bool incoming,
338 bool outgoing) {
339 if ((dump_incoming_rtp_packet_ && incoming) ||
340 (dump_outgoing_rtp_packet_ && outgoing)) {
341 if (incoming)
342 dump_incoming_rtp_packet_ = false;
343
344 if (outgoing)
345 dump_outgoing_rtp_packet_ = false;
346
347 if (!dump_incoming_rtp_packet_ && !dump_outgoing_rtp_packet_)
348 packet_callback_.Reset();
349
350 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it)
351 it->second->StopRtpDump(incoming, outgoing);
352 }
353 }
354
355 } // namespace content 297 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698