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 #include "core/html/AutoplayUmaHelper.h" | |
| 6 | |
| 7 #include "core/html/HTMLMediaElement.h" | |
| 8 #include "platform/Histogram.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 void recordMutedVideoOfSourceMethodFinallyVisibleUma(bool visible) | |
| 15 { | |
| 16 DEFINE_STATIC_LOCAL(BooleanHistogram, histogram, ("Media.Video.Autoplay. Muted.SourceMethod.FinallyVisible")); | |
| 17 histogram.count(visible); | |
| 18 } | |
|
mlamouri (slow - plz ping)
2016/07/01 11:00:07
style: no indentation
Zhiqiang Zhang (Slow)
2016/07/04 14:34:38
Done.
| |
| 19 | |
| 20 } // namespace | |
| 21 | |
| 22 AutoplayUmaHelper::AutoplayUmaHelper(HTMLMediaElement* element) | |
| 23 : m_source(AutoplaySource::NumberOfSources) | |
| 24 , m_element(element) | |
| 25 { | |
| 26 } | |
| 27 | |
| 28 AutoplayUmaHelper::~AutoplayUmaHelper() = default; | |
| 29 | |
| 30 void AutoplayUmaHelper::onAutoplayInitiated(AutoplaySource source) | |
| 31 { | |
| 32 m_source = source; | |
| 33 } | |
| 34 | |
| 35 void AutoplayUmaHelper::onAutoplayStarted() | |
| 36 { | |
| 37 if (m_source == AutoplaySource::Method && m_element->isHTMLVideoElement() && m_element->muted()) | |
| 38 recordMutedVideoOfSourceMethodFinallyVisibleUma(true); | |
| 39 } | |
| 40 | |
| 41 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.
| |
| 42 { | |
| 43 if (m_source == AutoplaySource::Method && m_element->isHTMLVideoElement() && m_element->muted()) | |
| 44 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
| |
| 45 } | |
| 46 | |
| 47 DEFINE_TRACE(AutoplayUmaHelper) | |
| 48 { | |
| 49 visitor->trace(m_element); | |
| 50 } | |
| 51 | |
| 52 } // namespace blink | |
| OLD | NEW |