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

Side by Side 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, 9 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
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 using namespace HTMLNames; 104 using namespace HTMLNames;
105 105
106 using WeakMediaElementSet = WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaEl ement>>; 106 using WeakMediaElementSet = WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaEl ement>>;
107 using DocumentElementSetMap = WillBeHeapHashMap<RawPtrWillBeWeakMember<Document> , WeakMediaElementSet>; 107 using DocumentElementSetMap = WillBeHeapHashMap<RawPtrWillBeWeakMember<Document> , WeakMediaElementSet>;
108 108
109 namespace { 109 namespace {
110 110
111 // URL protocol used to signal that the media source API is being used. 111 // URL protocol used to signal that the media source API is being used.
112 const char mediaSourceBlobProtocol[] = "blob"; 112 const char mediaSourceBlobProtocol[] = "blob";
113 113
114 enum MediaControlsShow {
115 MediaControlsShowAttribute = 0,
116 MediaControlsShowFullscreen,
117 MediaControlsShowNoScript,
118 MediaControlsShowNotShown,
119 MediaControlsShowMax
120 };
121
114 #if !LOG_DISABLED 122 #if !LOG_DISABLED
115 String urlForLoggingMedia(const KURL& url) 123 String urlForLoggingMedia(const KURL& url)
116 { 124 {
117 static const unsigned maximumURLLengthForLogging = 128; 125 static const unsigned maximumURLLengthForLogging = 128;
118 126
119 if (url.string().length() < maximumURLLengthForLogging) 127 if (url.string().length() < maximumURLLengthForLogging)
120 return url.string(); 128 return url.string();
121 return url.string().substring(0, maximumURLLengthForLogging) + "..."; 129 return url.string().substring(0, maximumURLLengthForLogging) + "...";
122 } 130 }
123 131
(...skipping 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 { 2079 {
2072 return fastHasAttribute(loopAttr); 2080 return fastHasAttribute(loopAttr);
2073 } 2081 }
2074 2082
2075 void HTMLMediaElement::setLoop(bool b) 2083 void HTMLMediaElement::setLoop(bool b)
2076 { 2084 {
2077 WTF_LOG(Media, "HTMLMediaElement::setLoop(%p, %s)", this, boolString(b)); 2085 WTF_LOG(Media, "HTMLMediaElement::setLoop(%p, %s)", this, boolString(b));
2078 setBooleanAttribute(loopAttr, b); 2086 setBooleanAttribute(loopAttr, b);
2079 } 2087 }
2080 2088
2081 bool HTMLMediaElement::shouldShowControls() const 2089 bool HTMLMediaElement::shouldShowControls(const RecordMetricsBehavior recordMetr ics) const
2082 { 2090 {
2091 DEFINE_STATIC_LOCAL(EnumerationHistogram, showControlsHistogram, ("Media.Con trols.Show", MediaControlsShowMax));
2092
2093 if (fastHasAttribute(controlsAttr)) {
2094 if (recordMetrics == RecordMetricsBehavior::DoRecord)
2095 showControlsHistogram.count(MediaControlsShowAttribute);
2096 return true;
2097 }
2098
2099 if (isFullscreen()) {
2100 if (recordMetrics == RecordMetricsBehavior::DoRecord)
2101 showControlsHistogram.count(MediaControlsShowFullscreen);
2102 return true;
2103 }
2104
2083 LocalFrame* frame = document().frame(); 2105 LocalFrame* frame = document().frame();
2106 if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript)) {
2107 if (recordMetrics == RecordMetricsBehavior::DoRecord)
2108 showControlsHistogram.count(MediaControlsShowNoScript);
2109 return true;
2110 }
2084 2111
2085 // always show controls when scripting is disabled 2112 if (recordMetrics == RecordMetricsBehavior::DoRecord)
2086 if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript)) 2113 showControlsHistogram.count(MediaControlsShowNotShown);
2087 return true; 2114 return false;
2088
2089 // Always show controls when in full screen mode.
2090 if (isFullscreen())
2091 return true;
2092
2093 return fastHasAttribute(controlsAttr);
2094 } 2115 }
2095 2116
2096 double HTMLMediaElement::volume() const 2117 double HTMLMediaElement::volume() const
2097 { 2118 {
2098 return m_volume; 2119 return m_volume;
2099 } 2120 }
2100 2121
2101 void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState) 2122 void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState)
2102 { 2123 {
2103 WTF_LOG(Media, "HTMLMediaElement::setVolume(%p, %f)", this, vol); 2124 WTF_LOG(Media, "HTMLMediaElement::setVolume(%p, %f)", this, vol);
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
3339 void HTMLMediaElement::configureMediaControls() 3360 void HTMLMediaElement::configureMediaControls()
3340 { 3361 {
3341 if (!inDocument()) { 3362 if (!inDocument()) {
3342 if (mediaControls()) 3363 if (mediaControls())
3343 mediaControls()->hide(); 3364 mediaControls()->hide();
3344 return; 3365 return;
3345 } 3366 }
3346 3367
3347 ensureMediaControls(); 3368 ensureMediaControls();
3348 mediaControls()->reset(); 3369 mediaControls()->reset();
3349 if (shouldShowControls()) 3370
3371 if (shouldShowControls(RecordMetricsBehavior::DoRecord))
3350 mediaControls()->show(); 3372 mediaControls()->show();
3351 else 3373 else
3352 mediaControls()->hide(); 3374 mediaControls()->hide();
3353 } 3375 }
3354 3376
3355 CueTimeline& HTMLMediaElement::cueTimeline() 3377 CueTimeline& HTMLMediaElement::cueTimeline()
3356 { 3378 {
3357 if (!m_cueTimeline) 3379 if (!m_cueTimeline)
3358 m_cueTimeline = adoptPtrWillBeNoop(new CueTimeline(*this)); 3380 m_cueTimeline = adoptPtrWillBeNoop(new CueTimeline(*this));
3359 return *m_cueTimeline; 3381 return *m_cueTimeline;
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
3628 { 3650 {
3629 visitor->trace(m_client); 3651 visitor->trace(m_client);
3630 } 3652 }
3631 3653
3632 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) 3654 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl)
3633 { 3655 {
3634 visitor->trace(m_client); 3656 visitor->trace(m_client);
3635 } 3657 }
3636 3658
3637 } // namespace blink 3659 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698