Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d7e6dfadf61d7e800b25325615a9eb5087d745d7 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef AutoplayUmaHelper_h |
| +#define AutoplayUmaHelper_h |
| + |
| +#include "platform/heap/Handle.h" |
| + |
| +namespace blink { |
| + |
| +// These values are used for histograms. Do not reorder. |
| +enum class AutoplaySource { |
| + // Autoplay comes from HTMLMediaElement `autoplay` attribute. |
| + Attribute = 0, |
| + // Autoplay comes from `play()` method. |
| + Method = 1, |
| + // This enum value must be last. |
| + NumberOfSources = 2, |
| +}; |
| + |
| +// These values are used for histograms. Do not reorder. |
| +enum AutoplayUnmuteActionStatus { |
|
mlamouri (slow - plz ping)
2016/07/04 15:18:19
nit: `enum class`
Zhiqiang Zhang (Slow)
2016/07/06 13:55:51
Done.
|
| + Failure = 0, |
| + Success = 1, |
| + NumberOfStatus = 2, |
| +}; |
| + |
| +class ElementVisibilityObserver; |
| +class HTMLMediaElement; |
| + |
| +class AutoplayUmaHelper final : public GarbageCollectedFinalized<AutoplayUmaHelper> { |
| + |
|
mlamouri (slow - plz ping)
2016/07/04 15:18:19
style: remove empty line
Zhiqiang Zhang (Slow)
2016/07/06 13:55:51
Done.
|
| +public: |
| + |
|
mlamouri (slow - plz ping)
2016/07/04 15:18:19
style: ditto
Zhiqiang Zhang (Slow)
2016/07/06 13:55:51
Done.
|
| + static AutoplayUmaHelper* create(HTMLMediaElement* element) |
| + { |
| + return new AutoplayUmaHelper(element); |
| + } |
|
mlamouri (slow - plz ping)
2016/07/04 15:18:19
nit: can you move the definition to the cpp ?
Zhiqiang Zhang (Slow)
2016/07/06 13:55:51
Done.
|
| + |
| + ~AutoplayUmaHelper(); |
| + |
| + void onAutoplayInitiated(AutoplaySource); |
| + void onAutoplayStarted(); |
| + void onElementDestroyed(); |
| + |
| + void recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus); |
| + |
| + void onVisibilityChangedForVideoMutedPlayMethod(bool isVisible); |
| + |
| + DECLARE_TRACE(); |
| + |
| +private: |
| + explicit AutoplayUmaHelper(HTMLMediaElement*); |
| + |
| + // The autoplay source. Use AutoplaySource::NumberOfSources for invalid source. |
| + AutoplaySource m_source; |
| + WeakMember<HTMLMediaElement> m_element; |
| + Member<ElementVisibilityObserver> m_videoMutedPlayMethodVisibilityObserver; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // AutoplayUmaHelper_h |