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

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

Issue 2044373002: [Media, Autoplay] Add UMA to record autoplay source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make recordAutoplaySourceMetric() private 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
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 7beecb9dd4be9a28665ac847fe9e6f45f67b085f..656fb5719b110fcb24eeb8f478c5aede6122fa3d 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()
{
DVLOG(MEDIA_LOG_LEVEL) << "play(" << (void*)this << ")";
+ recordAutoplaySourceMetric(AutoplaySourceMethod);
mlamouri (slow - plz ping) 2016/06/08 12:30:03 What we call "autoplay" is when there is no user g
Zhiqiang Zhang (Slow) 2016/06/08 12:55:14 Done.
m_autoplayHelper->playMethodCalled();
if (!UserGestureIndicator::processingUserGesture()) {
@@ -3771,6 +3783,21 @@ EnumerationHistogram& HTMLMediaElement::showControlsHistogram() const
return histogram;
}
+void HTMLMediaElement::recordAutoplaySourceMetric(int source)
+{
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, videoHistogram, ("Blink.MediaElement.Autoplay.Source.Video", NumberOfAutoplaySources));
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, mutedVideoHistogram, ("Blink.MediaElement.Autoplay.Source.Video.Muted", NumberOfAutoplaySources));
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, audioHistogram, ("Blink.MediaElement.Autoplay.Source.Audio", 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)) {

Powered by Google App Engine
This is Rietveld 408576698