Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp

Issue 2108403003: Measure whether muted videos that started playing with play() become visible at some point (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: this one is ready Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698