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

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

Issue 2909103002: Deprecate NonThreadSafe in content/renderer/media in favor of SequenceChecker. (Closed)
Patch Set: fix compile Created 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_uma_histograms.h" 5 #include "content/renderer/media/webrtc_uma_histograms.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 void LogUserMediaRequestWithNoResult(MediaStreamRequestState state) { 11 void LogUserMediaRequestWithNoResult(MediaStreamRequestState state) {
12 UMA_HISTOGRAM_ENUMERATION("WebRTC.UserMediaRequest.NoResultState", 12 UMA_HISTOGRAM_ENUMERATION("WebRTC.UserMediaRequest.NoResultState",
13 state, 13 state,
14 NUM_MEDIA_STREAM_REQUEST_WITH_NO_RESULT); 14 NUM_MEDIA_STREAM_REQUEST_WITH_NO_RESULT);
15 } 15 }
16 16
17 void LogUserMediaRequestResult(MediaStreamRequestResult result) { 17 void LogUserMediaRequestResult(MediaStreamRequestResult result) {
18 UMA_HISTOGRAM_ENUMERATION( 18 UMA_HISTOGRAM_ENUMERATION(
19 "WebRTC.UserMediaRequest.Result", result, NUM_MEDIA_REQUEST_RESULTS); 19 "WebRTC.UserMediaRequest.Result", result, NUM_MEDIA_REQUEST_RESULTS);
20 } 20 }
21 21
22 void UpdateWebRTCMethodCount(JavaScriptAPIName api_name) { 22 void UpdateWebRTCMethodCount(JavaScriptAPIName api_name) {
23 DVLOG(3) << "Incrementing WebRTC.webkitApiCount for " << api_name; 23 DVLOG(3) << "Incrementing WebRTC.webkitApiCount for " << api_name;
24 UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCount", api_name, INVALID_NAME); 24 UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCount", api_name, INVALID_NAME);
25 PerSessionWebRTCAPIMetrics::GetInstance()->LogUsageOnlyOnce(api_name); 25 PerSessionWebRTCAPIMetrics::GetInstance()->LogUsageOnlyOnce(api_name);
26 } 26 }
27 27
28 PerSessionWebRTCAPIMetrics::~PerSessionWebRTCAPIMetrics() { 28 PerSessionWebRTCAPIMetrics::~PerSessionWebRTCAPIMetrics() {
29 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
29 } 30 }
30 31
31 // static 32 // static
32 PerSessionWebRTCAPIMetrics* PerSessionWebRTCAPIMetrics::GetInstance() { 33 PerSessionWebRTCAPIMetrics* PerSessionWebRTCAPIMetrics::GetInstance() {
33 return base::Singleton<PerSessionWebRTCAPIMetrics>::get(); 34 return base::Singleton<PerSessionWebRTCAPIMetrics>::get();
34 } 35 }
35 36
36 void PerSessionWebRTCAPIMetrics::IncrementStreamCounter() { 37 void PerSessionWebRTCAPIMetrics::IncrementStreamCounter() {
37 DCHECK(CalledOnValidThread()); 38 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
38 ++num_streams_; 39 ++num_streams_;
39 } 40 }
40 41
41 void PerSessionWebRTCAPIMetrics::DecrementStreamCounter() { 42 void PerSessionWebRTCAPIMetrics::DecrementStreamCounter() {
42 DCHECK(CalledOnValidThread()); 43 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
43 if (--num_streams_ == 0) { 44 if (--num_streams_ == 0) {
44 ResetUsage(); 45 ResetUsage();
45 } 46 }
46 } 47 }
47 48
48 PerSessionWebRTCAPIMetrics::PerSessionWebRTCAPIMetrics() : num_streams_(0) { 49 PerSessionWebRTCAPIMetrics::PerSessionWebRTCAPIMetrics() : num_streams_(0) {
49 ResetUsage(); 50 ResetUsage();
50 } 51 }
51 52
52 void PerSessionWebRTCAPIMetrics::LogUsage(JavaScriptAPIName api_name) { 53 void PerSessionWebRTCAPIMetrics::LogUsage(JavaScriptAPIName api_name) {
53 DVLOG(3) << "Incrementing WebRTC.webkitApiCountPerSession for " << api_name; 54 DVLOG(3) << "Incrementing WebRTC.webkitApiCountPerSession for " << api_name;
54 UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCountPerSession", 55 UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCountPerSession",
55 api_name, INVALID_NAME); 56 api_name, INVALID_NAME);
56 } 57 }
57 58
58 void PerSessionWebRTCAPIMetrics::LogUsageOnlyOnce(JavaScriptAPIName api_name) { 59 void PerSessionWebRTCAPIMetrics::LogUsageOnlyOnce(JavaScriptAPIName api_name) {
59 DCHECK(CalledOnValidThread()); 60 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
60 if (!has_used_api_[api_name]) { 61 if (!has_used_api_[api_name]) {
61 has_used_api_[api_name] = true; 62 has_used_api_[api_name] = true;
62 LogUsage(api_name); 63 LogUsage(api_name);
63 } 64 }
64 } 65 }
65 66
66 void PerSessionWebRTCAPIMetrics::ResetUsage() { 67 void PerSessionWebRTCAPIMetrics::ResetUsage() {
67 for (bool& has_used_api : has_used_api_) 68 for (bool& has_used_api : has_used_api_)
68 has_used_api = false; 69 has_used_api = false;
69 } 70 }
70 71
71 } // namespace content 72 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698