Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 26 matching lines...) Expand all Loading... | |
| 37 #include "core/dom/ElementTraversal.h" | 37 #include "core/dom/ElementTraversal.h" |
| 38 #include "core/dom/ElementVisibilityObserver.h" | 38 #include "core/dom/ElementVisibilityObserver.h" |
| 39 #include "core/dom/Fullscreen.h" | 39 #include "core/dom/Fullscreen.h" |
| 40 #include "core/dom/shadow/ShadowRoot.h" | 40 #include "core/dom/shadow/ShadowRoot.h" |
| 41 #include "core/events/Event.h" | 41 #include "core/events/Event.h" |
| 42 #include "core/frame/FrameView.h" | 42 #include "core/frame/FrameView.h" |
| 43 #include "core/frame/LocalFrame.h" | 43 #include "core/frame/LocalFrame.h" |
| 44 #include "core/frame/Settings.h" | 44 #include "core/frame/Settings.h" |
| 45 #include "core/frame/UseCounter.h" | 45 #include "core/frame/UseCounter.h" |
| 46 #include "core/frame/csp/ContentSecurityPolicy.h" | 46 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 47 #include "core/html/AutoplayUmaHelper.h" | |
| 47 #include "core/html/HTMLMediaSource.h" | 48 #include "core/html/HTMLMediaSource.h" |
| 48 #include "core/html/HTMLSourceElement.h" | 49 #include "core/html/HTMLSourceElement.h" |
| 49 #include "core/html/HTMLTrackElement.h" | 50 #include "core/html/HTMLTrackElement.h" |
| 50 #include "core/html/MediaError.h" | 51 #include "core/html/MediaError.h" |
| 51 #include "core/html/MediaFragmentURIParser.h" | 52 #include "core/html/MediaFragmentURIParser.h" |
| 52 #include "core/html/TimeRanges.h" | 53 #include "core/html/TimeRanges.h" |
| 53 #include "core/html/shadow/MediaControls.h" | 54 #include "core/html/shadow/MediaControls.h" |
| 54 #include "core/html/track/AudioTrack.h" | 55 #include "core/html/track/AudioTrack.h" |
| 55 #include "core/html/track/AudioTrackList.h" | 56 #include "core/html/track/AudioTrackList.h" |
| 56 #include "core/html/track/AutomaticTrackSelection.h" | 57 #include "core/html/track/AutomaticTrackSelection.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 case WebMediaPlayer::PreloadMetaData: | 274 case WebMediaPlayer::PreloadMetaData: |
| 274 return "metadata"; | 275 return "metadata"; |
| 275 case WebMediaPlayer::PreloadAuto: | 276 case WebMediaPlayer::PreloadAuto: |
| 276 return "auto"; | 277 return "auto"; |
| 277 } | 278 } |
| 278 | 279 |
| 279 NOTREACHED(); | 280 NOTREACHED(); |
| 280 return String(); | 281 return String(); |
| 281 } | 282 } |
| 282 | 283 |
| 283 // These values are used for histograms. Do not reorder. | |
| 284 enum AutoplaySource { | |
| 285 // Autoplay comes from HTMLMediaElement `autoplay` attribute. | |
| 286 AutoplaySourceAttribute = 0, | |
| 287 // Autoplay comes from `play()` method. | |
| 288 AutoplaySourceMethod = 1, | |
| 289 // This enum value must be last. | |
| 290 NumberOfAutoplaySources = 2, | |
| 291 }; | |
| 292 | |
| 293 } // anonymous namespace | 284 } // anonymous namespace |
| 294 | 285 |
| 295 class HTMLMediaElement::AutoplayHelperClientImpl : | 286 class HTMLMediaElement::AutoplayHelperClientImpl : |
| 296 public AutoplayExperimentHelper::Client { | 287 public AutoplayExperimentHelper::Client { |
| 297 | 288 |
| 298 public: | 289 public: |
| 299 static AutoplayHelperClientImpl* create(HTMLMediaElement* element) | 290 static AutoplayHelperClientImpl* create(HTMLMediaElement* element) |
| 300 { | 291 { |
| 301 return new AutoplayHelperClientImpl(element); | 292 return new AutoplayHelperClientImpl(element); |
| 302 } | 293 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 , m_playingRemotely(false) | 431 , m_playingRemotely(false) |
| 441 , m_inOverlayFullscreenVideo(false) | 432 , m_inOverlayFullscreenVideo(false) |
| 442 , m_audioTracks(AudioTrackList::create(*this)) | 433 , m_audioTracks(AudioTrackList::create(*this)) |
| 443 , m_videoTracks(VideoTrackList::create(*this)) | 434 , m_videoTracks(VideoTrackList::create(*this)) |
| 444 , m_textTracks(nullptr) | 435 , m_textTracks(nullptr) |
| 445 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl ement::resolveScheduledPlayPromises)) | 436 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl ement::resolveScheduledPlayPromises)) |
| 446 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle ment::rejectScheduledPlayPromises)) | 437 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle ment::rejectScheduledPlayPromises)) |
| 447 , m_audioSourceNode(nullptr) | 438 , m_audioSourceNode(nullptr) |
| 448 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this)) | 439 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this)) |
| 449 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g et())) | 440 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g et())) |
| 441 , m_autoplayUmaHelper(AutoplayUmaHelper::create(this)) | |
| 450 , m_remotePlaybackClient(nullptr) | 442 , m_remotePlaybackClient(nullptr) |
| 451 , m_autoplayVisibilityObserver(nullptr) | 443 , m_autoplayVisibilityObserver(nullptr) |
| 452 { | 444 { |
| 453 ThreadState::current()->registerPreFinalizer(this); | 445 ThreadState::current()->registerPreFinalizer(this); |
| 454 | 446 |
| 455 MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; | 447 MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; |
| 456 | 448 |
| 457 // If any experiment is enabled, then we want to enable a user gesture by | 449 // If any experiment is enabled, then we want to enable a user gesture by |
| 458 // default, otherwise the experiment does nothing. | 450 // default, otherwise the experiment does nothing. |
| 459 if ((document.settings() && document.settings()->mediaPlaybackRequiresUserGe sture()) | 451 if ((document.settings() && document.settings()->mediaPlaybackRequiresUserGe sture()) |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 483 closeMediaSource(); | 475 closeMediaSource(); |
| 484 | 476 |
| 485 // Destroying the player may cause a resource load to be canceled, | 477 // Destroying the player may cause a resource load to be canceled, |
| 486 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being | 478 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being |
| 487 // called via ResourceFetch::didLoadResource(), then | 479 // called via ResourceFetch::didLoadResource(), then |
| 488 // FrameLoader::checkCompleted(). But it's guaranteed that the load event | 480 // FrameLoader::checkCompleted(). But it's guaranteed that the load event |
| 489 // doesn't get dispatched during the object destruction. | 481 // doesn't get dispatched during the object destruction. |
| 490 // See Document::isDelayingLoadEvent(). | 482 // See Document::isDelayingLoadEvent(). |
| 491 // Also see http://crbug.com/275223 for more details. | 483 // Also see http://crbug.com/275223 for more details. |
| 492 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 484 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
| 485 | |
| 486 m_autoplayUmaHelper->onElementDestroyed(); | |
| 493 } | 487 } |
| 494 | 488 |
| 495 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) | 489 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) |
| 496 { | 490 { |
| 497 MEDIA_LOG << "didMoveToNewDocument(" << (void*)this << ")"; | 491 MEDIA_LOG << "didMoveToNewDocument(" << (void*)this << ")"; |
| 498 | 492 |
| 499 // If any experiment is enabled, then we want to enable a user gesture by | 493 // If any experiment is enabled, then we want to enable a user gesture by |
| 500 // default, otherwise the experiment does nothing. | 494 // default, otherwise the experiment does nothing. |
| 501 bool oldDocumentRequiresUserGesture = (oldDocument.settings() && oldDocument .settings()->mediaPlaybackRequiresUserGesture()) | 495 bool oldDocumentRequiresUserGesture = (oldDocument.settings() && oldDocument .settings()->mediaPlaybackRequiresUserGesture()) |
| 502 || m_autoplayHelper->isExperimentEnabled(); | 496 || m_autoplayHelper->isExperimentEnabled(); |
| (...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1619 | 1613 |
| 1620 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { | 1614 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { |
| 1621 if (oldState <= HAVE_CURRENT_DATA) { | 1615 if (oldState <= HAVE_CURRENT_DATA) { |
| 1622 scheduleEvent(EventTypeNames::canplay); | 1616 scheduleEvent(EventTypeNames::canplay); |
| 1623 if (isPotentiallyPlaying) | 1617 if (isPotentiallyPlaying) |
| 1624 scheduleNotifyPlaying(); | 1618 scheduleNotifyPlaying(); |
| 1625 } | 1619 } |
| 1626 | 1620 |
| 1627 // Check for autoplay, and record metrics about it if needed. | 1621 // Check for autoplay, and record metrics about it if needed. |
| 1628 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { | 1622 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { |
| 1629 recordAutoplaySourceMetric(AutoplaySourceAttribute); | 1623 m_autoplayUmaHelper->onAutoplayInitiated(AutoplaySource::Attribute); |
|
mlamouri (slow - plz ping)
2016/07/04 15:18:19
I wonder if we shouldn't move this check to the pr
Zhiqiang Zhang (Slow)
2016/07/06 13:55:51
Acknowledged.
| |
| 1630 | 1624 |
| 1631 // If the autoplay experiment says that it's okay to play now, | 1625 // If the autoplay experiment says that it's okay to play now, |
| 1632 // then don't require a user gesture. | 1626 // then don't require a user gesture. |
| 1633 m_autoplayHelper->becameReadyToPlay(); | 1627 m_autoplayHelper->becameReadyToPlay(); |
| 1634 | 1628 |
| 1635 if (!isGestureNeededForPlayback()) { | 1629 if (!isGestureNeededForPlayback()) { |
| 1636 if (isHTMLVideoElement() && muted() && RuntimeEnabledFeatures::a utoplayMutedVideosEnabled()) { | 1630 if (isHTMLVideoElement() && muted() && RuntimeEnabledFeatures::a utoplayMutedVideosEnabled()) { |
| 1637 m_autoplayVisibilityObserver = new ElementVisibilityObserver (this, WTF::bind(&HTMLMediaElement::onVisibilityChangedForAutoplay, wrapPersiste nt(this))); | 1631 m_autoplayVisibilityObserver = new ElementVisibilityObserver (this, WTF::bind(&HTMLMediaElement::onVisibilityChangedForAutoplay, wrapPersiste nt(this))); |
| 1638 m_autoplayVisibilityObserver->start(); | 1632 m_autoplayVisibilityObserver->start(); |
| 1639 } else { | 1633 } else { |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2069 return promise; | 2063 return promise; |
| 2070 } | 2064 } |
| 2071 | 2065 |
| 2072 Nullable<ExceptionCode> HTMLMediaElement::play() | 2066 Nullable<ExceptionCode> HTMLMediaElement::play() |
| 2073 { | 2067 { |
| 2074 MEDIA_LOG << "play(" << (void*)this << ")"; | 2068 MEDIA_LOG << "play(" << (void*)this << ")"; |
| 2075 | 2069 |
| 2076 m_autoplayHelper->playMethodCalled(); | 2070 m_autoplayHelper->playMethodCalled(); |
| 2077 | 2071 |
| 2078 if (!UserGestureIndicator::processingUserGesture()) { | 2072 if (!UserGestureIndicator::processingUserGesture()) { |
| 2079 recordAutoplaySourceMetric(AutoplaySourceMethod); | 2073 m_autoplayUmaHelper->onAutoplayInitiated(AutoplaySource::Method); |
| 2080 if (isGestureNeededForPlayback()) { | 2074 if (isGestureNeededForPlayback()) { |
| 2081 // If playback is deferred, then don't start playback but don't | 2075 // If playback is deferred, then don't start playback but don't |
| 2082 // fail yet either. | 2076 // fail yet either. |
| 2083 if (m_autoplayHelper->isPlaybackDeferred()) | 2077 if (m_autoplayHelper->isPlaybackDeferred()) |
| 2084 return nullptr; | 2078 return nullptr; |
| 2085 | 2079 |
| 2086 // If we're already playing, then this play would do nothing anyway. | 2080 // If we're already playing, then this play would do nothing anyway. |
| 2087 // Call playInternal to handle scheduling the promise resolution. | 2081 // Call playInternal to handle scheduling the promise resolution. |
| 2088 if (!m_paused) { | 2082 if (!m_paused) { |
| 2089 playInternal(); | 2083 playInternal(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2125 if (m_networkState == NETWORK_EMPTY) | 2119 if (m_networkState == NETWORK_EMPTY) |
| 2126 invokeResourceSelectionAlgorithm(); | 2120 invokeResourceSelectionAlgorithm(); |
| 2127 | 2121 |
| 2128 // Generally "ended" and "looping" are exclusive. Here, the loop attribute | 2122 // Generally "ended" and "looping" are exclusive. Here, the loop attribute |
| 2129 // is ignored to seek back to start in case loop was set after playback | 2123 // is ignored to seek back to start in case loop was set after playback |
| 2130 // ended. See http://crbug.com/364442 | 2124 // ended. See http://crbug.com/364442 |
| 2131 if (endedPlayback(LoopCondition::Ignored)) | 2125 if (endedPlayback(LoopCondition::Ignored)) |
| 2132 seek(0); | 2126 seek(0); |
| 2133 | 2127 |
| 2134 if (m_paused) { | 2128 if (m_paused) { |
| 2129 m_autoplayUmaHelper->onAutoplayStarted(); | |
|
mlamouri (slow - plz ping)
2016/07/04 15:18:19
Maybe this should be called onPlaybackStart{,ed,in
Zhiqiang Zhang (Slow)
2016/07/06 13:55:51
Using EventListener now :)
| |
| 2135 m_paused = false; | 2130 m_paused = false; |
| 2136 invalidateCachedTime(); | 2131 invalidateCachedTime(); |
| 2137 scheduleEvent(EventTypeNames::play); | 2132 scheduleEvent(EventTypeNames::play); |
| 2138 | 2133 |
| 2139 if (m_readyState <= HAVE_CURRENT_DATA) | 2134 if (m_readyState <= HAVE_CURRENT_DATA) |
| 2140 scheduleEvent(EventTypeNames::waiting); | 2135 scheduleEvent(EventTypeNames::waiting); |
| 2141 else if (m_readyState >= HAVE_FUTURE_DATA) | 2136 else if (m_readyState >= HAVE_FUTURE_DATA) |
| 2142 scheduleNotifyPlaying(); | 2137 scheduleNotifyPlaying(); |
| 2143 } else if (m_readyState >= HAVE_FUTURE_DATA) { | 2138 } else if (m_readyState >= HAVE_FUTURE_DATA) { |
| 2144 scheduleResolvePlayPromises(); | 2139 scheduleResolvePlayPromises(); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2294 else | 2289 else |
| 2295 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _Off")); | 2290 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _Off")); |
| 2296 | 2291 |
| 2297 scheduleEvent(EventTypeNames::volumechange); | 2292 scheduleEvent(EventTypeNames::volumechange); |
| 2298 | 2293 |
| 2299 // If an element autoplayed while muted, it needs to be unlocked to unmute, | 2294 // If an element autoplayed while muted, it needs to be unlocked to unmute, |
| 2300 // otherwise, it will be paused. | 2295 // otherwise, it will be paused. |
| 2301 if (wasAutoplayingMuted) { | 2296 if (wasAutoplayingMuted) { |
| 2302 if (isGestureNeededForPlayback()) { | 2297 if (isGestureNeededForPlayback()) { |
| 2303 pause(); | 2298 pause(); |
| 2304 recordAutoplayUnmuteStatus(AutoplayUnmuteActionFailure); | 2299 m_autoplayUmaHelper->recordAutoplayUnmuteStatus(AutoplayUnmuteAction Status::Failure); |
| 2305 } else { | 2300 } else { |
| 2306 recordAutoplayUnmuteStatus(AutoplayUnmuteActionSuccess); | 2301 m_autoplayUmaHelper->recordAutoplayUnmuteStatus(AutoplayUnmuteAction Status::Success); |
| 2307 } | 2302 } |
| 2308 } | 2303 } |
| 2309 } | 2304 } |
| 2310 | 2305 |
| 2311 void HTMLMediaElement::updateVolume() | 2306 void HTMLMediaElement::updateVolume() |
| 2312 { | 2307 { |
| 2313 if (webMediaPlayer()) | 2308 if (webMediaPlayer()) |
| 2314 webMediaPlayer()->setVolume(effectiveMediaVolume()); | 2309 webMediaPlayer()->setVolume(effectiveMediaVolume()); |
| 2315 | 2310 |
| 2316 if (mediaControls()) | 2311 if (mediaControls()) |
| (...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3654 visitor->trace(m_videoTracks); | 3649 visitor->trace(m_videoTracks); |
| 3655 visitor->trace(m_cueTimeline); | 3650 visitor->trace(m_cueTimeline); |
| 3656 visitor->trace(m_textTracks); | 3651 visitor->trace(m_textTracks); |
| 3657 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3652 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
| 3658 visitor->trace(m_playPromiseResolvers); | 3653 visitor->trace(m_playPromiseResolvers); |
| 3659 visitor->trace(m_playPromiseResolveList); | 3654 visitor->trace(m_playPromiseResolveList); |
| 3660 visitor->trace(m_playPromiseRejectList); | 3655 visitor->trace(m_playPromiseRejectList); |
| 3661 visitor->trace(m_audioSourceProvider); | 3656 visitor->trace(m_audioSourceProvider); |
| 3662 visitor->trace(m_autoplayHelperClient); | 3657 visitor->trace(m_autoplayHelperClient); |
| 3663 visitor->trace(m_autoplayHelper); | 3658 visitor->trace(m_autoplayHelper); |
| 3659 visitor->trace(m_autoplayUmaHelper); | |
| 3664 visitor->trace(m_srcObject); | 3660 visitor->trace(m_srcObject); |
| 3665 visitor->trace(m_autoplayVisibilityObserver); | 3661 visitor->trace(m_autoplayVisibilityObserver); |
| 3666 visitor->template registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::c learWeakMembers>(this); | 3662 visitor->template registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::c learWeakMembers>(this); |
| 3667 Supplementable<HTMLMediaElement>::trace(visitor); | 3663 Supplementable<HTMLMediaElement>::trace(visitor); |
| 3668 HTMLElement::trace(visitor); | 3664 HTMLElement::trace(visitor); |
| 3669 ActiveDOMObject::trace(visitor); | 3665 ActiveDOMObject::trace(visitor); |
| 3670 } | 3666 } |
| 3671 | 3667 |
| 3672 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) | 3668 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) |
| 3673 { | 3669 { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3874 { | 3870 { |
| 3875 if (isHTMLVideoElement()) { | 3871 if (isHTMLVideoElement()) { |
| 3876 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, ("Media.Controls.Sh ow.Video", MediaControlsShowMax)); | 3872 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, ("Media.Controls.Sh ow.Video", MediaControlsShowMax)); |
| 3877 return histogram; | 3873 return histogram; |
| 3878 } | 3874 } |
| 3879 | 3875 |
| 3880 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, ("Media.Controls.Show.A udio", MediaControlsShowMax)); | 3876 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, ("Media.Controls.Show.A udio", MediaControlsShowMax)); |
| 3881 return histogram; | 3877 return histogram; |
| 3882 } | 3878 } |
| 3883 | 3879 |
| 3884 void HTMLMediaElement::recordAutoplaySourceMetric(int source) | |
| 3885 { | |
| 3886 DEFINE_STATIC_LOCAL(EnumerationHistogram, videoHistogram, ("Media.Video.Auto play", NumberOfAutoplaySources)); | |
| 3887 DEFINE_STATIC_LOCAL(EnumerationHistogram, mutedVideoHistogram, ("Media.Video .Autoplay.Muted", NumberOfAutoplaySources)); | |
| 3888 DEFINE_STATIC_LOCAL(EnumerationHistogram, audioHistogram, ("Media.Audio.Auto play", NumberOfAutoplaySources)); | |
| 3889 | |
| 3890 if (isHTMLVideoElement()) { | |
| 3891 videoHistogram.count(source); | |
| 3892 if (muted()) | |
| 3893 mutedVideoHistogram.count(source); | |
| 3894 } else { | |
| 3895 audioHistogram.count(source); | |
| 3896 } | |
| 3897 } | |
| 3898 | |
| 3899 void HTMLMediaElement::recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus sta tus) | |
| 3900 { | |
| 3901 DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayUnmuteHistogram, ("Media.V ideo.Autoplay.Muted.UnmuteAction", AutoplayUnmuteActionMax)); | |
| 3902 | |
| 3903 autoplayUnmuteHistogram.count(status); | |
| 3904 } | |
| 3905 | |
| 3906 void HTMLMediaElement::onVisibilityChangedForAutoplay(bool isVisible) | 3880 void HTMLMediaElement::onVisibilityChangedForAutoplay(bool isVisible) |
| 3907 { | 3881 { |
| 3908 if (!isVisible) | 3882 if (!isVisible) |
| 3909 return; | 3883 return; |
| 3910 | 3884 |
| 3911 if (shouldAutoplay()) { | 3885 if (shouldAutoplay()) { |
| 3912 m_paused = false; | 3886 m_paused = false; |
| 3913 invalidateCachedTime(); | 3887 invalidateCachedTime(); |
| 3914 scheduleEvent(EventTypeNames::play); | 3888 scheduleEvent(EventTypeNames::play); |
| 3915 scheduleNotifyPlaying(); | 3889 scheduleNotifyPlaying(); |
| 3916 m_autoplaying = false; | 3890 m_autoplaying = false; |
| 3917 | 3891 |
| 3918 updatePlayState(); | 3892 updatePlayState(); |
| 3893 m_autoplayUmaHelper->onAutoplayStarted(); | |
| 3919 } | 3894 } |
|
mlamouri (slow - plz ping)
2016/07/04 15:18:19
If we are here, the source is unlikely play() so i
Zhiqiang Zhang (Slow)
2016/07/06 13:55:51
Since we are using EventListener, there's no probl
| |
| 3920 | 3895 |
| 3921 m_autoplayVisibilityObserver->stop(); | 3896 m_autoplayVisibilityObserver->stop(); |
| 3922 m_autoplayVisibilityObserver = nullptr; | 3897 m_autoplayVisibilityObserver = nullptr; |
| 3923 } | 3898 } |
| 3924 | 3899 |
| 3925 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3900 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3926 { | 3901 { |
| 3927 if (!ThreadHeap::isHeapObjectAlive(m_audioSourceNode)) { | 3902 if (!ThreadHeap::isHeapObjectAlive(m_audioSourceNode)) { |
| 3928 getAudioSourceProvider().setClient(nullptr); | 3903 getAudioSourceProvider().setClient(nullptr); |
| 3929 m_audioSourceNode = nullptr; | 3904 m_audioSourceNode = nullptr; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4028 | 4003 |
| 4029 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst | 4004 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst |
| 4030 { | 4005 { |
| 4031 IntRect result; | 4006 IntRect result; |
| 4032 if (LayoutObject* object = m_element->layoutObject()) | 4007 if (LayoutObject* object = m_element->layoutObject()) |
| 4033 result = object->absoluteBoundingBoxRect(); | 4008 result = object->absoluteBoundingBoxRect(); |
| 4034 return result; | 4009 return result; |
| 4035 } | 4010 } |
| 4036 | 4011 |
| 4037 } // namespace blink | 4012 } // namespace blink |
| OLD | NEW |