summaryrefslogtreecommitdiffstats
path: root/content/renderer/media/webrtc_uma_histograms.cc
blob: 4cf8b986491a8972c88996affd4b1ee79236ced9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/renderer/media/webrtc_uma_histograms.h"

#include <set>

#include "base/lazy_instance.h"

namespace content {

namespace {

typedef std::set<base::string16> OriginSet;
base::LazyInstance<OriginSet>::Leaky counted_security_origins;

}  // namespace

void UpdateWebRTCMethodCount(JavaScriptAPIName api_name) {
  UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCount", api_name, INVALID_NAME);
}

void UpdateWebRTCUniqueOriginMethodCount(
    JavaScriptAPIName api_name,
    const base::string16& security_origin) {
  OriginSet* origins = counted_security_origins.Pointer();

  if (origins->find(security_origin) == origins->end()) {
    UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCountUniqueByOrigin",
                              api_name, INVALID_NAME);
    origins->insert(security_origin);
  }
}

} //  namespace content