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

Side by Side Diff: content/renderer/media/rtc_peer_connection_handler.cc

Issue 292163002: Destroy all rtc peer connection handlers before shutting down blink (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 6 years, 7 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/renderer/media/rtc_peer_connection_handler.h" 5 #include "content/renderer/media/rtc_peer_connection_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/lazy_instance.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
16 #include "base/stl_util.h" 17 #include "base/stl_util.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
19 #include "content/renderer/media/media_stream_track.h" 20 #include "content/renderer/media/media_stream_track.h"
20 #include "content/renderer/media/peer_connection_tracker.h" 21 #include "content/renderer/media/peer_connection_tracker.h"
21 #include "content/renderer/media/remote_media_stream_impl.h" 22 #include "content/renderer/media/remote_media_stream_impl.h"
22 #include "content/renderer/media/rtc_data_channel_handler.h" 23 #include "content/renderer/media/rtc_data_channel_handler.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 double timestamp) { 310 double timestamp) {
310 return impl_.addReport(type, id, timestamp); 311 return impl_.addReport(type, id, timestamp);
311 } 312 }
312 313
313 void LocalRTCStatsResponse::addStatistic(size_t report, 314 void LocalRTCStatsResponse::addStatistic(size_t report,
314 blink::WebString name, 315 blink::WebString name,
315 blink::WebString value) { 316 blink::WebString value) {
316 impl_.addStatistic(report, name, value); 317 impl_.addStatistic(report, name, value);
317 } 318 }
318 319
320 namespace {
321
322 base::LazyInstance<std::set<RTCPeerConnectionHandler*> >::Leaky
323 g_peer_connection_handlers = LAZY_INSTANCE_INITIALIZER;
324
325 } // namespace
326
319 RTCPeerConnectionHandler::RTCPeerConnectionHandler( 327 RTCPeerConnectionHandler::RTCPeerConnectionHandler(
320 blink::WebRTCPeerConnectionHandlerClient* client, 328 blink::WebRTCPeerConnectionHandlerClient* client,
321 PeerConnectionDependencyFactory* dependency_factory) 329 PeerConnectionDependencyFactory* dependency_factory)
322 : client_(client), 330 : client_(client),
323 dependency_factory_(dependency_factory), 331 dependency_factory_(dependency_factory),
324 frame_(NULL), 332 frame_(NULL),
325 peer_connection_tracker_(NULL), 333 peer_connection_tracker_(NULL),
326 num_data_channels_created_(0) { 334 num_data_channels_created_(0) {
335 g_peer_connection_handlers.Get().insert(this);
327 } 336 }
328 337
329 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { 338 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() {
339 g_peer_connection_handlers.Get().erase(this);
330 if (peer_connection_tracker_) 340 if (peer_connection_tracker_)
331 peer_connection_tracker_->UnregisterPeerConnection(this); 341 peer_connection_tracker_->UnregisterPeerConnection(this);
332 STLDeleteValues(&remote_streams_); 342 STLDeleteValues(&remote_streams_);
333 343
334 UMA_HISTOGRAM_COUNTS_10000( 344 UMA_HISTOGRAM_COUNTS_10000(
335 "WebRTC.NumDataChannelsPerPeerConnection", num_data_channels_created_); 345 "WebRTC.NumDataChannelsPerPeerConnection", num_data_channels_created_);
336 } 346 }
337 347
348 // static
349 void RTCPeerConnectionHandler::DestructAllHandlers() {
350 std::set<RTCPeerConnectionHandler*> handlers(
351 g_peer_connection_handlers.Get().begin(),
352 g_peer_connection_handlers.Get().end());
353 for (std::set<RTCPeerConnectionHandler*>::iterator handler = handlers.begin();
354 handler != handlers.end();
355 ++handler) {
356 (*handler)->client_->releasePeerConnectionHandler();
357 }
358 }
359
338 void RTCPeerConnectionHandler::associateWithFrame(blink::WebFrame* frame) { 360 void RTCPeerConnectionHandler::associateWithFrame(blink::WebFrame* frame) {
339 DCHECK(frame); 361 DCHECK(frame);
340 frame_ = frame; 362 frame_ = frame;
341 } 363 }
342 364
343 bool RTCPeerConnectionHandler::initialize( 365 bool RTCPeerConnectionHandler::initialize(
344 const blink::WebRTCConfiguration& server_configuration, 366 const blink::WebRTCConfiguration& server_configuration,
345 const blink::WebMediaConstraints& options) { 367 const blink::WebMediaConstraints& options) {
346 DCHECK(frame_); 368 DCHECK(frame_);
347 369
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 webrtc::SessionDescriptionInterface* native_desc = 883 webrtc::SessionDescriptionInterface* native_desc =
862 dependency_factory_->CreateSessionDescription(type, sdp, error); 884 dependency_factory_->CreateSessionDescription(type, sdp, error);
863 885
864 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." 886 LOG_IF(ERROR, !native_desc) << "Failed to create native session description."
865 << " Type: " << type << " SDP: " << sdp; 887 << " Type: " << type << " SDP: " << sdp;
866 888
867 return native_desc; 889 return native_desc;
868 } 890 }
869 891
870 } // namespace content 892 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698