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

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

Issue 1576283003: Have HTMLMediaElement::play() return a Promise. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 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 11 matching lines...) Expand all
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "core/html/HTMLMediaElement.h" 26 #include "core/html/HTMLMediaElement.h"
27 27
28 #include "bindings/core/v8/ExceptionState.h" 28 #include "bindings/core/v8/ExceptionState.h"
29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
30 #include "bindings/core/v8/ScriptController.h" 30 #include "bindings/core/v8/ScriptController.h"
31 #include "bindings/core/v8/ScriptEventListener.h" 31 #include "bindings/core/v8/ScriptEventListener.h"
32 #include "bindings/core/v8/ScriptPromiseResolver.h"
32 #include "core/HTMLNames.h" 33 #include "core/HTMLNames.h"
33 #include "core/css/MediaList.h" 34 #include "core/css/MediaList.h"
34 #include "core/dom/Attribute.h" 35 #include "core/dom/Attribute.h"
35 #include "core/dom/ElementTraversal.h" 36 #include "core/dom/ElementTraversal.h"
36 #include "core/dom/ExceptionCode.h"
37 #include "core/dom/Fullscreen.h" 37 #include "core/dom/Fullscreen.h"
38 #include "core/dom/shadow/ShadowRoot.h" 38 #include "core/dom/shadow/ShadowRoot.h"
39 #include "core/events/Event.h" 39 #include "core/events/Event.h"
40 #include "core/frame/LocalFrame.h" 40 #include "core/frame/LocalFrame.h"
41 #include "core/frame/Settings.h" 41 #include "core/frame/Settings.h"
42 #include "core/frame/UseCounter.h" 42 #include "core/frame/UseCounter.h"
43 #include "core/frame/csp/ContentSecurityPolicy.h" 43 #include "core/frame/csp/ContentSecurityPolicy.h"
44 #include "core/html/HTMLMediaSource.h" 44 #include "core/html/HTMLMediaSource.h"
45 #include "core/html/HTMLSourceElement.h" 45 #include "core/html/HTMLSourceElement.h"
46 #include "core/html/HTMLTrackElement.h" 46 #include "core/html/HTMLTrackElement.h"
(...skipping 16 matching lines...) Expand all
63 #include "core/layout/compositing/PaintLayerCompositor.h" 63 #include "core/layout/compositing/PaintLayerCompositor.h"
64 #include "core/loader/FrameLoader.h" 64 #include "core/loader/FrameLoader.h"
65 #include "core/loader/FrameLoaderClient.h" 65 #include "core/loader/FrameLoaderClient.h"
66 #include "core/page/ChromeClient.h" 66 #include "core/page/ChromeClient.h"
67 #include "core/page/NetworkStateNotifier.h" 67 #include "core/page/NetworkStateNotifier.h"
68 #include "platform/ContentType.h" 68 #include "platform/ContentType.h"
69 #include "platform/Logging.h" 69 #include "platform/Logging.h"
70 #include "platform/MIMETypeFromURL.h" 70 #include "platform/MIMETypeFromURL.h"
71 #include "platform/MIMETypeRegistry.h" 71 #include "platform/MIMETypeRegistry.h"
72 #include "platform/RuntimeEnabledFeatures.h" 72 #include "platform/RuntimeEnabledFeatures.h"
73 #include "platform/Task.h"
73 #include "platform/UserGestureIndicator.h" 74 #include "platform/UserGestureIndicator.h"
74 #include "platform/audio/AudioBus.h" 75 #include "platform/audio/AudioBus.h"
75 #include "platform/audio/AudioSourceProviderClient.h" 76 #include "platform/audio/AudioSourceProviderClient.h"
76 #include "platform/graphics/GraphicsLayer.h" 77 #include "platform/graphics/GraphicsLayer.h"
77 #include "platform/weborigin/SecurityOrigin.h" 78 #include "platform/weborigin/SecurityOrigin.h"
78 #include "public/platform/Platform.h" 79 #include "public/platform/Platform.h"
79 #include "public/platform/WebAudioSourceProvider.h" 80 #include "public/platform/WebAudioSourceProvider.h"
80 #include "public/platform/WebContentDecryptionModule.h" 81 #include "public/platform/WebContentDecryptionModule.h"
81 #include "public/platform/WebInbandTextTrack.h" 82 #include "public/platform/WebInbandTextTrack.h"
82 #include "wtf/CurrentTime.h" 83 #include "wtf/CurrentTime.h"
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 m_displayMode = Unknown; 720 m_displayMode = Unknown;
720 721
721 // 1 - Abort any already-running instance of the resource selection algorith m for this element. 722 // 1 - Abort any already-running instance of the resource selection algorith m for this element.
722 m_loadState = WaitingForSource; 723 m_loadState = WaitingForSource;
723 m_currentSourceNode = nullptr; 724 m_currentSourceNode = nullptr;
724 725
725 // 2 - If there are any tasks from the media element's media element event t ask source in 726 // 2 - If there are any tasks from the media element's media element event t ask source in
726 // one of the task queues, then remove those tasks. 727 // one of the task queues, then remove those tasks.
727 cancelPendingEventsAndCallbacks(); 728 cancelPendingEventsAndCallbacks();
728 729
730 rejectPlayPromises(AbortError, "The play() request was interrupted by a new load request.");
731
729 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW ORK_IDLE, queue 732 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW ORK_IDLE, queue
730 // a task to fire a simple event named abort at the media element. 733 // a task to fire a simple event named abort at the media element.
731 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) 734 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE)
732 scheduleEvent(EventTypeNames::abort); 735 scheduleEvent(EventTypeNames::abort);
733 736
734 resetMediaPlayerAndMediaSource(); 737 resetMediaPlayerAndMediaSource();
735 738
736 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps 739 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps
737 if (m_networkState != NETWORK_EMPTY) { 740 if (m_networkState != NETWORK_EMPTY) {
738 // 4.1 - Queue a task to fire a simple event named emptied at the media element. 741 // 4.1 - Queue a task to fire a simple event named emptied at the media element.
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 } 1236 }
1234 1237
1235 void HTMLMediaElement::noneSupported() 1238 void HTMLMediaElement::noneSupported()
1236 { 1239 {
1237 WTF_LOG(Media, "HTMLMediaElement::noneSupported(%p)", this); 1240 WTF_LOG(Media, "HTMLMediaElement::noneSupported(%p)", this);
1238 1241
1239 stopPeriodicTimers(); 1242 stopPeriodicTimers();
1240 m_loadState = WaitingForSource; 1243 m_loadState = WaitingForSource;
1241 m_currentSourceNode = nullptr; 1244 m_currentSourceNode = nullptr;
1242 1245
1243 // 4.8.10.5 1246 // 4.8.13.5
1244 // 6 - Reaching this step indicates that the media resource failed to load o r that the given 1247 // The dedicated media source failure steps are the following steps:
1245 // URL could not be resolved. In one atomic operation, run the following ste ps:
1246 1248
1247 // 6.1 - Set the error attribute to a new MediaError object whose code attri bute is set to 1249 // 1 - Set the error attribute to a new MediaError object whose code attribu te is set to
1248 // MEDIA_ERR_SRC_NOT_SUPPORTED. 1250 // MEDIA_ERR_SRC_NOT_SUPPORTED.
1249 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); 1251 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED);
1250 1252
1251 // 6.2 - Forget the media element's media-resource-specific text tracks. 1253 // 2 - Forget the media element's media-resource-specific text tracks.
1252 forgetResourceSpecificTracks(); 1254 forgetResourceSpecificTracks();
1253 1255
1254 // 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE v alue. 1256 // 3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE val ue.
1255 setNetworkState(NETWORK_NO_SOURCE); 1257 setNetworkState(NETWORK_NO_SOURCE);
1256 1258
1257 // 7 - Queue a task to fire a simple event named error at the media element. 1259 // 4 - Set the element's show poster flag to true.
1260 updateDisplayState();
1261
1262 // 5 - Fire a simple event named error at the media element.
1258 scheduleEvent(EventTypeNames::error); 1263 scheduleEvent(EventTypeNames::error);
1259 1264
1265 // 6 - Reject pending play promises with NotSupportedError.
1266 scheduleRejectPlayPromises(NotSupportedError, "Failed to load because no sup ported source was found.");
1267
1260 closeMediaSource(); 1268 closeMediaSource();
1261 1269
1262 // 8 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. 1270 // 7 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event.
1263 setShouldDelayLoadEvent(false); 1271 setShouldDelayLoadEvent(false);
1264 1272
1265 // 9 - Abort these steps. Until the load() method is invoked or the src attr ibute is changed,
1266 // the element won't attempt to load another resource.
1267
1268 updateDisplayState();
1269
1270 if (layoutObject()) 1273 if (layoutObject())
1271 layoutObject()->updateFromElement(); 1274 layoutObject()->updateFromElement();
1272 } 1275 }
1273 1276
1274 void HTMLMediaElement::mediaEngineError(MediaError* err) 1277 void HTMLMediaElement::mediaEngineError(MediaError* err)
1275 { 1278 {
1276 ASSERT(m_readyState >= HAVE_METADATA); 1279 ASSERT(m_readyState >= HAVE_METADATA);
1277 WTF_LOG(Media, "HTMLMediaElement::mediaEngineError(%p, %d)", this, static_ca st<int>(err->code())); 1280 WTF_LOG(Media, "HTMLMediaElement::mediaEngineError(%p, %d)", this, static_ca st<int>(err->code()));
1278 1281
1279 // 1 - The user agent should cancel the fetching process. 1282 // 1 - The user agent should cancel the fetching process.
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 m_haveFiredLoadedData = true; 1513 m_haveFiredLoadedData = true;
1511 shouldUpdateDisplayState = true; 1514 shouldUpdateDisplayState = true;
1512 scheduleEvent(EventTypeNames::loadeddata); 1515 scheduleEvent(EventTypeNames::loadeddata);
1513 setShouldDelayLoadEvent(false); 1516 setShouldDelayLoadEvent(false);
1514 } 1517 }
1515 1518
1516 bool isPotentiallyPlaying = potentiallyPlaying(); 1519 bool isPotentiallyPlaying = potentiallyPlaying();
1517 if (m_readyState == HAVE_FUTURE_DATA && oldState <= HAVE_CURRENT_DATA && tra cksAreReady) { 1520 if (m_readyState == HAVE_FUTURE_DATA && oldState <= HAVE_CURRENT_DATA && tra cksAreReady) {
1518 scheduleEvent(EventTypeNames::canplay); 1521 scheduleEvent(EventTypeNames::canplay);
1519 if (isPotentiallyPlaying) 1522 if (isPotentiallyPlaying)
1520 scheduleEvent(EventTypeNames::playing); 1523 scheduleNotifyPlaying();
1521 shouldUpdateDisplayState = true; 1524 shouldUpdateDisplayState = true;
1522 } 1525 }
1523 1526
1524 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { 1527 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) {
1525 if (oldState <= HAVE_CURRENT_DATA) { 1528 if (oldState <= HAVE_CURRENT_DATA) {
1526 scheduleEvent(EventTypeNames::canplay); 1529 scheduleEvent(EventTypeNames::canplay);
1527 if (isPotentiallyPlaying) 1530 if (isPotentiallyPlaying)
1528 scheduleEvent(EventTypeNames::playing); 1531 scheduleNotifyPlaying();
1529 } 1532 }
1530 1533
1531 // Check for autoplay, and record metrics about it if needed. 1534 // Check for autoplay, and record metrics about it if needed.
1532 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { 1535 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) {
1533 // If the autoplay experiment says that it's okay to play now, 1536 // If the autoplay experiment says that it's okay to play now,
1534 // then don't require a user gesture. 1537 // then don't require a user gesture.
1535 m_autoplayHelper.becameReadyToPlay(); 1538 m_autoplayHelper.becameReadyToPlay();
1536 1539
1537 if (!m_userGestureRequiredForPlay) { 1540 if (!m_userGestureRequiredForPlay) {
1538 m_paused = false; 1541 m_paused = false;
1539 invalidateCachedTime(); 1542 invalidateCachedTime();
1540 scheduleEvent(EventTypeNames::play); 1543 scheduleEvent(EventTypeNames::play);
1541 scheduleEvent(EventTypeNames::playing); 1544 scheduleNotifyPlaying();
1542 m_autoplaying = false; 1545 m_autoplaying = false;
1543 } 1546 }
1544 } 1547 }
1545 1548
1546 scheduleEvent(EventTypeNames::canplaythrough); 1549 scheduleEvent(EventTypeNames::canplaythrough);
1547 1550
1548 shouldUpdateDisplayState = true; 1551 shouldUpdateDisplayState = true;
1549 } 1552 }
1550 1553
1551 if (shouldUpdateDisplayState) { 1554 if (shouldUpdateDisplayState) {
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 // https://crbug.com/310450 1926 // https://crbug.com/310450
1924 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault); 1927 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault);
1925 return WebMediaPlayer::PreloadAuto; 1928 return WebMediaPlayer::PreloadAuto;
1926 } 1929 }
1927 1930
1928 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const 1931 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const
1929 { 1932 {
1930 return autoplay() ? WebMediaPlayer::PreloadAuto : preloadType(); 1933 return autoplay() ? WebMediaPlayer::PreloadAuto : preloadType();
1931 } 1934 }
1932 1935
1933 void HTMLMediaElement::play() 1936 ScriptPromise HTMLMediaElement::playForBindings(ScriptState* scriptState)
1937 {
1938 Nullable<ExceptionCode> code = play();
1939 if (!code.isNull()) {
1940 String message;
1941 switch (code.get()) {
1942 case NotAllowedError:
1943 message = "play() must be initiated by a user gesture.";
philipj_slow 2016/02/04 10:54:20 Perhaps "can only" to match the console message?
mlamouri (slow - plz ping) 2016/02/18 17:06:06 Done.
1944 break;
1945 case NotSupportedError:
1946 message = "The element has no supported sources.";
1947 break;
1948 default:
1949 ASSERT_NOT_REACHED();
1950 }
1951 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(code.get(), message));
1952 }
1953
1954 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
1955 ScriptPromise promise = resolver->promise();
1956
1957 m_playResolvers.append(resolver);
1958 playInternal();
philipj_slow 2016/02/04 10:54:20 play() already calls playInternal()
mlamouri (slow - plz ping) 2016/02/18 17:06:06 Not sure why that was here.
1959
1960 return promise;
1961 }
1962
1963 Nullable<ExceptionCode> HTMLMediaElement::play()
1934 { 1964 {
1935 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); 1965 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this);
1936 1966
1937 m_autoplayHelper.playMethodCalled(); 1967 m_autoplayHelper.playMethodCalled();
1938 1968
1939 if (!UserGestureIndicator::processingUserGesture()) { 1969 if (!UserGestureIndicator::processingUserGesture()) {
1940 autoplayMediaEncountered(); 1970 autoplayMediaEncountered();
1941 1971
1942 if (m_userGestureRequiredForPlay) { 1972 if (m_userGestureRequiredForPlay) {
1943 recordAutoplayMetric(PlayMethodFailed); 1973 recordAutoplayMetric(PlayMethodFailed);
1944 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); 1974 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture.");
1945 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); 1975 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message));
1946 return; 1976 return NotAllowedError;
1947 } 1977 }
1948 } else if (m_userGestureRequiredForPlay) { 1978 } else if (m_userGestureRequiredForPlay) {
1949 if (m_autoplayMediaCounted) 1979 if (m_autoplayMediaCounted)
1950 recordAutoplayMetric(AutoplayManualStart); 1980 recordAutoplayMetric(AutoplayManualStart);
1951 m_userGestureRequiredForPlay = false; 1981 m_userGestureRequiredForPlay = false;
1952 } 1982 }
1953 1983
1984 if (m_error && m_error->code() == MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED)
1985 return NotSupportedError;
1986
1954 playInternal(); 1987 playInternal();
1988
1989 return nullptr;
1955 } 1990 }
1956 1991
1957 void HTMLMediaElement::playInternal() 1992 void HTMLMediaElement::playInternal()
1958 { 1993 {
1959 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); 1994 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this);
1960 1995
1961 // Always return the buffering strategy to normal when not paused, 1996 // Always return the buffering strategy to normal when not paused,
1962 // regardless of the cause. (In contrast with aggressive buffering which is 1997 // regardless of the cause. (In contrast with aggressive buffering which is
1963 // only enabled by pause(), not pauseInternal().) 1998 // only enabled by pause(), not pauseInternal().)
1964 if (webMediaPlayer()) 1999 if (webMediaPlayer())
(...skipping 10 matching lines...) Expand all
1975 seek(0); 2010 seek(0);
1976 2011
1977 if (m_paused) { 2012 if (m_paused) {
1978 m_paused = false; 2013 m_paused = false;
1979 invalidateCachedTime(); 2014 invalidateCachedTime();
1980 scheduleEvent(EventTypeNames::play); 2015 scheduleEvent(EventTypeNames::play);
1981 2016
1982 if (m_readyState <= HAVE_CURRENT_DATA) 2017 if (m_readyState <= HAVE_CURRENT_DATA)
1983 scheduleEvent(EventTypeNames::waiting); 2018 scheduleEvent(EventTypeNames::waiting);
1984 else if (m_readyState >= HAVE_FUTURE_DATA) 2019 else if (m_readyState >= HAVE_FUTURE_DATA)
1985 scheduleEvent(EventTypeNames::playing); 2020 scheduleNotifyPlaying();
2021 } else if (m_readyState >= HAVE_FUTURE_DATA) {
2022 scheduleResolvePlayPromises();
1986 } 2023 }
2024
1987 m_autoplaying = false; 2025 m_autoplaying = false;
1988 2026
1989 updatePlayState(); 2027 updatePlayState();
1990 } 2028 }
1991 2029
1992 void HTMLMediaElement::autoplayMediaEncountered() 2030 void HTMLMediaElement::autoplayMediaEncountered()
1993 { 2031 {
1994 if (!m_autoplayMediaCounted) { 2032 if (!m_autoplayMediaCounted) {
1995 m_autoplayMediaCounted = true; 2033 m_autoplayMediaCounted = true;
1996 recordAutoplayMetric(AutoplayMediaFound); 2034 recordAutoplayMetric(AutoplayMediaFound);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 m_autoplayHelper.pauseMethodCalled(); 2069 m_autoplayHelper.pauseMethodCalled();
2032 2070
2033 m_autoplaying = false; 2071 m_autoplaying = false;
2034 2072
2035 if (!m_paused) { 2073 if (!m_paused) {
2036 recordMetricsIfPausing(); 2074 recordMetricsIfPausing();
2037 2075
2038 m_paused = true; 2076 m_paused = true;
2039 scheduleTimeupdateEvent(false); 2077 scheduleTimeupdateEvent(false);
2040 scheduleEvent(EventTypeNames::pause); 2078 scheduleEvent(EventTypeNames::pause);
2079 scheduleRejectPlayPromises(AbortError, "The play() request was interrupt ed by a call to pause().");
2041 } 2080 }
2042 2081
2043 updatePlayState(); 2082 updatePlayState();
2044 } 2083 }
2045 2084
2046 void HTMLMediaElement::requestRemotePlayback() 2085 void HTMLMediaElement::requestRemotePlayback()
2047 { 2086 {
2048 ASSERT(m_remoteRoutesAvailable); 2087 ASSERT(m_remoteRoutesAvailable);
2049 webMediaPlayer()->requestRemotePlayback(); 2088 webMediaPlayer()->requestRemotePlayback();
2050 } 2089 }
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
3480 visitor->trace(m_asyncEventQueue); 3519 visitor->trace(m_asyncEventQueue);
3481 visitor->trace(m_error); 3520 visitor->trace(m_error);
3482 visitor->trace(m_currentSourceNode); 3521 visitor->trace(m_currentSourceNode);
3483 visitor->trace(m_nextChildNodeToConsider); 3522 visitor->trace(m_nextChildNodeToConsider);
3484 visitor->trace(m_mediaSource); 3523 visitor->trace(m_mediaSource);
3485 visitor->trace(m_audioTracks); 3524 visitor->trace(m_audioTracks);
3486 visitor->trace(m_videoTracks); 3525 visitor->trace(m_videoTracks);
3487 visitor->trace(m_cueTimeline); 3526 visitor->trace(m_cueTimeline);
3488 visitor->trace(m_textTracks); 3527 visitor->trace(m_textTracks);
3489 visitor->trace(m_textTracksWhenResourceSelectionBegan); 3528 visitor->trace(m_textTracksWhenResourceSelectionBegan);
3529 visitor->trace(m_playResolvers);
3490 visitor->trace(m_audioSourceProvider); 3530 visitor->trace(m_audioSourceProvider);
3491 visitor->template registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::c learWeakMembers>(this); 3531 visitor->template registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::c learWeakMembers>(this);
3492 visitor->trace(m_autoplayHelper); 3532 visitor->trace(m_autoplayHelper);
3493 HeapSupplementable<HTMLMediaElement>::trace(visitor); 3533 HeapSupplementable<HTMLMediaElement>::trace(visitor);
3494 #endif 3534 #endif
3495 HTMLElement::trace(visitor); 3535 HTMLElement::trace(visitor);
3496 ActiveDOMObject::trace(visitor); 3536 ActiveDOMObject::trace(visitor);
3497 } 3537 }
3498 3538
3499 void HTMLMediaElement::createPlaceholderTracksIfNecessary() 3539 void HTMLMediaElement::createPlaceholderTracksIfNecessary()
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3557 { 3597 {
3558 m_autoplayHelper.updatePositionNotificationRegistration(); 3598 m_autoplayHelper.updatePositionNotificationRegistration();
3559 } 3599 }
3560 3600
3561 // TODO(liberato): remove once autoplay gesture override experiment concludes. 3601 // TODO(liberato): remove once autoplay gesture override experiment concludes.
3562 void HTMLMediaElement::triggerAutoplayViewportCheckForTesting() 3602 void HTMLMediaElement::triggerAutoplayViewportCheckForTesting()
3563 { 3603 {
3564 m_autoplayHelper.triggerAutoplayViewportCheckForTesting(); 3604 m_autoplayHelper.triggerAutoplayViewportCheckForTesting();
3565 } 3605 }
3566 3606
3607 void HTMLMediaElement::scheduleResolvePlayPromises()
3608 {
3609 Platform::current()->currentThread()->taskRunner()->postTask(
3610 BLINK_FROM_HERE, new Task(WTF::bind(&HTMLMediaElement::resolvePlayPromis es, this)));
3611 }
3612
3613 void HTMLMediaElement::scheduleRejectPlayPromises(ExceptionCode code, const Stri ng& message)
3614 {
3615 Platform::current()->currentThread()->taskRunner()->postTask(
3616 BLINK_FROM_HERE, new Task(WTF::bind(&HTMLMediaElement::rejectPlayPromise s, this, code, message)));
3617 }
3618
3619 void HTMLMediaElement::scheduleNotifyPlaying()
3620 {
3621 scheduleEvent(EventTypeNames::playing);
3622 scheduleResolvePlayPromises();
3623 }
3624
3625 void HTMLMediaElement::resolvePlayPromises()
3626 {
3627 for (auto& resolver: m_playResolvers)
3628 resolver->resolve();
3629
3630 m_playResolvers.clear();
3631 }
3632
3633 void HTMLMediaElement::rejectPlayPromises(ExceptionCode code, const String& mess age)
3634 {
3635 ASSERT(code == AbortError || code == NotSupportedError);
3636
3637 for (auto& resolver: m_playResolvers)
3638 resolver->reject(DOMException::create(code, message));
3639
3640 m_playResolvers.clear();
3641 }
3642
3567 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3643 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3568 { 3644 {
3569 if (!Heap::isHeapObjectAlive(m_audioSourceNode)) 3645 if (!Heap::isHeapObjectAlive(m_audioSourceNode))
3570 audioSourceProvider().setClient(nullptr); 3646 audioSourceProvider().setClient(nullptr);
3571 } 3647 }
3572 3648
3573 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider) 3649 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider)
3574 { 3650 {
3575 MutexLocker locker(provideInputLock); 3651 MutexLocker locker(provideInputLock);
3576 3652
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3624 { 3700 {
3625 visitor->trace(m_client); 3701 visitor->trace(m_client);
3626 } 3702 }
3627 3703
3628 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) 3704 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl)
3629 { 3705 {
3630 visitor->trace(m_client); 3706 visitor->trace(m_client);
3631 } 3707 }
3632 3708
3633 } // namespace blink 3709 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698