| 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 ElementVisibilityObserver; |
| 31 class HTMLMediaElement; |
| 32 |
| 33 class AutoplayUmaHelper final : public EventListener { |
| 34 public: |
| 35 static AutoplayUmaHelper* create(HTMLMediaElement*); |
| 36 |
| 37 ~AutoplayUmaHelper(); |
| 38 |
| 39 bool operator==(const EventListener&) const override; |
| 40 |
| 41 void onAutoplayInitiated(AutoplaySource); |
| 42 |
| 43 void recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus); |
| 44 |
| 45 void onVisibilityChangedForVideoMutedPlayMethod(bool isVisible); |
| 46 |
| 47 DECLARE_VIRTUAL_TRACE(); |
| 48 |
| 49 private: |
| 50 explicit AutoplayUmaHelper(HTMLMediaElement*); |
| 51 |
| 52 void handleEvent(ExecutionContext*, Event*) override; |
| 53 |
| 54 void handlePlayingEvent(); |
| 55 void handleUnloadEvent(); |
| 56 |
| 57 // The autoplay source. Use AutoplaySource::NumberOfSources for invalid sour
ce. |
| 58 AutoplaySource m_source; |
| 59 // The media element this UMA helper is attached to. |m_element| owns |this|
. |
| 60 WeakMember<HTMLMediaElement> m_element; |
| 61 // The observer is used to observe whether a muted video autoplaying by play
() method become visible at some point. |
| 62 Member<ElementVisibilityObserver> m_videoMutedPlayMethodVisibilityObserver; |
| 63 }; |
| 64 |
| 65 } // namespace blink |
| 66 |
| 67 #endif // AutoplayUmaHelper_h |
| OLD | NEW |