chrome.bluetoothSocket: clean-up Listen functions
[chromium-blink-merge.git] / content / renderer / media / webrtc_uma_histograms.cc
blob16da393073e45e1b27d8f4e055faa0a898d7f9f2
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"
9 namespace content {
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() {
20 // static
21 PerSessionWebRTCAPIMetrics* PerSessionWebRTCAPIMetrics::GetInstance() {
22 return Singleton<PerSessionWebRTCAPIMetrics>::get();
25 void PerSessionWebRTCAPIMetrics::IncrementStreamCounter() {
26 DCHECK(CalledOnValidThread());
27 ++num_streams_;
30 void PerSessionWebRTCAPIMetrics::DecrementStreamCounter() {
31 DCHECK(CalledOnValidThread());
32 if (--num_streams_ == 0) {
33 ResetUsage();
37 PerSessionWebRTCAPIMetrics::PerSessionWebRTCAPIMetrics() : num_streams_(0) {
38 ResetUsage();
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;
51 LogUsage(api_name);
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