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

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

Issue 2108403003: Measure whether muted videos that started playing with play() become visible at some point (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up in a unload event listener Created 4 years, 5 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') | third_party/WebKit/Source/core/html/OWNERS » ('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 d1df73ea7a01981c75a55126bda93136a0de210c..96abe739c58f6832a719911ef6e1f90dd46b315b 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -44,6 +44,7 @@
#include "core/frame/Settings.h"
#include "core/frame/UseCounter.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
+#include "core/html/AutoplayUmaHelper.h"
#include "core/html/HTMLMediaSource.h"
#include "core/html/HTMLSourceElement.h"
#include "core/html/HTMLTrackElement.h"
@@ -280,16 +281,6 @@ 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 :
@@ -447,6 +438,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
, m_audioSourceNode(nullptr)
, m_autoplayHelperClient(AutoplayHelperClientImpl::create(this))
, m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.get()))
+ , m_autoplayUmaHelper(AutoplayUmaHelper::create(this))
, m_remotePlaybackClient(nullptr)
, m_autoplayVisibilityObserver(nullptr)
{
@@ -1626,7 +1618,7 @@ void HTMLMediaElement::setReadyState(ReadyState state)
// Check for autoplay, and record metrics about it if needed.
if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) {
- recordAutoplaySourceMetric(AutoplaySourceAttribute);
+ m_autoplayUmaHelper->onAutoplayInitiated(AutoplaySource::Attribute);
// If the autoplay experiment says that it's okay to play now,
// then don't require a user gesture.
@@ -2081,7 +2073,7 @@ Nullable<ExceptionCode> HTMLMediaElement::play()
m_autoplayHelper->playMethodCalled();
if (!UserGestureIndicator::processingUserGesture()) {
- recordAutoplaySourceMetric(AutoplaySourceMethod);
+ m_autoplayUmaHelper->onAutoplayInitiated(AutoplaySource::Method);
if (isGestureNeededForPlayback()) {
// If playback is deferred, then don't start playback but don't
// fail yet either.
@@ -2306,9 +2298,9 @@ void HTMLMediaElement::setMuted(bool muted)
if (wasAutoplayingMuted) {
if (isGestureNeededForPlayback()) {
pause();
- recordAutoplayUnmuteStatus(AutoplayUnmuteActionFailure);
+ m_autoplayUmaHelper->recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus::Failure);
} else {
- recordAutoplayUnmuteStatus(AutoplayUnmuteActionSuccess);
+ m_autoplayUmaHelper->recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus::Success);
}
}
}
@@ -3666,6 +3658,7 @@ DEFINE_TRACE(HTMLMediaElement)
visitor->trace(m_audioSourceProvider);
visitor->trace(m_autoplayHelperClient);
visitor->trace(m_autoplayHelper);
+ visitor->trace(m_autoplayUmaHelper);
visitor->trace(m_srcObject);
visitor->trace(m_autoplayVisibilityObserver);
visitor->template registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::clearWeakMembers>(this);
@@ -3886,28 +3879,6 @@ 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::recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus status)
-{
- DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayUnmuteHistogram, ("Media.Video.Autoplay.Muted.UnmuteAction", AutoplayUnmuteActionMax));
-
- autoplayUnmuteHistogram.count(status);
-}
-
void HTMLMediaElement::onVisibilityChangedForAutoplay(bool isVisible)
{
if (!isVisible)
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | third_party/WebKit/Source/core/html/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698