Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp |
| diff --git a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..980643009d2ae0dfd85ea1f9b725ad67dccf1c16 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp |
| @@ -0,0 +1,52 @@ |
| +// 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. |
| + |
| +#include "core/html/AutoplayUmaHelper.h" |
| + |
| +#include "core/html/HTMLMediaElement.h" |
| +#include "platform/Histogram.h" |
| + |
| +namespace blink { |
| + |
| +namespace { |
| + |
| + void recordMutedVideoOfSourceMethodFinallyVisibleUma(bool visible) |
| + { |
| + DEFINE_STATIC_LOCAL(BooleanHistogram, histogram, ("Media.Video.Autoplay.Muted.SourceMethod.FinallyVisible")); |
| + histogram.count(visible); |
| + } |
|
mlamouri (slow - plz ping)
2016/07/01 11:00:07
style: no indentation
Zhiqiang Zhang (Slow)
2016/07/04 14:34:38
Done.
|
| + |
| +} // namespace |
| + |
| +AutoplayUmaHelper::AutoplayUmaHelper(HTMLMediaElement* element) |
| + : m_source(AutoplaySource::NumberOfSources) |
| + , m_element(element) |
| +{ |
| +} |
| + |
| +AutoplayUmaHelper::~AutoplayUmaHelper() = default; |
| + |
| +void AutoplayUmaHelper::onAutoplayInitiated(AutoplaySource source) |
| +{ |
| + m_source = source; |
| +} |
| + |
| +void AutoplayUmaHelper::onAutoplayStarted() |
| +{ |
| + if (m_source == AutoplaySource::Method && m_element->isHTMLVideoElement() && m_element->muted()) |
| + recordMutedVideoOfSourceMethodFinallyVisibleUma(true); |
| +} |
| + |
| +void AutoplayUmaHelper::onElementDestroyed() |
|
mlamouri (slow - plz ping)
2016/07/01 11:00:07
The issue with recording UMA in a dtor is that it
Zhiqiang Zhang (Slow)
2016/07/04 14:34:38
Done.
|
| +{ |
| + if (m_source == AutoplaySource::Method && m_element->isHTMLVideoElement() && m_element->muted()) |
| + recordMutedVideoOfSourceMethodFinallyVisibleUma(false); |
|
mlamouri (slow - plz ping)
2016/07/01 11:00:07
Maybe you could have a `m_shouldRecordVisibilityCh
Zhiqiang Zhang (Slow)
2016/07/04 14:34:38
The logic here was wrong. I'm using a ElementVisib
|
| +} |
| + |
| +DEFINE_TRACE(AutoplayUmaHelper) |
| +{ |
| + visitor->trace(m_element); |
| +} |
| + |
| +} // namespace blink |