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

Unified Diff: third_party/WebKit/Source/core/html/AutoplayUmaHelper.h

Issue 2780403004: Create core/html/media/ and move auxiliary media files in it. (Closed)
Patch Set: actually add autoplay files Created 3 years, 9 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.h
diff --git a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.h b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.h
deleted file mode 100644
index 82130ef27566f342d2e972181b0c85adeeedc277..0000000000000000000000000000000000000000
--- a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.h
+++ /dev/null
@@ -1,149 +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.
-
-#ifndef AutoplayUmaHelper_h
-#define AutoplayUmaHelper_h
-
-#include "core/CoreExport.h"
-#include "core/dom/ContextLifecycleObserver.h"
-#include "core/events/EventListener.h"
-#include "platform/heap/Handle.h"
-
-#include <set>
-
-namespace blink {
-
-// These values are used for histograms. Do not reorder.
-enum class AutoplaySource {
- // Autoplay comes from HTMLMediaElement `autoplay` attribute.
- Attribute = 0,
- // Autoplay comes from `play()` method.
- Method = 1,
- // Used for checking dual source.
- NumberOfSources = 2,
- // Both sources are used.
- DualSource = 2,
- // This enum value must be last.
- NumberOfUmaSources = 3,
-};
-
-// These values are used for histograms. Do not reorder.
-enum class AutoplayUnmuteActionStatus {
- Failure = 0,
- Success = 1,
- NumberOfStatus = 2,
-};
-
-// These values are used for histograms. Do not reorder.
-enum AutoplayBlockedReason {
- AutoplayBlockedReasonDataSaver = 0,
- AutoplayBlockedReasonSetting = 1,
- AutoplayBlockedReasonDataSaverAndSetting = 2,
- // Keey at the end.
- AutoplayBlockedReasonMax = 3
-};
-
-enum class CrossOriginAutoplayResult {
- AutoplayAllowed = 0,
- AutoplayBlocked = 1,
- PlayedWithGesture = 2,
- UserPaused = 3,
- // Keep at the end.
- NumberOfResults = 4,
-};
-
-class Document;
-class ElementVisibilityObserver;
-class HTMLMediaElement;
-
-class CORE_EXPORT AutoplayUmaHelper : public EventListener,
- public ContextLifecycleObserver {
- USING_GARBAGE_COLLECTED_MIXIN(AutoplayUmaHelper);
-
- public:
- static AutoplayUmaHelper* create(HTMLMediaElement*);
-
- ~AutoplayUmaHelper();
-
- bool operator==(const EventListener&) const override;
-
- void contextDestroyed(ExecutionContext*) override;
-
- void onAutoplayInitiated(AutoplaySource);
-
- void recordCrossOriginAutoplayResult(CrossOriginAutoplayResult);
- void recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus);
-
- void didMoveToNewDocument(Document& oldDocument);
-
- bool isVisible() const { return m_isVisible; }
-
- bool hasSource() const { return !m_sources.empty(); }
-
- DECLARE_VIRTUAL_TRACE();
-
- private:
- friend class MockAutoplayUmaHelper;
-
- explicit AutoplayUmaHelper(HTMLMediaElement*);
- void handleEvent(ExecutionContext*, Event*) override;
- void handlePlayingEvent();
- void handlePauseEvent();
- virtual void handleContextDestroyed(); // Make virtual for testing.
-
- void maybeUnregisterContextDestroyedObserver();
- void maybeUnregisterMediaElementPauseListener();
-
- void maybeStartRecordingMutedVideoPlayMethodBecomeVisible();
- void maybeStopRecordingMutedVideoPlayMethodBecomeVisible(bool isVisible);
-
- void maybeStartRecordingMutedVideoOffscreenDuration();
- void maybeStopRecordingMutedVideoOffscreenDuration();
-
- void maybeRecordUserPausedAutoplayingCrossOriginVideo();
-
- void onVisibilityChangedForMutedVideoOffscreenDuration(bool isVisibile);
- void onVisibilityChangedForMutedVideoPlayMethodBecomeVisible(bool isVisible);
-
- bool shouldListenToContextDestroyed() const;
- bool shouldRecordUserPausedAutoplayingCrossOriginVideo() const;
-
- // The autoplay sources.
- std::set<AutoplaySource> m_sources;
-
- // The media element this UMA helper is attached to. |m_element| owns |this|.
- Member<HTMLMediaElement> m_element;
-
- // The observer is used to observe whether a muted video autoplaying by play()
- // method become visible at some point.
- // The UMA is pending for recording as long as this observer is non-null.
- Member<ElementVisibilityObserver> m_mutedVideoPlayMethodVisibilityObserver;
-
- // -----------------------------------------------------------------------
- // Variables used for recording the duration of autoplay muted video playing
- // offscreen. The variables are valid when
- // |m_autoplayOffscrenVisibilityObserver| is non-null.
- // The recording stops whenever the playback pauses or the page is unloaded.
-
- // The starting time of autoplaying muted video.
- int64_t m_mutedVideoAutoplayOffscreenStartTimeMS;
-
- // The duration an autoplaying muted video has been in offscreen.
- int64_t m_mutedVideoAutoplayOffscreenDurationMS;
-
- // Whether an autoplaying muted video is visible.
- bool m_isVisible;
-
- std::set<CrossOriginAutoplayResult> m_recordedCrossOriginAutoplayResults;
-
- // The observer is used to observer an autoplaying muted video changing it's
- // visibility, which is used for offscreen duration UMA. The UMA is pending
- // for recording as long as this observer is non-null.
- Member<ElementVisibilityObserver>
- m_mutedVideoOffscreenDurationVisibilityObserver;
-};
-
-} // namespace blink
-
-#endif // AutoplayUmaHelper_h

Powered by Google App Engine
This is Rietveld 408576698