Chromium Code Reviews| 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 }; | |
|
mlamouri (slow - plz ping)
2016/07/07 12:45:47
BTW, I think you can fwd declare these enums here
Zhiqiang Zhang (Slow)
2016/07/08 18:16:49
These enums are referenced in HTMLMediaElement, so
| |
| 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 void onElementDestroyed(); | |
| 43 | |
| 44 void recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus); | |
| 45 | |
| 46 void onVisibilityChangedForVideoMutedPlayMethod(bool isVisible); | |
| 47 | |
| 48 DECLARE_VIRTUAL_TRACE(); | |
| 49 | |
| 50 private: | |
| 51 explicit AutoplayUmaHelper(HTMLMediaElement*); | |
| 52 | |
| 53 void handleEvent(ExecutionContext*, Event*) override; | |
| 54 | |
| 55 void handlePlayingEvent(); | |
| 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 |