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

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

Issue 2463113002: Let AutoplayUmaHelper listen to visibilitychange instead of unload (Closed)
Patch Set: nit Created 4 years, 1 month 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/BUILD.gn ('k') | third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index 7dda64bb56d55bc2b799c5290a8a9b9f2c420e88..706dd56183f0ea03aad7098bc37ec2557184ecfc 100644
--- a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.h
+++ b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.h
@@ -5,6 +5,8 @@
#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"
@@ -40,7 +42,10 @@ class Document;
class ElementVisibilityObserver;
class HTMLMediaElement;
-class AutoplayUmaHelper final : public EventListener {
+class CORE_EXPORT AutoplayUmaHelper : public EventListener,
+ public ContextLifecycleObserver {
+ USING_GARBAGE_COLLECTED_MIXIN(AutoplayUmaHelper);
+
public:
static AutoplayUmaHelper* create(HTMLMediaElement*);
@@ -48,6 +53,8 @@ class AutoplayUmaHelper final : public EventListener {
bool operator==(const EventListener&) const override;
+ void contextDestroyed() override;
+
void onAutoplayInitiated(AutoplaySource);
void recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus);
@@ -61,15 +68,15 @@ class AutoplayUmaHelper final : public EventListener {
DECLARE_VIRTUAL_TRACE();
private:
- explicit AutoplayUmaHelper(HTMLMediaElement*);
+ friend class MockAutoplayUmaHelper;
+ explicit AutoplayUmaHelper(HTMLMediaElement*);
void handleEvent(ExecutionContext*, Event*) override;
-
void handlePlayingEvent();
void handlePauseEvent();
- void handleUnloadEvent();
+ virtual void handleContextDestroyed(); // Make virtual for testing.
- void maybeUnregisterUnloadListener();
+ void maybeUnregisterContextDestroyedObserver();
void maybeStartRecordingMutedVideoPlayMethodBecomeVisible();
void maybeStopRecordingMutedVideoPlayMethodBecomeVisible(bool isVisible);
@@ -80,7 +87,7 @@ class AutoplayUmaHelper final : public EventListener {
void onVisibilityChangedForMutedVideoOffscreenDuration(bool isVisibile);
void onVisibilityChangedForMutedVideoPlayMethodBecomeVisible(bool isVisible);
- bool shouldListenToUnloadEvent() const;
+ bool shouldListenToContextDestroyed() const;
// The autoplay source. Use AutoplaySource::NumberOfSources for invalid
// source.
« no previous file with comments | « third_party/WebKit/Source/core/BUILD.gn ('k') | third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698