Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2056743002: [Media, Autoplay] Add UMA to record autoplay source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
index b61f709be202125c3164f3396979f8f9c5b64b66..246e0c42c49ca53d2623ec7865ecafe484d3e27a 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -281,6 +281,16 @@ String preloadTypeToString(WebMediaPlayer::Preload preloadType)
return String();
}
+// These values are used for histograms. Do not reorder.
+enum AutoplaySource {
+ // Autoplay comes from HTMLMediaElement `autoplay` attribute.
+ AutoplaySourceAttribute = 0,
+ // Autoplay comes from `play()` method.
+ AutoplaySourceMethod = 1,
+ // This enum value must be last.
+ NumberOfAutoplaySources = 2,
+};
+
} // anonymous namespace
class HTMLMediaElement::AutoplayHelperClientImpl :
@@ -1618,6 +1628,7 @@ void HTMLMediaElement::setReadyState(ReadyState state)
// Check for autoplay, and record metrics about it if needed.
if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) {
+ recordAutoplaySourceMetric(AutoplaySourceAttribute);
// If the autoplay experiment says that it's okay to play now,
// then don't require a user gesture.
m_autoplayHelper->becameReadyToPlay();
@@ -2048,6 +2059,7 @@ Nullable<ExceptionCode> HTMLMediaElement::play()
m_autoplayHelper->playMethodCalled();
if (!UserGestureIndicator::processingUserGesture()) {
+ recordAutoplaySourceMetric(AutoplaySourceMethod);
if (isGestureNeededForPlayback()) {
// If playback is deferred, then don't start playback but don't
// fail yet either.
@@ -3768,6 +3780,21 @@ EnumerationHistogram& HTMLMediaElement::showControlsHistogram() const
return histogram;
}
+void HTMLMediaElement::recordAutoplaySourceMetric(int source)
+{
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, videoHistogram, ("Media.Video.Autoplay", NumberOfAutoplaySources));
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, mutedVideoHistogram, ("Media.Video.Autoplay.Muted", NumberOfAutoplaySources));
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, audioHistogram, ("Media.Audio.Autoplay", NumberOfAutoplaySources));
+
+ if (isHTMLVideoElement()) {
+ videoHistogram.count(source);
+ if (muted())
+ mutedVideoHistogram.count(source);
+ } else {
+ audioHistogram.count(source);
+ }
+}
+
void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
{
if (!ThreadHeap::isHeapObjectAlive(m_audioSourceNode)) {
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698