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

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 1700743003: Record whether and why the media default controls are being shown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@media-controls-usecount
Patch Set: review comments Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
index 94a7462aa3d18fe965aef3720517b3e66fc8ae9d..1b616ce8902e0b6e38e3c1b84c43cbf55d973910 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -111,6 +111,14 @@ namespace {
// URL protocol used to signal that the media source API is being used.
const char mediaSourceBlobProtocol[] = "blob";
+enum MediaControlsShow {
+ MediaControlsShowAttribute = 0,
+ MediaControlsShowFullscreen,
+ MediaControlsShowNoScript,
+ MediaControlsShowNone,
philipj_slow 2016/02/19 04:05:43 Maybe MediaControlsNotShown?
mlamouri (slow - plz ping) 2016/02/23 18:42:13 Done.
+ MediaControlsShowMax
philipj_slow 2016/02/19 04:05:43 AutoplayExperimentHelper.h has NumberOfAutoplayMet
mlamouri (slow - plz ping) 2016/02/23 18:42:13 Yes, it is a weird exception, see: https://code.go
philipj_slow 2016/02/24 09:54:33 OK, there's a bit of both, and some *Count as well
+};
+
#if !LOG_DISABLED
String urlForLoggingMedia(const KURL& url)
{
@@ -2083,17 +2091,7 @@ void HTMLMediaElement::setLoop(bool b)
bool HTMLMediaElement::shouldShowControls() const
{
- LocalFrame* frame = document().frame();
-
- // always show controls when scripting is disabled
- if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript))
- return true;
-
- // Always show controls when in full screen mode.
- if (isFullscreen())
- return true;
-
- return fastHasAttribute(controlsAttr);
+ return shouldShowControlsInternal(false);
}
double HTMLMediaElement::volume() const
@@ -3353,7 +3351,8 @@ void HTMLMediaElement::configureMediaControls()
ensureMediaControls();
mediaControls()->reset();
- if (shouldShowControls())
+
+ if (shouldShowControlsInternal(true))
mediaControls()->show();
else
mediaControls()->hide();
@@ -3575,6 +3574,39 @@ void HTMLMediaElement::triggerAutoplayViewportCheckForTesting()
m_autoplayHelper.triggerAutoplayViewportCheckForTesting();
}
+bool HTMLMediaElement::shouldShowControlsInternal(bool record) const
+{
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, showControlsHistogram, ("Media.Controls.Show", MediaControlsShowMax));
+
+ // These checks are in order of conditions superseeding each other, which
philipj_slow 2016/02/19 04:05:43 Well, this would be true of any order where all "r
mlamouri (slow - plz ping) 2016/02/23 18:42:13 I understand what you mean. I guess my comment is
+ // also matches speed. In other words, a media element with a controls
+ // attribute, will always have controls, regardless of the other conditions.
+ // Same for an element in fullscreen. That means that recorded metrics will
+ // only show the superseeding reason of the controls showing.
+
+ if (fastHasAttribute(controlsAttr)) {
+ if (record)
+ showControlsHistogram.count(MediaControlsShowAttribute);
+ return true;
+ }
+
+ if (isFullscreen()) {
+ if (record)
+ showControlsHistogram.count(MediaControlsShowFullscreen);
+ return true;
+ }
+
+ LocalFrame* frame = document().frame();
+ if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript)) {
+ if (record)
+ showControlsHistogram.count(MediaControlsShowNoScript);
+ return true;
+ }
+
+ showControlsHistogram.count(MediaControlsShowNone);
+ return false;
+}
+
void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
{
if (!Heap::isHeapObjectAlive(m_audioSourceNode))

Powered by Google App Engine
This is Rietveld 408576698