| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef AutoplayUmaHelper_h |
| 6 #define AutoplayUmaHelper_h |
| 7 |
| 8 #include "core/events/EventListener.h" |
| 9 #include "platform/heap/Handle.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 // These values are used for histograms. Do not reorder. |
| 14 enum class AutoplaySource { |
| 15 // Autoplay comes from HTMLMediaElement `autoplay` attribute. |
| 16 Attribute = 0, |
| 17 // Autoplay comes from `play()` method. |
| 18 Method = 1, |
| 19 // This enum value must be last. |
| 20 NumberOfSources = 2, |
| 21 }; |
| 22 |
| 23 // These values are used for histograms. Do not reorder. |
| 24 enum class AutoplayUnmuteActionStatus { |
| 25 Failure = 0, |
| 26 Success = 1, |
| 27 NumberOfStatus = 2, |
| 28 }; |
| 29 |
| 30 class Document; |
| 31 class ElementVisibilityObserver; |
| 32 class HTMLMediaElement; |
| 33 |
| 34 class AutoplayUmaHelper final : public EventListener { |
| 35 public: |
| 36 static AutoplayUmaHelper* create(HTMLMediaElement*); |
| 37 |
| 38 ~AutoplayUmaHelper(); |
| 39 |
| 40 bool operator==(const EventListener&) const override; |
| 41 |
| 42 void onAutoplayInitiated(AutoplaySource); |
| 43 |
| 44 void recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus); |
| 45 |
| 46 void onVisibilityChangedForVideoMutedPlayMethod(bool isVisible); |
| 47 |
| 48 void didMoveToNewDocument(Document& oldDocument); |
| 49 |
| 50 DECLARE_VIRTUAL_TRACE(); |
| 51 |
| 52 private: |
| 53 explicit AutoplayUmaHelper(HTMLMediaElement*); |
| 54 |
| 55 void handleEvent(ExecutionContext*, Event*) override; |
| 56 |
| 57 void handlePlayingEvent(); |
| 58 void handleUnloadEvent(); |
| 59 |
| 60 // The autoplay source. Use AutoplaySource::NumberOfSources for invalid sour
ce. |
| 61 AutoplaySource m_source; |
| 62 // The media element this UMA helper is attached to. |m_element| owns |this|
. |
| 63 WeakMember<HTMLMediaElement> m_element; |
| 64 // The observer is used to observe whether a muted video autoplaying by play
() method become visible at some point. |
| 65 Member<ElementVisibilityObserver> m_videoMutedPlayMethodVisibilityObserver; |
| 66 }; |
| 67 |
| 68 } // namespace blink |
| 69 |
| 70 #endif // AutoplayUmaHelper_h |
| OLD | NEW |