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

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

Issue 2141093003: Revert "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: 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 07dba329083c52b89b4a0f67f9df5ea21053a45f..5a63b92a411057bd6934052df59836e6eadb1078 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -44,7 +44,6 @@
#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"
@@ -281,6 +280,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 :
@@ -438,7 +447,6 @@ 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)
{
@@ -482,8 +490,6 @@ void HTMLMediaElement::dispose()
// See Document::isDelayingLoadEvent().
// Also see http://crbug.com/275223 for more details.
clearMediaPlayerAndAudioSourceProviderClientWithoutLocking();
-
- m_autoplayUmaHelper->onElementDestroyed();
}
void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument)
@@ -1620,7 +1626,7 @@ void HTMLMediaElement::setReadyState(ReadyState state)
// Check for autoplay, and record metrics about it if needed.
if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) {
- m_autoplayUmaHelper->onAutoplayInitiated(AutoplaySource::Attribute);
+ recordAutoplaySourceMetric(AutoplaySourceAttribute);
// If the autoplay experiment says that it's okay to play now,
// then don't require a user gesture.
@@ -2075,7 +2081,7 @@ Nullable<ExceptionCode> HTMLMediaElement::play()
m_autoplayHelper->playMethodCalled();
if (!UserGestureIndicator::processingUserGesture()) {
- m_autoplayUmaHelper->onAutoplayInitiated(AutoplaySource::Method);
+ recordAutoplaySourceMetric(AutoplaySourceMethod);
if (isGestureNeededForPlayback()) {
// If playback is deferred, then don't start playback but don't
// fail yet either.
@@ -2300,9 +2306,9 @@ void HTMLMediaElement::setMuted(bool muted)
if (wasAutoplayingMuted) {
if (isGestureNeededForPlayback()) {
pause();
- m_autoplayUmaHelper->recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus::Failure);
+ recordAutoplayUnmuteStatus(AutoplayUnmuteActionFailure);
} else {
- m_autoplayUmaHelper->recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus::Success);
+ recordAutoplayUnmuteStatus(AutoplayUnmuteActionSuccess);
}
}
}
@@ -3660,7 +3666,6 @@ 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);
@@ -3881,6 +3886,28 @@ 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