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.
5 #include "content/renderer/media/webrtc_uma_histograms.h"
7 #include "base/metrics/histogram.h"
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
);
17 PerSessionWebRTCAPIMetrics::~PerSessionWebRTCAPIMetrics() {
21 PerSessionWebRTCAPIMetrics
* PerSessionWebRTCAPIMetrics::GetInstance() {
22 return Singleton
<PerSessionWebRTCAPIMetrics
>::get();
25 void PerSessionWebRTCAPIMetrics::IncrementStreamCounter() {
26 DCHECK(CalledOnValidThread());
30 void PerSessionWebRTCAPIMetrics::DecrementStreamCounter() {
31 DCHECK(CalledOnValidThread());
32 if (--num_streams_
== 0) {
37 PerSessionWebRTCAPIMetrics::PerSessionWebRTCAPIMetrics() : num_streams_(0) {
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
);
47 void PerSessionWebRTCAPIMetrics::LogUsageOnlyOnce(JavaScriptAPIName api_name
) {
48 DCHECK(CalledOnValidThread());
49 if (!has_used_api_
[api_name
]) {
50 has_used_api_
[api_name
] = true;
55 void PerSessionWebRTCAPIMetrics::ResetUsage() {
56 for (size_t i
= 0; i
< arraysize(has_used_api_
); ++i
)
57 has_used_api_
[i
] = false;
60 } // namespace content