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

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

Issue 2668813002: Remove LazyInstance usage from media/ (Closed)
Patch Set: Fix presubmit comments. Created 3 years, 10 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/renderer/media/rtc_peer_connection_handler.h" 5 #include "content/renderer/media/rtc_peer_connection_handler.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/lazy_instance.h"
15 #include "base/location.h" 14 #include "base/location.h"
16 #include "base/logging.h" 15 #include "base/logging.h"
17 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
18 #include "base/metrics/histogram_macros.h" 17 #include "base/metrics/histogram_macros.h"
19 #include "base/metrics/sparse_histogram.h" 18 #include "base/metrics/sparse_histogram.h"
20 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
21 #include "base/threading/thread_task_runner_handle.h" 20 #include "base/threading/thread_task_runner_handle.h"
22 #include "base/trace_event/trace_event.h" 21 #include "base/trace_event/trace_event.h"
23 #include "content/public/common/content_features.h" 22 #include "content/public/common/content_features.h"
24 #include "content/public/common/content_switches.h" 23 #include "content/public/common/content_switches.h"
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 constraints, &blink::WebMediaTrackConstraintSet::offerToReceiveVideo, 905 constraints, &blink::WebMediaTrackConstraintSet::offerToReceiveVideo,
907 &output->offer_to_receive_video); 906 &output->offer_to_receive_video);
908 GetConstraintValueAsBoolean( 907 GetConstraintValueAsBoolean(
909 constraints, &blink::WebMediaTrackConstraintSet::voiceActivityDetection, 908 constraints, &blink::WebMediaTrackConstraintSet::voiceActivityDetection,
910 &output->voice_activity_detection); 909 &output->voice_activity_detection);
911 GetConstraintValueAsBoolean(constraints, 910 GetConstraintValueAsBoolean(constraints,
912 &blink::WebMediaTrackConstraintSet::iceRestart, 911 &blink::WebMediaTrackConstraintSet::iceRestart,
913 &output->ice_restart); 912 &output->ice_restart);
914 } 913 }
915 914
916 base::LazyInstance<std::set<RTCPeerConnectionHandler*> >::Leaky 915 std::set<RTCPeerConnectionHandler*>* GetPeerConnectionHandlers() {
917 g_peer_connection_handlers = LAZY_INSTANCE_INITIALIZER; 916 static std::set<RTCPeerConnectionHandler*>* handlers =
917 new std::set<RTCPeerConnectionHandler*>();
918 return handlers;
919 }
918 920
919 } // namespace 921 } // namespace
920 922
921 // Implementation of LocalRTCStatsRequest. 923 // Implementation of LocalRTCStatsRequest.
922 LocalRTCStatsRequest::LocalRTCStatsRequest(blink::WebRTCStatsRequest impl) 924 LocalRTCStatsRequest::LocalRTCStatsRequest(blink::WebRTCStatsRequest impl)
923 : impl_(impl) { 925 : impl_(impl) {
924 } 926 }
925 927
926 LocalRTCStatsRequest::LocalRTCStatsRequest() {} 928 LocalRTCStatsRequest::LocalRTCStatsRequest() {}
927 LocalRTCStatsRequest::~LocalRTCStatsRequest() {} 929 LocalRTCStatsRequest::~LocalRTCStatsRequest() {}
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_; 1090 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_;
1089 }; 1091 };
1090 1092
1091 RTCPeerConnectionHandler::RTCPeerConnectionHandler( 1093 RTCPeerConnectionHandler::RTCPeerConnectionHandler(
1092 blink::WebRTCPeerConnectionHandlerClient* client, 1094 blink::WebRTCPeerConnectionHandlerClient* client,
1093 PeerConnectionDependencyFactory* dependency_factory) 1095 PeerConnectionDependencyFactory* dependency_factory)
1094 : client_(client), 1096 : client_(client),
1095 is_closed_(false), 1097 is_closed_(false),
1096 dependency_factory_(dependency_factory), 1098 dependency_factory_(dependency_factory),
1097 weak_factory_(this) { 1099 weak_factory_(this) {
1098 CHECK(client_), 1100 CHECK(client_);
1099 g_peer_connection_handlers.Get().insert(this); 1101 GetPeerConnectionHandlers()->insert(this);
1100 } 1102 }
1101 1103
1102 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { 1104 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() {
1103 DCHECK(thread_checker_.CalledOnValidThread()); 1105 DCHECK(thread_checker_.CalledOnValidThread());
1104 1106
1105 stop(); 1107 stop();
1106 1108
1107 g_peer_connection_handlers.Get().erase(this); 1109 GetPeerConnectionHandlers()->erase(this);
1108 if (peer_connection_tracker_) 1110 if (peer_connection_tracker_)
1109 peer_connection_tracker_->UnregisterPeerConnection(this); 1111 peer_connection_tracker_->UnregisterPeerConnection(this);
1110 1112
1111 UMA_HISTOGRAM_COUNTS_10000( 1113 UMA_HISTOGRAM_COUNTS_10000(
1112 "WebRTC.NumDataChannelsPerPeerConnection", num_data_channels_created_); 1114 "WebRTC.NumDataChannelsPerPeerConnection", num_data_channels_created_);
1113 } 1115 }
1114 1116
1115 // static 1117 // static
1116 void RTCPeerConnectionHandler::DestructAllHandlers() { 1118 void RTCPeerConnectionHandler::DestructAllHandlers() {
1117 // Copy g_peer_connection_handlers since releasePeerConnectionHandler will 1119 // Copy g_peer_connection_handlers since releasePeerConnectionHandler will
1118 // remove an item. 1120 // remove an item.
1119 std::set<RTCPeerConnectionHandler*> handlers( 1121 std::set<RTCPeerConnectionHandler*> handlers(
1120 g_peer_connection_handlers.Get().begin(), 1122 GetPeerConnectionHandlers()->begin(), GetPeerConnectionHandlers()->end());
1121 g_peer_connection_handlers.Get().end());
1122 for (auto* handler : handlers) 1123 for (auto* handler : handlers)
1123 handler->client_->releasePeerConnectionHandler(); 1124 handler->client_->releasePeerConnectionHandler();
1124 } 1125 }
1125 1126
1126 void RTCPeerConnectionHandler::associateWithFrame(blink::WebFrame* frame) { 1127 void RTCPeerConnectionHandler::associateWithFrame(blink::WebFrame* frame) {
1127 DCHECK(thread_checker_.CalledOnValidThread()); 1128 DCHECK(thread_checker_.CalledOnValidThread());
1128 DCHECK(frame); 1129 DCHECK(frame);
1129 frame_ = frame; 1130 frame_ = frame;
1130 } 1131 }
1131 1132
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 } 2005 }
2005 2006
2006 void RTCPeerConnectionHandler::ResetUMAStats() { 2007 void RTCPeerConnectionHandler::ResetUMAStats() {
2007 DCHECK(thread_checker_.CalledOnValidThread()); 2008 DCHECK(thread_checker_.CalledOnValidThread());
2008 num_local_candidates_ipv6_ = 0; 2009 num_local_candidates_ipv6_ = 0;
2009 num_local_candidates_ipv4_ = 0; 2010 num_local_candidates_ipv4_ = 0;
2010 ice_connection_checking_start_ = base::TimeTicks(); 2011 ice_connection_checking_start_ = base::TimeTicks();
2011 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); 2012 memset(ice_state_seen_, 0, sizeof(ice_state_seen_));
2012 } 2013 }
2013 } // namespace content 2014 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/render_media_client_unittest.cc ('k') | content/renderer/media/webrtc/rtc_stats.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698