| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef AutoplayExperimentHelper_h | 5 #ifndef AutoplayExperimentHelper_h |
| 6 #define AutoplayExperimentHelper_h | 6 #define AutoplayExperimentHelper_h |
| 7 | 7 |
| 8 #include "core/page/Page.h" | 8 #include "core/page/Page.h" |
| 9 #include "platform/Timer.h" | 9 #include "platform/Timer.h" |
| 10 #include "platform/geometry/IntRect.h" | 10 #include "platform/geometry/IntRect.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 GesturelessPlaybackNotOverridden = 20, | 89 GesturelessPlaybackNotOverridden = 20, |
| 90 | 90 |
| 91 // Gestureless playback was enabled by a user gesture play() call. | 91 // Gestureless playback was enabled by a user gesture play() call. |
| 92 GesturelessPlaybackEnabledByPlayMethod = 21, | 92 GesturelessPlaybackEnabledByPlayMethod = 21, |
| 93 | 93 |
| 94 // This enum value must be last. | 94 // This enum value must be last. |
| 95 NumberOfAutoplayMetrics, | 95 NumberOfAutoplayMetrics, |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 class CORE_EXPORT AutoplayExperimentHelper final : | 98 class CORE_EXPORT AutoplayExperimentHelper final : |
| 99 public NoBaseWillBeGarbageCollectedFinalized<AutoplayExperimentHelper> { | 99 public GarbageCollectedFinalized<AutoplayExperimentHelper> { |
| 100 friend class AutoplayExperimentTest; | 100 friend class AutoplayExperimentTest; |
| 101 | 101 |
| 102 public: | 102 public: |
| 103 // For easier testing, collect all the things we care about here. | 103 // For easier testing, collect all the things we care about here. |
| 104 class Client : public NoBaseWillBeGarbageCollectedFinalized<Client> { | 104 class Client : public GarbageCollectedFinalized<Client> { |
| 105 public: | 105 public: |
| 106 virtual ~Client() {} | 106 virtual ~Client() {} |
| 107 | 107 |
| 108 // HTMLMediaElement | 108 // HTMLMediaElement |
| 109 virtual double currentTime() const = 0; | 109 virtual double currentTime() const = 0; |
| 110 virtual double duration() const = 0; | 110 virtual double duration() const = 0; |
| 111 virtual bool ended() const = 0; | 111 virtual bool ended() const = 0; |
| 112 virtual bool muted() const = 0; | 112 virtual bool muted() const = 0; |
| 113 virtual void setMuted(bool) = 0; | 113 virtual void setMuted(bool) = 0; |
| 114 virtual void playInternal() = 0; | 114 virtual void playInternal() = 0; |
| 115 virtual bool isUserGestureRequiredForPlay() const = 0; | 115 virtual bool isUserGestureRequiredForPlay() const = 0; |
| 116 virtual void removeUserGestureRequirement() = 0; | 116 virtual void removeUserGestureRequirement() = 0; |
| 117 virtual void recordAutoplayMetric(AutoplayMetrics) = 0; | 117 virtual void recordAutoplayMetric(AutoplayMetrics) = 0; |
| 118 virtual bool shouldAutoplay() = 0; | 118 virtual bool shouldAutoplay() = 0; |
| 119 virtual bool isHTMLVideoElement() const = 0; | 119 virtual bool isHTMLVideoElement() const = 0; |
| 120 virtual bool isHTMLAudioElement() const = 0; | 120 virtual bool isHTMLAudioElement() const = 0; |
| 121 | 121 |
| 122 // Document | 122 // Document |
| 123 virtual bool isLegacyViewportType() = 0; | 123 virtual bool isLegacyViewportType() = 0; |
| 124 virtual PageVisibilityState pageVisibilityState() const = 0; | 124 virtual PageVisibilityState pageVisibilityState() const = 0; |
| 125 virtual String autoplayExperimentMode() const = 0; | 125 virtual String autoplayExperimentMode() const = 0; |
| 126 | 126 |
| 127 // LayoutObject | 127 // LayoutObject |
| 128 virtual void setRequestPositionUpdates(bool) = 0; | 128 virtual void setRequestPositionUpdates(bool) = 0; |
| 129 virtual IntRect absoluteBoundingBoxRect() const = 0; | 129 virtual IntRect absoluteBoundingBoxRect() const = 0; |
| 130 | 130 |
| 131 DEFINE_INLINE_VIRTUAL_TRACE() { } | 131 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 static PassOwnPtrWillBeRawPtr<AutoplayExperimentHelper> create(Client* clien
t) | 134 static RawPtr<AutoplayExperimentHelper> create(Client* client) |
| 135 { | 135 { |
| 136 return adoptPtrWillBeNoop(new AutoplayExperimentHelper(client)); | 136 return new AutoplayExperimentHelper(client); |
| 137 } | 137 } |
| 138 | 138 |
| 139 ~AutoplayExperimentHelper(); | 139 ~AutoplayExperimentHelper(); |
| 140 | 140 |
| 141 void becameReadyToPlay(); | 141 void becameReadyToPlay(); |
| 142 void playMethodCalled(); | 142 void playMethodCalled(); |
| 143 void pauseMethodCalled(); | 143 void pauseMethodCalled(); |
| 144 void loadMethodCalled(); | 144 void loadMethodCalled(); |
| 145 void mutedChanged(); | 145 void mutedChanged(); |
| 146 void positionChanged(const IntRect&); | 146 void positionChanged(const IntRect&); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 243 } |
| 244 | 244 |
| 245 Mode fromString(const String& mode); | 245 Mode fromString(const String& mode); |
| 246 | 246 |
| 247 void recordAutoplayMetric(AutoplayMetrics); | 247 void recordAutoplayMetric(AutoplayMetrics); |
| 248 | 248 |
| 249 // Could stopping at this point be considered a bailout of playback? | 249 // Could stopping at this point be considered a bailout of playback? |
| 250 // (as in, "The user really didn't want to play this"). | 250 // (as in, "The user really didn't want to play this"). |
| 251 bool isBailout() const; | 251 bool isBailout() const; |
| 252 | 252 |
| 253 RawPtrWillBeMember<Client> m_client; | 253 Member<Client> m_client; |
| 254 | 254 |
| 255 Mode m_mode; | 255 Mode m_mode; |
| 256 | 256 |
| 257 // Autoplay experiment state. | 257 // Autoplay experiment state. |
| 258 // True if we've received a play() without a pause(). | 258 // True if we've received a play() without a pause(). |
| 259 bool m_playPending : 1; | 259 bool m_playPending : 1; |
| 260 | 260 |
| 261 // Are we registered with the view for position updates? | 261 // Are we registered with the view for position updates? |
| 262 bool m_registeredWithLayoutObject : 1; | 262 bool m_registeredWithLayoutObject : 1; |
| 263 | 263 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 inline AutoplayExperimentHelper::Mode& operator|=(AutoplayExperimentHelper::Mode
& a, | 298 inline AutoplayExperimentHelper::Mode& operator|=(AutoplayExperimentHelper::Mode
& a, |
| 299 const AutoplayExperimentHelper::Mode& b) | 299 const AutoplayExperimentHelper::Mode& b) |
| 300 { | 300 { |
| 301 a = static_cast<AutoplayExperimentHelper::Mode>(static_cast<int>(a) | static
_cast<int>(b)); | 301 a = static_cast<AutoplayExperimentHelper::Mode>(static_cast<int>(a) | static
_cast<int>(b)); |
| 302 return a; | 302 return a; |
| 303 } | 303 } |
| 304 | 304 |
| 305 } // namespace blink | 305 } // namespace blink |
| 306 | 306 |
| 307 #endif // AutoplayExperimentHelper_h | 307 #endif // AutoplayExperimentHelper_h |
| OLD | NEW |