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

Unified Diff: third_party/WebKit/Source/core/html/AutoplayUmaHelper.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
Index: third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
diff --git a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
deleted file mode 100644
index e9be0ccf5dbc58d2e1bda2931b97756d77b5bd92..0000000000000000000000000000000000000000
--- a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright 2016 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 "core/html/AutoplayUmaHelper.h"
-
-#include "core/dom/ElementVisibilityObserver.h"
-#include "core/events/Event.h"
-#include "core/html/HTMLMediaElement.h"
-#include "platform/Histogram.h"
-
-namespace blink {
-
-namespace {
-
-void recordVideoAutoplayMutedPlayMethodBecomesVisibleUma(bool visible)
-{
- DEFINE_STATIC_LOCAL(BooleanHistogram, histogram, ("Media.Video.Autoplay.Muted.PlayMethod.BecomesVisible"));
- histogram.count(visible);
-}
-
-} // namespace
-
-AutoplayUmaHelper* AutoplayUmaHelper::create(HTMLMediaElement* element)
-{
- return new AutoplayUmaHelper(element);
-}
-
-AutoplayUmaHelper::AutoplayUmaHelper(HTMLMediaElement* element)
- : EventListener(CPPEventListenerType)
- , m_source(AutoplaySource::NumberOfSources)
- , m_element(element)
- , m_videoMutedPlayMethodVisibilityObserver(nullptr) { }
-
-AutoplayUmaHelper::~AutoplayUmaHelper() = default;
-
-bool AutoplayUmaHelper::operator==(const EventListener& other) const
-{
- return this == &other;
-}
-
-void AutoplayUmaHelper::onAutoplayInitiated(AutoplaySource source)
-{
- DEFINE_STATIC_LOCAL(EnumerationHistogram, videoHistogram, ("Media.Video.Autoplay", static_cast<int>(AutoplaySource::NumberOfSources)));
- DEFINE_STATIC_LOCAL(EnumerationHistogram, mutedVideoHistogram, ("Media.Video.Autoplay.Muted", static_cast<int>(AutoplaySource::NumberOfSources)));
- DEFINE_STATIC_LOCAL(EnumerationHistogram, audioHistogram, ("Media.Audio.Autoplay", static_cast<int>(AutoplaySource::NumberOfSources)));
-
- m_source = source;
-
- if (m_element->isHTMLVideoElement()) {
- videoHistogram.count(static_cast<int>(m_source));
- if (m_element->muted())
- mutedVideoHistogram.count(static_cast<int>(m_source));
- } else {
- audioHistogram.count(static_cast<int>(m_source));
- }
-
- if (m_source == AutoplaySource::Method && m_element->isHTMLVideoElement() && m_element->muted())
- m_element->addEventListener(EventTypeNames::playing, this, false);
-}
-
-void AutoplayUmaHelper::onElementDestroyed()
-{
- if (m_videoMutedPlayMethodVisibilityObserver) {
- recordVideoAutoplayMutedPlayMethodBecomesVisibleUma(false);
- m_videoMutedPlayMethodVisibilityObserver->stop();
- m_videoMutedPlayMethodVisibilityObserver = nullptr;
- }
-}
-
-void AutoplayUmaHelper::recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus status)
-{
- DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayUnmuteHistogram, ("Media.Video.Autoplay.Muted.UnmuteAction", static_cast<int>(AutoplayUnmuteActionStatus::NumberOfStatus)));
-
- autoplayUnmuteHistogram.count(static_cast<int>(status));
-}
-
-void AutoplayUmaHelper::onVisibilityChangedForVideoMutedPlayMethod(bool isVisible)
-{
- if (!isVisible)
- return;
-
- recordVideoAutoplayMutedPlayMethodBecomesVisibleUma(true);
- m_videoMutedPlayMethodVisibilityObserver->stop();
- m_videoMutedPlayMethodVisibilityObserver = nullptr;
-}
-
-void AutoplayUmaHelper::handleEvent(ExecutionContext* executionContext, Event* event)
-{
- DCHECK(event->type() == EventTypeNames::playing);
- handlePlayingEvent();
-}
-
-void AutoplayUmaHelper::handlePlayingEvent()
-{
- if (m_source == AutoplaySource::Method && m_element->isHTMLVideoElement() && m_element->muted()) {
- if (!m_videoMutedPlayMethodVisibilityObserver) {
- m_videoMutedPlayMethodVisibilityObserver = new ElementVisibilityObserver(m_element, WTF::bind(&AutoplayUmaHelper::onVisibilityChangedForVideoMutedPlayMethod, wrapPersistent(this)));
- m_videoMutedPlayMethodVisibilityObserver->start();
- }
- }
- m_element->removeEventListener(EventTypeNames::playing, this, false);
-}
-
-DEFINE_TRACE(AutoplayUmaHelper)
-{
- EventListener::trace(visitor);
- visitor->trace(m_element);
- visitor->trace(m_videoMutedPlayMethodVisibilityObserver);
-}
-
-} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/html/AutoplayUmaHelper.h ('k') | third_party/WebKit/Source/core/html/HTMLMediaElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698