OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/renderer/media/webrtc_uma_histograms.h" |
| 6 |
| 7 #include "base/metrics/histogram.h" |
| 8 |
| 9 namespace content { |
| 10 |
| 11 void UpdateWebRTCMethodCount(JavaScriptAPIName api_name) { |
| 12 DVLOG(3) << "Incrementing WebRTC.webkitApiCount for " << api_name; |
| 13 UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCount", api_name, INVALID_NAME); |
| 14 PerSessionWebRTCAPIMetrics::GetInstance()->LogUsageOnlyOnce(api_name); |
| 15 } |
| 16 |
| 17 PerSessionWebRTCAPIMetrics::~PerSessionWebRTCAPIMetrics() { |
| 18 } |
| 19 |
| 20 // static |
| 21 PerSessionWebRTCAPIMetrics* PerSessionWebRTCAPIMetrics::GetInstance() { |
| 22 return Singleton<PerSessionWebRTCAPIMetrics>::get(); |
| 23 } |
| 24 |
| 25 void PerSessionWebRTCAPIMetrics::IncrementStreamCounter() { |
| 26 DCHECK(CalledOnValidThread()); |
| 27 ++num_streams_; |
| 28 } |
| 29 |
| 30 void PerSessionWebRTCAPIMetrics::DecrementStreamCounter() { |
| 31 DCHECK(CalledOnValidThread()); |
| 32 if (--num_streams_ == 0) { |
| 33 ResetUsage(); |
| 34 } |
| 35 } |
| 36 |
| 37 PerSessionWebRTCAPIMetrics::PerSessionWebRTCAPIMetrics() : num_streams_(0) { |
| 38 ResetUsage(); |
| 39 } |
| 40 |
| 41 void PerSessionWebRTCAPIMetrics::LogUsage(JavaScriptAPIName api_name) { |
| 42 DVLOG(3) << "Incrementing WebRTC.webkitApiCountPerSession for " << api_name; |
| 43 UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCountPerSession", |
| 44 api_name, INVALID_NAME); |
| 45 } |
| 46 |
| 47 void PerSessionWebRTCAPIMetrics::LogUsageOnlyOnce(JavaScriptAPIName api_name) { |
| 48 DCHECK(CalledOnValidThread()); |
| 49 if (!has_used_api_[api_name]) { |
| 50 has_used_api_[api_name] = true; |
| 51 LogUsage(api_name); |
| 52 } |
| 53 } |
| 54 |
| 55 void PerSessionWebRTCAPIMetrics::ResetUsage() { |
| 56 for (size_t i = 0; i < arraysize(has_used_api_); ++i) |
| 57 has_used_api_[i] = false; |
| 58 } |
| 59 |
| 60 } // namespace content |
OLD | NEW |