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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 case WebMediaPlayer::PreloadMetaData: | 274 case WebMediaPlayer::PreloadMetaData: |
| 275 return "metadata"; | 275 return "metadata"; |
| 276 case WebMediaPlayer::PreloadAuto: | 276 case WebMediaPlayer::PreloadAuto: |
| 277 return "auto"; | 277 return "auto"; |
| 278 } | 278 } |
| 279 | 279 |
| 280 NOTREACHED(); | 280 NOTREACHED(); |
| 281 return String(); | 281 return String(); |
| 282 } | 282 } |
| 283 | 283 |
| 284 // These values are used for histograms. Do not reorder. | |
| 285 enum AutoplaySource { | |
| 286 // Autoplay comes from HTMLMediaElement `autoplay` attribute. | |
| 287 AutoplaySourceAttribute = 0, | |
| 288 // Autoplay comes from `play()` method. | |
| 289 AutoplaySourceMethod = 1, | |
| 290 // This enum value must be last. | |
| 291 NumberOfAutoplaySources = 2, | |
| 292 }; | |
| 293 | |
| 284 } // anonymous namespace | 294 } // anonymous namespace |
| 285 | 295 |
| 286 class HTMLMediaElement::AutoplayHelperClientImpl : | 296 class HTMLMediaElement::AutoplayHelperClientImpl : |
| 287 public AutoplayExperimentHelper::Client { | 297 public AutoplayExperimentHelper::Client { |
| 288 | 298 |
| 289 public: | 299 public: |
| 290 static AutoplayHelperClientImpl* create(HTMLMediaElement* element) | 300 static AutoplayHelperClientImpl* create(HTMLMediaElement* element) |
| 291 { | 301 { |
| 292 return new AutoplayHelperClientImpl(element); | 302 return new AutoplayHelperClientImpl(element); |
| 293 } | 303 } |
| (...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1611 | 1621 |
| 1612 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { | 1622 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { |
| 1613 if (oldState <= HAVE_CURRENT_DATA) { | 1623 if (oldState <= HAVE_CURRENT_DATA) { |
| 1614 scheduleEvent(EventTypeNames::canplay); | 1624 scheduleEvent(EventTypeNames::canplay); |
| 1615 if (isPotentiallyPlaying) | 1625 if (isPotentiallyPlaying) |
| 1616 scheduleNotifyPlaying(); | 1626 scheduleNotifyPlaying(); |
| 1617 } | 1627 } |
| 1618 | 1628 |
| 1619 // Check for autoplay, and record metrics about it if needed. | 1629 // Check for autoplay, and record metrics about it if needed. |
| 1620 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { | 1630 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { |
| 1631 recordAutoplaySourceMetric(AutoplaySourceAttribute); | |
| 1621 // If the autoplay experiment says that it's okay to play now, | 1632 // If the autoplay experiment says that it's okay to play now, |
| 1622 // then don't require a user gesture. | 1633 // then don't require a user gesture. |
| 1623 m_autoplayHelper->becameReadyToPlay(); | 1634 m_autoplayHelper->becameReadyToPlay(); |
| 1624 | 1635 |
| 1625 if (!isGestureNeededForPlayback()) { | 1636 if (!isGestureNeededForPlayback()) { |
| 1626 m_paused = false; | 1637 m_paused = false; |
| 1627 invalidateCachedTime(); | 1638 invalidateCachedTime(); |
| 1628 scheduleEvent(EventTypeNames::play); | 1639 scheduleEvent(EventTypeNames::play); |
| 1629 scheduleNotifyPlaying(); | 1640 scheduleNotifyPlaying(); |
| 1630 m_autoplaying = false; | 1641 m_autoplaying = false; |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2041 ScriptPromise promise = resolver->promise(); | 2052 ScriptPromise promise = resolver->promise(); |
| 2042 | 2053 |
| 2043 m_playResolvers.append(resolver); | 2054 m_playResolvers.append(resolver); |
| 2044 return promise; | 2055 return promise; |
| 2045 } | 2056 } |
| 2046 | 2057 |
| 2047 Nullable<ExceptionCode> HTMLMediaElement::play() | 2058 Nullable<ExceptionCode> HTMLMediaElement::play() |
| 2048 { | 2059 { |
| 2049 DVLOG(MEDIA_LOG_LEVEL) << "play(" << (void*)this << ")"; | 2060 DVLOG(MEDIA_LOG_LEVEL) << "play(" << (void*)this << ")"; |
| 2050 | 2061 |
| 2062 recordAutoplaySourceMetric(AutoplaySourceMethod); | |
|
mlamouri (slow - plz ping)
2016/06/08 12:30:03
What we call "autoplay" is when there is no user g
Zhiqiang Zhang (Slow)
2016/06/08 12:55:14
Done.
| |
| 2051 m_autoplayHelper->playMethodCalled(); | 2063 m_autoplayHelper->playMethodCalled(); |
| 2052 | 2064 |
| 2053 if (!UserGestureIndicator::processingUserGesture()) { | 2065 if (!UserGestureIndicator::processingUserGesture()) { |
| 2054 if (isGestureNeededForPlayback()) { | 2066 if (isGestureNeededForPlayback()) { |
| 2055 // If playback is deferred, then don't start playback but don't | 2067 // If playback is deferred, then don't start playback but don't |
| 2056 // fail yet either. | 2068 // fail yet either. |
| 2057 if (m_autoplayHelper->isPlaybackDeferred()) | 2069 if (m_autoplayHelper->isPlaybackDeferred()) |
| 2058 return nullptr; | 2070 return nullptr; |
| 2059 | 2071 |
| 2060 // If we're already playing, then this play would do nothing anyway. | 2072 // If we're already playing, then this play would do nothing anyway. |
| (...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3764 { | 3776 { |
| 3765 if (isHTMLVideoElement()) { | 3777 if (isHTMLVideoElement()) { |
| 3766 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, ("Media.Controls.Sh ow.Video", MediaControlsShowMax)); | 3778 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, ("Media.Controls.Sh ow.Video", MediaControlsShowMax)); |
| 3767 return histogram; | 3779 return histogram; |
| 3768 } | 3780 } |
| 3769 | 3781 |
| 3770 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, ("Media.Controls.Show.A udio", MediaControlsShowMax)); | 3782 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, ("Media.Controls.Show.A udio", MediaControlsShowMax)); |
| 3771 return histogram; | 3783 return histogram; |
| 3772 } | 3784 } |
| 3773 | 3785 |
| 3786 void HTMLMediaElement::recordAutoplaySourceMetric(int source) | |
| 3787 { | |
| 3788 DEFINE_STATIC_LOCAL(EnumerationHistogram, videoHistogram, ("Blink.MediaEleme nt.Autoplay.Source.Video", NumberOfAutoplaySources)); | |
| 3789 DEFINE_STATIC_LOCAL(EnumerationHistogram, mutedVideoHistogram, ("Blink.Media Element.Autoplay.Source.Video.Muted", NumberOfAutoplaySources)); | |
| 3790 DEFINE_STATIC_LOCAL(EnumerationHistogram, audioHistogram, ("Blink.MediaEleme nt.Autoplay.Source.Audio", NumberOfAutoplaySources)); | |
| 3791 | |
| 3792 if (isHTMLVideoElement()) { | |
| 3793 videoHistogram.count(source); | |
| 3794 if (muted()) | |
| 3795 mutedVideoHistogram.count(source); | |
| 3796 } else { | |
| 3797 audioHistogram.count(source); | |
| 3798 } | |
| 3799 } | |
| 3800 | |
| 3774 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3801 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3775 { | 3802 { |
| 3776 if (!ThreadHeap::isHeapObjectAlive(m_audioSourceNode)) { | 3803 if (!ThreadHeap::isHeapObjectAlive(m_audioSourceNode)) { |
| 3777 getAudioSourceProvider().setClient(nullptr); | 3804 getAudioSourceProvider().setClient(nullptr); |
| 3778 m_audioSourceNode = nullptr; | 3805 m_audioSourceNode = nullptr; |
| 3779 } | 3806 } |
| 3780 } | 3807 } |
| 3781 | 3808 |
| 3782 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider) | 3809 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider) |
| 3783 { | 3810 { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3881 | 3908 |
| 3882 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst | 3909 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst |
| 3883 { | 3910 { |
| 3884 IntRect result; | 3911 IntRect result; |
| 3885 if (LayoutObject* object = m_element->layoutObject()) | 3912 if (LayoutObject* object = m_element->layoutObject()) |
| 3886 result = object->absoluteBoundingBoxRect(); | 3913 result = object->absoluteBoundingBoxRect(); |
| 3887 return result; | 3914 return result; |
| 3888 } | 3915 } |
| 3889 | 3916 |
| 3890 } // namespace blink | 3917 } // namespace blink |
| OLD | NEW |