summaryrefslogtreecommitdiffstats
path: root/content/renderer/media
diff options
context:
space:
mode:
Diffstat (limited to 'content/renderer/media')
-rw-r--r--content/renderer/media/media_stream_impl.cc8
-rw-r--r--content/renderer/media/webrtc_uma_histograms.cc36
-rw-r--r--content/renderer/media/webrtc_uma_histograms.h26
3 files changed, 63 insertions, 7 deletions
diff --git a/content/renderer/media/media_stream_impl.cc b/content/renderer/media/media_stream_impl.cc
index 3867bed..ddbbc15 100644
--- a/content/renderer/media/media_stream_impl.cc
+++ b/content/renderer/media/media_stream_impl.cc
@@ -128,7 +128,13 @@ void MediaStreamImpl::requestUserMedia(
&options.optional_video);
}
- security_origin = GURL(user_media_request.securityOrigin().toString());
+ base::string16 security_origin_string =
+ user_media_request.securityOrigin().toString();
+ security_origin = GURL(security_origin_string);
+
+ UpdateWebRTCUniqueOriginMethodCount(WEBKIT_GET_USER_MEDIA,
+ security_origin_string);
+
// Get the WebFrame that requested a MediaStream.
// The frame is needed to tell the MediaStreamDispatcher when a stream goes
// out of scope.
diff --git a/content/renderer/media/webrtc_uma_histograms.cc b/content/renderer/media/webrtc_uma_histograms.cc
new file mode 100644
index 0000000..4cf8b98
--- /dev/null
+++ b/content/renderer/media/webrtc_uma_histograms.cc
@@ -0,0 +1,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
diff --git a/content/renderer/media/webrtc_uma_histograms.h b/content/renderer/media/webrtc_uma_histograms.h
index de358f4..06b94d3 100644
--- a/content/renderer/media/webrtc_uma_histograms.h
+++ b/content/renderer/media/webrtc_uma_histograms.h
@@ -6,6 +6,7 @@
#define CONTENT_RENDERER_MEDIA_WEBRTC_UMA_HISTOGRAMS_H_
#include "base/metrics/histogram.h"
+#include "base/strings/string16.h"
namespace content {
@@ -18,12 +19,25 @@ enum JavaScriptAPIName {
INVALID_NAME
};
-// Helper method used to collect information about the number of times
-// different WebRTC API:s are called from JavaScript.
-// The histogram can be viewed at chrome://histograms/WebRTC.webkitApiCount.
-inline void UpdateWebRTCMethodCount(JavaScriptAPIName api_name) {
- UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCount", api_name, INVALID_NAME);
-}
+// Helper method used to collect information about the raw count of
+// the number of times different WebRTC APIs are called from
+// JavaScript.
+//
+// The histogram can be viewed at
+// chrome://histograms/WebRTC.webkitApiCount.
+void UpdateWebRTCMethodCount(JavaScriptAPIName api_name);
+
+// Helper method used to collect information about the number of
+// unique security origins that call different WebRTC APIs within the
+// current browser session. For example, if abc.com calls getUserMedia
+// 100 times and RTCPeerConnection 10 times, and xyz.com calls
+// getUserMedia 50 times, RTCPeerConnection will have a count of 1 and
+// getUserMedia will have a count of 2.
+//
+// The histogram can be viewed at
+// chrome://histograms/WebRTC.webkitApiCountUniqueByOrigin.
+void UpdateWebRTCUniqueOriginMethodCount(JavaScriptAPIName api_name,
+ const base::string16& security_origin);
} // namespace content