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

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

Issue 2159813002: Clean up Media_* actions by marking them obsolete and not_user_trigerred. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark obsolete Created 4 years, 4 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
« no previous file with comments | « no previous file | tools/metrics/actions/actions.xml » ('j') | tools/metrics/actions/actions.xml » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 // 14 - Set the seeking IDL attribute to false. 1787 // 14 - Set the seeking IDL attribute to false.
1788 m_seeking = false; 1788 m_seeking = false;
1789 1789
1790 // 16 - Queue a task to fire a simple event named timeupdate at the element. 1790 // 16 - Queue a task to fire a simple event named timeupdate at the element.
1791 scheduleTimeupdateEvent(false); 1791 scheduleTimeupdateEvent(false);
1792 1792
1793 // 17 - Queue a task to fire a simple event named seeked at the element. 1793 // 17 - Queue a task to fire a simple event named seeked at the element.
1794 scheduleEvent(EventTypeNames::seeked); 1794 scheduleEvent(EventTypeNames::seeked);
1795 1795
1796 setDisplayMode(Video); 1796 setDisplayMode(Video);
1797
1798 Platform::current()->recordAction(UserMetricsAction("Media_Seeked"));
1799 } 1797 }
1800 1798
1801 HTMLMediaElement::ReadyState HTMLMediaElement::getReadyState() const 1799 HTMLMediaElement::ReadyState HTMLMediaElement::getReadyState() const
1802 { 1800 {
1803 return m_readyState; 1801 return m_readyState;
1804 } 1802 }
1805 1803
1806 bool HTMLMediaElement::hasVideo() const 1804 bool HTMLMediaElement::hasVideo() const
1807 { 1805 {
1808 return webMediaPlayer() && webMediaPlayer()->hasVideo(); 1806 return webMediaPlayer() && webMediaPlayer()->hasVideo();
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 2095
2098 recordAutoplayMetric(PlayMethodFailed); 2096 recordAutoplayMetric(PlayMethodFailed);
2099 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); 2097 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture.");
2100 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); 2098 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message));
2101 return NotAllowedError; 2099 return NotAllowedError;
2102 } 2100 }
2103 } else { 2101 } else {
2104 UserGestureIndicator::utilizeUserGesture(); 2102 UserGestureIndicator::utilizeUserGesture();
2105 // We ask the helper to remove the gesture requirement for us, so that 2103 // We ask the helper to remove the gesture requirement for us, so that
2106 // it can record the reason. 2104 // it can record the reason.
2107 Platform::current()->recordAction(UserMetricsAction("Media_Play_WithGest ure"));
2108 m_autoplayHelper->unlockUserGesture(GesturelessPlaybackEnabledByPlayMeth od); 2105 m_autoplayHelper->unlockUserGesture(GesturelessPlaybackEnabledByPlayMeth od);
2109 } 2106 }
2110 2107
2111 if (m_error && m_error->code() == MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED) 2108 if (m_error && m_error->code() == MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED)
2112 return NotSupportedError; 2109 return NotSupportedError;
2113 2110
2114 playInternal(); 2111 playInternal();
2115 2112
2116 return nullptr; 2113 return nullptr;
2117 } 2114 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2185 scheduleRejectPlayPromises(AbortError); 2182 scheduleRejectPlayPromises(AbortError);
2186 } 2183 }
2187 2184
2188 updatePlayState(); 2185 updatePlayState();
2189 } 2186 }
2190 2187
2191 void HTMLMediaElement::requestRemotePlayback() 2188 void HTMLMediaElement::requestRemotePlayback()
2192 { 2189 {
2193 DCHECK(m_remoteRoutesAvailable); 2190 DCHECK(m_remoteRoutesAvailable);
2194 webMediaPlayer()->requestRemotePlayback(); 2191 webMediaPlayer()->requestRemotePlayback();
2195 Platform::current()->recordAction(UserMetricsAction("Media_RequestRemotePlay back"));
2196 } 2192 }
2197 2193
2198 void HTMLMediaElement::requestRemotePlaybackControl() 2194 void HTMLMediaElement::requestRemotePlaybackControl()
2199 { 2195 {
2200 DCHECK(m_remoteRoutesAvailable); 2196 DCHECK(m_remoteRoutesAvailable);
2201 webMediaPlayer()->requestRemotePlaybackControl(); 2197 webMediaPlayer()->requestRemotePlaybackControl();
2202 Platform::current()->recordAction(UserMetricsAction("Media_RequestRemotePlay back_Control"));
2203 } 2198 }
2204 2199
2205 void HTMLMediaElement::closeMediaSource() 2200 void HTMLMediaElement::closeMediaSource()
2206 { 2201 {
2207 if (!m_mediaSource) 2202 if (!m_mediaSource)
2208 return; 2203 return;
2209 2204
2210 m_mediaSource->close(); 2205 m_mediaSource->close();
2211 m_mediaSource = nullptr; 2206 m_mediaSource = nullptr;
2212 } 2207 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2258 BLINK_MEDIA_LOG << "setVolume(" << (void*)this << ", " << vol << ")"; 2253 BLINK_MEDIA_LOG << "setVolume(" << (void*)this << ", " << vol << ")";
2259 2254
2260 if (m_volume == vol) 2255 if (m_volume == vol)
2261 return; 2256 return;
2262 2257
2263 if (vol < 0.0f || vol > 1.0f) { 2258 if (vol < 0.0f || vol > 1.0f) {
2264 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", vol, 0.0, ExceptionMessages::InclusiveBound, 1.0, Except ionMessages::InclusiveBound)); 2259 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", vol, 0.0, ExceptionMessages::InclusiveBound, 1.0, Except ionMessages::InclusiveBound));
2265 return; 2260 return;
2266 } 2261 }
2267 2262
2268 Platform::current()->recordAction(UserMetricsAction("Media_SetVolume"));
2269
2270 m_volume = vol; 2263 m_volume = vol;
2271 updateVolume(); 2264 updateVolume();
2272 scheduleEvent(EventTypeNames::volumechange); 2265 scheduleEvent(EventTypeNames::volumechange);
2273 } 2266 }
2274 2267
2275 bool HTMLMediaElement::muted() const 2268 bool HTMLMediaElement::muted() const
2276 { 2269 {
2277 return m_muted; 2270 return m_muted;
2278 } 2271 }
2279 2272
2280 void HTMLMediaElement::setMuted(bool muted) 2273 void HTMLMediaElement::setMuted(bool muted)
2281 { 2274 {
2282 BLINK_MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) < < ")"; 2275 BLINK_MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) < < ")";
2283 2276
2284 if (m_muted == muted) 2277 if (m_muted == muted)
2285 return; 2278 return;
2286 2279
2287 bool wasAutoplayingMuted = !paused() && m_muted && isLockedPendingUserGestur e(); 2280 bool wasAutoplayingMuted = !paused() && m_muted && isLockedPendingUserGestur e();
2288 2281
2289 if (UserGestureIndicator::processingUserGesture()) 2282 if (UserGestureIndicator::processingUserGesture())
2290 unlockUserGesture(); 2283 unlockUserGesture();
2291 2284
2292 m_muted = muted; 2285 m_muted = muted;
2293 m_autoplayHelper->mutedChanged(); 2286 m_autoplayHelper->mutedChanged();
2294 2287
2295 updateVolume(); 2288 updateVolume();
2296 2289
2297 if (muted)
2298 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _On"));
2299 else
2300 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _Off"));
2301
2302 scheduleEvent(EventTypeNames::volumechange); 2290 scheduleEvent(EventTypeNames::volumechange);
2303 2291
2304 // If an element autoplayed while muted, it needs to be unlocked to unmute, 2292 // If an element autoplayed while muted, it needs to be unlocked to unmute,
2305 // otherwise, it will be paused. 2293 // otherwise, it will be paused.
2306 if (wasAutoplayingMuted) { 2294 if (wasAutoplayingMuted) {
2307 if (isGestureNeededForPlayback()) { 2295 if (isGestureNeededForPlayback()) {
2308 pause(); 2296 pause();
2309 recordAutoplayUnmuteStatus(AutoplayUnmuteActionFailure); 2297 recordAutoplayUnmuteStatus(AutoplayUnmuteActionFailure);
2310 } else { 2298 } else {
2311 recordAutoplayUnmuteStatus(AutoplayUnmuteActionSuccess); 2299 recordAutoplayUnmuteStatus(AutoplayUnmuteActionSuccess);
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
2901 } else { 2889 } else {
2902 // If the media element has still ended playback, and the direction of playback is still 2890 // If the media element has still ended playback, and the direction of playback is still
2903 // forwards, and paused is false, 2891 // forwards, and paused is false,
2904 if (!m_paused) { 2892 if (!m_paused) {
2905 // changes paused to true and fires a simple event named pause a t the media element. 2893 // changes paused to true and fires a simple event named pause a t the media element.
2906 m_paused = true; 2894 m_paused = true;
2907 scheduleEvent(EventTypeNames::pause); 2895 scheduleEvent(EventTypeNames::pause);
2908 } 2896 }
2909 // Queue a task to fire a simple event named ended at the media elem ent. 2897 // Queue a task to fire a simple event named ended at the media elem ent.
2910 scheduleEvent(EventTypeNames::ended); 2898 scheduleEvent(EventTypeNames::ended);
2911 Platform::current()->recordAction(UserMetricsAction("Media_Playback_ Ended"));
2912 } 2899 }
2913 } 2900 }
2914 updatePlayState(); 2901 updatePlayState();
2915 } 2902 }
2916 2903
2917 void HTMLMediaElement::durationChanged() 2904 void HTMLMediaElement::durationChanged()
2918 { 2905 {
2919 BLINK_MEDIA_LOG << "durationChanged(" << (void*)this << ")"; 2906 BLINK_MEDIA_LOG << "durationChanged(" << (void*)this << ")";
2920 // FIXME: Change WebMediaPlayer to convey the currentTime 2907 // FIXME: Change WebMediaPlayer to convey the currentTime
2921 // when the duration change occured. The current WebMediaPlayer 2908 // when the duration change occured. The current WebMediaPlayer
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
3127 if (shouldBePlaying) { 3114 if (shouldBePlaying) {
3128 setDisplayMode(Video); 3115 setDisplayMode(Video);
3129 invalidateCachedTime(); 3116 invalidateCachedTime();
3130 3117
3131 if (!isPlaying) { 3118 if (!isPlaying) {
3132 // Set rate, muted before calling play in case they were set before the media engine was setup. 3119 // Set rate, muted before calling play in case they were set before the media engine was setup.
3133 // The media engine should just stash the rate and muted values sinc e it isn't already playing. 3120 // The media engine should just stash the rate and muted values sinc e it isn't already playing.
3134 webMediaPlayer()->setRate(playbackRate()); 3121 webMediaPlayer()->setRate(playbackRate());
3135 updateVolume(); 3122 updateVolume();
3136 webMediaPlayer()->play(); 3123 webMediaPlayer()->play();
3137 Platform::current()->recordAction(
3138 UserMetricsAction("Media_Playback_Started"));
3139 m_autoplayHelper->playbackStarted(); 3124 m_autoplayHelper->playbackStarted();
3140 } 3125 }
3141 3126
3142 if (mediaControls()) 3127 if (mediaControls())
3143 mediaControls()->playbackStarted(); 3128 mediaControls()->playbackStarted();
3144 startPlaybackProgressTimer(); 3129 startPlaybackProgressTimer();
3145 m_playing = true; 3130 m_playing = true;
3146 3131
3147 } else { // Should not be playing right now 3132 } else { // Should not be playing right now
3148 if (isPlaying) { 3133 if (isPlaying) {
3149 webMediaPlayer()->pause(); 3134 webMediaPlayer()->pause();
3150 Platform::current()->recordAction(UserMetricsAction("Media_Paused")) ;
3151 m_autoplayHelper->playbackStopped(); 3135 m_autoplayHelper->playbackStopped();
3152 } 3136 }
3153 3137
3154 refreshCachedTime(); 3138 refreshCachedTime();
3155 3139
3156 m_playbackProgressTimer.stop(); 3140 m_playbackProgressTimer.stop();
3157 m_playing = false; 3141 m_playing = false;
3158 double time = currentTime(); 3142 double time = currentTime();
3159 if (time > m_lastSeekTime) 3143 if (time > m_lastSeekTime)
3160 addPlayedRange(m_lastSeekTime, time); 3144 addPlayedRange(m_lastSeekTime, time);
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
4036 4020
4037 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 4021 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
4038 { 4022 {
4039 IntRect result; 4023 IntRect result;
4040 if (LayoutObject* object = m_element->layoutObject()) 4024 if (LayoutObject* object = m_element->layoutObject())
4041 result = object->absoluteBoundingBoxRect(); 4025 result = object->absoluteBoundingBoxRect();
4042 return result; 4026 return result;
4043 } 4027 }
4044 4028
4045 } // namespace blink 4029 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/actions/actions.xml » ('j') | tools/metrics/actions/actions.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698