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

Side by Side Diff: content/renderer/media/webrtc/rtc_stats.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
« no previous file with comments | « content/renderer/media/rtc_peer_connection_handler.cc ('k') | media/PRESUBMIT.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/webrtc/rtc_stats.h" 5 #include "content/renderer/media/webrtc/rtc_stats.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/lazy_instance.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "base/time/time.h" 11 #include "base/time/time.h"
13 #include "third_party/webrtc/api/stats/rtcstats_objects.h" 12 #include "third_party/webrtc/api/stats/rtcstats_objects.h"
14 13
15 namespace content { 14 namespace content {
16 15
17 namespace { 16 namespace {
18 17
19 class RTCStatsWhitelist { 18 class RTCStatsWhitelist {
20 public: 19 public:
(...skipping 20 matching lines...) Expand all
41 } 40 }
42 41
43 void WhitelistStatsForTesting(const char* type) { 42 void WhitelistStatsForTesting(const char* type) {
44 whitelisted_stats_types_.insert(type); 43 whitelisted_stats_types_.insert(type);
45 } 44 }
46 45
47 private: 46 private:
48 std::set<std::string> whitelisted_stats_types_; 47 std::set<std::string> whitelisted_stats_types_;
49 }; 48 };
50 49
51 base::LazyInstance<RTCStatsWhitelist>::Leaky 50 RTCStatsWhitelist* GetStatsWhitelist() {
52 g_whitelisted_stats = LAZY_INSTANCE_INITIALIZER; 51 static RTCStatsWhitelist* whitelist = new RTCStatsWhitelist();
52 return whitelist;
53 }
53 54
54 bool IsWhitelistedStats(const webrtc::RTCStats& stats) { 55 bool IsWhitelistedStats(const webrtc::RTCStats& stats) {
55 return g_whitelisted_stats.Get().IsWhitelisted(stats); 56 return GetStatsWhitelist()->IsWhitelisted(stats);
56 } 57 }
57 58
58 } // namespace 59 } // namespace
59 60
60 RTCStatsReport::RTCStatsReport( 61 RTCStatsReport::RTCStatsReport(
61 const scoped_refptr<const webrtc::RTCStatsReport>& stats_report) 62 const scoped_refptr<const webrtc::RTCStatsReport>& stats_report)
62 : stats_report_(stats_report), 63 : stats_report_(stats_report),
63 it_(stats_report_->begin()), 64 it_(stats_report_->begin()),
64 end_(stats_report_->end()) { 65 end_(stats_report_->end()) {
65 DCHECK(stats_report_); 66 DCHECK(stats_report_);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 DCHECK(isDefined()); 270 DCHECK(isDefined());
270 const std::vector<std::string>& sequence = 271 const std::vector<std::string>& sequence =
271 *member_->cast_to<webrtc::RTCStatsMember<std::vector<std::string>>>(); 272 *member_->cast_to<webrtc::RTCStatsMember<std::vector<std::string>>>();
272 blink::WebVector<blink::WebString> web_sequence(sequence.size()); 273 blink::WebVector<blink::WebString> web_sequence(sequence.size());
273 for (size_t i = 0; i < sequence.size(); ++i) 274 for (size_t i = 0; i < sequence.size(); ++i)
274 web_sequence[i] = blink::WebString::fromUTF8(sequence[i]); 275 web_sequence[i] = blink::WebString::fromUTF8(sequence[i]);
275 return web_sequence; 276 return web_sequence;
276 } 277 }
277 278
278 void WhitelistStatsForTesting(const char* type) { 279 void WhitelistStatsForTesting(const char* type) {
279 g_whitelisted_stats.Get().WhitelistStatsForTesting(type); 280 GetStatsWhitelist()->WhitelistStatsForTesting(type);
280 } 281 }
281 282
282 } // namespace content 283 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_peer_connection_handler.cc ('k') | media/PRESUBMIT.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698