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/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 Loading... | |
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 Loading... | |
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_), GetPeerConnectionHandlers()->insert(this); |
Mark Mentovai
2017/01/31 21:33:56
; would be more usual than , here.
DaleCurtis
2017/01/31 22:04:33
Whoops, surprised that compiled. Done.
| |
1099 g_peer_connection_handlers.Get().insert(this); | |
1100 } | 1101 } |
1101 | 1102 |
1102 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { | 1103 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { |
1103 DCHECK(thread_checker_.CalledOnValidThread()); | 1104 DCHECK(thread_checker_.CalledOnValidThread()); |
1104 | 1105 |
1105 stop(); | 1106 stop(); |
1106 | 1107 |
1107 g_peer_connection_handlers.Get().erase(this); | 1108 GetPeerConnectionHandlers()->erase(this); |
1108 if (peer_connection_tracker_) | 1109 if (peer_connection_tracker_) |
1109 peer_connection_tracker_->UnregisterPeerConnection(this); | 1110 peer_connection_tracker_->UnregisterPeerConnection(this); |
1110 | 1111 |
1111 UMA_HISTOGRAM_COUNTS_10000( | 1112 UMA_HISTOGRAM_COUNTS_10000( |
1112 "WebRTC.NumDataChannelsPerPeerConnection", num_data_channels_created_); | 1113 "WebRTC.NumDataChannelsPerPeerConnection", num_data_channels_created_); |
1113 } | 1114 } |
1114 | 1115 |
1115 // static | 1116 // static |
1116 void RTCPeerConnectionHandler::DestructAllHandlers() { | 1117 void RTCPeerConnectionHandler::DestructAllHandlers() { |
1117 // Copy g_peer_connection_handlers since releasePeerConnectionHandler will | 1118 // Copy g_peer_connection_handlers since releasePeerConnectionHandler will |
1118 // remove an item. | 1119 // remove an item. |
1119 std::set<RTCPeerConnectionHandler*> handlers( | 1120 std::set<RTCPeerConnectionHandler*> handlers( |
1120 g_peer_connection_handlers.Get().begin(), | 1121 GetPeerConnectionHandlers()->begin(), GetPeerConnectionHandlers()->end()); |
1121 g_peer_connection_handlers.Get().end()); | |
1122 for (auto* handler : handlers) | 1122 for (auto* handler : handlers) |
1123 handler->client_->releasePeerConnectionHandler(); | 1123 handler->client_->releasePeerConnectionHandler(); |
1124 } | 1124 } |
1125 | 1125 |
1126 void RTCPeerConnectionHandler::associateWithFrame(blink::WebFrame* frame) { | 1126 void RTCPeerConnectionHandler::associateWithFrame(blink::WebFrame* frame) { |
1127 DCHECK(thread_checker_.CalledOnValidThread()); | 1127 DCHECK(thread_checker_.CalledOnValidThread()); |
1128 DCHECK(frame); | 1128 DCHECK(frame); |
1129 frame_ = frame; | 1129 frame_ = frame; |
1130 } | 1130 } |
1131 | 1131 |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2004 } | 2004 } |
2005 | 2005 |
2006 void RTCPeerConnectionHandler::ResetUMAStats() { | 2006 void RTCPeerConnectionHandler::ResetUMAStats() { |
2007 DCHECK(thread_checker_.CalledOnValidThread()); | 2007 DCHECK(thread_checker_.CalledOnValidThread()); |
2008 num_local_candidates_ipv6_ = 0; | 2008 num_local_candidates_ipv6_ = 0; |
2009 num_local_candidates_ipv4_ = 0; | 2009 num_local_candidates_ipv4_ = 0; |
2010 ice_connection_checking_start_ = base::TimeTicks(); | 2010 ice_connection_checking_start_ = base::TimeTicks(); |
2011 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); | 2011 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); |
2012 } | 2012 } |
2013 } // namespace content | 2013 } // namespace content |
OLD | NEW |