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 11 matching lines...) Expand all Loading... | |
| 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 18 matching lines...) Expand all Loading... | |
| 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/Histogram.h" | 69 #include "platform/Histogram.h" |
| 70 #include "platform/LayoutTestSupport.h" | 70 #include "platform/LayoutTestSupport.h" |
| 71 #include "platform/Logging.h" | 71 #include "platform/Logging.h" |
| 72 #include "platform/MIMETypeFromURL.h" | 72 #include "platform/MIMETypeFromURL.h" |
| 73 #include "platform/MIMETypeRegistry.h" | 73 #include "platform/MIMETypeRegistry.h" |
| 74 #include "platform/RuntimeEnabledFeatures.h" | 74 #include "platform/RuntimeEnabledFeatures.h" |
| 75 #include "platform/Task.h" | |
| 76 #include "platform/ThreadSafeFunctional.h" | |
| 75 #include "platform/UserGestureIndicator.h" | 77 #include "platform/UserGestureIndicator.h" |
| 76 #include "platform/audio/AudioBus.h" | 78 #include "platform/audio/AudioBus.h" |
| 77 #include "platform/audio/AudioSourceProviderClient.h" | 79 #include "platform/audio/AudioSourceProviderClient.h" |
| 78 #include "platform/graphics/GraphicsLayer.h" | 80 #include "platform/graphics/GraphicsLayer.h" |
| 79 #include "platform/weborigin/SecurityOrigin.h" | 81 #include "platform/weborigin/SecurityOrigin.h" |
| 80 #include "public/platform/Platform.h" | 82 #include "public/platform/Platform.h" |
| 81 #include "public/platform/WebAudioSourceProvider.h" | 83 #include "public/platform/WebAudioSourceProvider.h" |
| 82 #include "public/platform/WebContentDecryptionModule.h" | 84 #include "public/platform/WebContentDecryptionModule.h" |
| 83 #include "public/platform/WebInbandTextTrack.h" | 85 #include "public/platform/WebInbandTextTrack.h" |
| 84 #include "wtf/CurrentTime.h" | 86 #include "wtf/CurrentTime.h" |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 723 m_displayMode = Unknown; | 725 m_displayMode = Unknown; |
| 724 | 726 |
| 725 // 1 - Abort any already-running instance of the resource selection algorith m for this element. | 727 // 1 - Abort any already-running instance of the resource selection algorith m for this element. |
| 726 m_loadState = WaitingForSource; | 728 m_loadState = WaitingForSource; |
| 727 m_currentSourceNode = nullptr; | 729 m_currentSourceNode = nullptr; |
| 728 | 730 |
| 729 // 2 - If there are any tasks from the media element's media element event t ask source in | 731 // 2 - If there are any tasks from the media element's media element event t ask source in |
| 730 // one of the task queues, then remove those tasks. | 732 // one of the task queues, then remove those tasks. |
| 731 cancelPendingEventsAndCallbacks(); | 733 cancelPendingEventsAndCallbacks(); |
| 732 | 734 |
| 735 rejectPlayPromises(AbortError, "The play() request was interrupted by a new load request."); | |
| 736 | |
| 733 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW ORK_IDLE, queue | 737 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW ORK_IDLE, queue |
| 734 // a task to fire a simple event named abort at the media element. | 738 // a task to fire a simple event named abort at the media element. |
| 735 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) | 739 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) |
| 736 scheduleEvent(EventTypeNames::abort); | 740 scheduleEvent(EventTypeNames::abort); |
| 737 | 741 |
| 738 resetMediaPlayerAndMediaSource(); | 742 resetMediaPlayerAndMediaSource(); |
| 739 | 743 |
| 740 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps | 744 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps |
| 741 if (m_networkState != NETWORK_EMPTY) { | 745 if (m_networkState != NETWORK_EMPTY) { |
| 742 // 4.1 - Queue a task to fire a simple event named emptied at the media element. | 746 // 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 Loading... | |
| 1237 } | 1241 } |
| 1238 | 1242 |
| 1239 void HTMLMediaElement::noneSupported() | 1243 void HTMLMediaElement::noneSupported() |
| 1240 { | 1244 { |
| 1241 WTF_LOG(Media, "HTMLMediaElement::noneSupported(%p)", this); | 1245 WTF_LOG(Media, "HTMLMediaElement::noneSupported(%p)", this); |
| 1242 | 1246 |
| 1243 stopPeriodicTimers(); | 1247 stopPeriodicTimers(); |
| 1244 m_loadState = WaitingForSource; | 1248 m_loadState = WaitingForSource; |
| 1245 m_currentSourceNode = nullptr; | 1249 m_currentSourceNode = nullptr; |
| 1246 | 1250 |
| 1247 // 4.8.10.5 | 1251 // 4.8.13.5 |
| 1248 // 6 - Reaching this step indicates that the media resource failed to load o r that the given | 1252 // The dedicated media source failure steps are the following steps: |
| 1249 // URL could not be resolved. In one atomic operation, run the following ste ps: | |
| 1250 | 1253 |
| 1251 // 6.1 - Set the error attribute to a new MediaError object whose code attri bute is set to | 1254 // 1 - Set the error attribute to a new MediaError object whose code attribu te is set to |
| 1252 // MEDIA_ERR_SRC_NOT_SUPPORTED. | 1255 // MEDIA_ERR_SRC_NOT_SUPPORTED. |
| 1253 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); | 1256 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); |
| 1254 | 1257 |
| 1255 // 6.2 - Forget the media element's media-resource-specific text tracks. | 1258 // 2 - Forget the media element's media-resource-specific text tracks. |
| 1256 forgetResourceSpecificTracks(); | 1259 forgetResourceSpecificTracks(); |
| 1257 | 1260 |
| 1258 // 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE v alue. | 1261 // 3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE val ue. |
| 1259 setNetworkState(NETWORK_NO_SOURCE); | 1262 setNetworkState(NETWORK_NO_SOURCE); |
| 1260 | 1263 |
| 1261 // 7 - Queue a task to fire a simple event named error at the media element. | 1264 // 4 - Set the element's show poster flag to true. |
| 1265 updateDisplayState(); | |
| 1266 | |
| 1267 // 5 - Fire a simple event named error at the media element. | |
| 1262 scheduleEvent(EventTypeNames::error); | 1268 scheduleEvent(EventTypeNames::error); |
| 1263 | 1269 |
| 1270 // 6 - Reject pending play promises with NotSupportedError. | |
| 1271 scheduleRejectPlayPromises(NotSupportedError, "Failed to load because no sup ported source was found."); | |
| 1272 | |
| 1264 closeMediaSource(); | 1273 closeMediaSource(); |
| 1265 | 1274 |
| 1266 // 8 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. | 1275 // 7 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. |
| 1267 setShouldDelayLoadEvent(false); | 1276 setShouldDelayLoadEvent(false); |
| 1268 | 1277 |
| 1269 // 9 - Abort these steps. Until the load() method is invoked or the src attr ibute is changed, | |
| 1270 // the element won't attempt to load another resource. | |
| 1271 | |
| 1272 updateDisplayState(); | |
| 1273 | |
| 1274 if (layoutObject()) | 1278 if (layoutObject()) |
| 1275 layoutObject()->updateFromElement(); | 1279 layoutObject()->updateFromElement(); |
| 1276 } | 1280 } |
| 1277 | 1281 |
| 1278 void HTMLMediaElement::mediaEngineError(MediaError* err) | 1282 void HTMLMediaElement::mediaEngineError(MediaError* err) |
| 1279 { | 1283 { |
| 1280 ASSERT(m_readyState >= HAVE_METADATA); | 1284 ASSERT(m_readyState >= HAVE_METADATA); |
| 1281 WTF_LOG(Media, "HTMLMediaElement::mediaEngineError(%p, %d)", this, static_ca st<int>(err->code())); | 1285 WTF_LOG(Media, "HTMLMediaElement::mediaEngineError(%p, %d)", this, static_ca st<int>(err->code())); |
| 1282 | 1286 |
| 1283 // 1 - The user agent should cancel the fetching process. | 1287 // 1 - The user agent should cancel the fetching process. |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1512 m_haveFiredLoadedData = true; | 1516 m_haveFiredLoadedData = true; |
| 1513 shouldUpdateDisplayState = true; | 1517 shouldUpdateDisplayState = true; |
| 1514 scheduleEvent(EventTypeNames::loadeddata); | 1518 scheduleEvent(EventTypeNames::loadeddata); |
| 1515 setShouldDelayLoadEvent(false); | 1519 setShouldDelayLoadEvent(false); |
| 1516 } | 1520 } |
| 1517 | 1521 |
| 1518 bool isPotentiallyPlaying = potentiallyPlaying(); | 1522 bool isPotentiallyPlaying = potentiallyPlaying(); |
| 1519 if (m_readyState == HAVE_FUTURE_DATA && oldState <= HAVE_CURRENT_DATA && tra cksAreReady) { | 1523 if (m_readyState == HAVE_FUTURE_DATA && oldState <= HAVE_CURRENT_DATA && tra cksAreReady) { |
| 1520 scheduleEvent(EventTypeNames::canplay); | 1524 scheduleEvent(EventTypeNames::canplay); |
| 1521 if (isPotentiallyPlaying) | 1525 if (isPotentiallyPlaying) |
| 1522 scheduleEvent(EventTypeNames::playing); | 1526 scheduleNotifyPlaying(); |
| 1523 shouldUpdateDisplayState = true; | 1527 shouldUpdateDisplayState = true; |
| 1524 } | 1528 } |
| 1525 | 1529 |
| 1526 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { | 1530 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { |
| 1527 if (oldState <= HAVE_CURRENT_DATA) { | 1531 if (oldState <= HAVE_CURRENT_DATA) { |
| 1528 scheduleEvent(EventTypeNames::canplay); | 1532 scheduleEvent(EventTypeNames::canplay); |
| 1529 if (isPotentiallyPlaying) | 1533 if (isPotentiallyPlaying) |
| 1530 scheduleEvent(EventTypeNames::playing); | 1534 scheduleNotifyPlaying(); |
| 1531 } | 1535 } |
| 1532 | 1536 |
| 1533 // Check for autoplay, and record metrics about it if needed. | 1537 // Check for autoplay, and record metrics about it if needed. |
| 1534 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { | 1538 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { |
| 1535 // If the autoplay experiment says that it's okay to play now, | 1539 // If the autoplay experiment says that it's okay to play now, |
| 1536 // then don't require a user gesture. | 1540 // then don't require a user gesture. |
| 1537 m_autoplayHelper.becameReadyToPlay(); | 1541 m_autoplayHelper.becameReadyToPlay(); |
| 1538 | 1542 |
| 1539 if (!m_userGestureRequiredForPlay) { | 1543 if (!m_userGestureRequiredForPlay) { |
| 1540 m_paused = false; | 1544 m_paused = false; |
| 1541 invalidateCachedTime(); | 1545 invalidateCachedTime(); |
| 1542 scheduleEvent(EventTypeNames::play); | 1546 scheduleEvent(EventTypeNames::play); |
| 1543 scheduleEvent(EventTypeNames::playing); | 1547 scheduleNotifyPlaying(); |
| 1544 m_autoplaying = false; | 1548 m_autoplaying = false; |
| 1545 } | 1549 } |
| 1546 } | 1550 } |
| 1547 | 1551 |
| 1548 scheduleEvent(EventTypeNames::canplaythrough); | 1552 scheduleEvent(EventTypeNames::canplaythrough); |
| 1549 | 1553 |
| 1550 shouldUpdateDisplayState = true; | 1554 shouldUpdateDisplayState = true; |
| 1551 } | 1555 } |
| 1552 | 1556 |
| 1553 if (shouldUpdateDisplayState) { | 1557 if (shouldUpdateDisplayState) { |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1925 // https://crbug.com/310450 | 1929 // https://crbug.com/310450 |
| 1926 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault); | 1930 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault); |
| 1927 return WebMediaPlayer::PreloadAuto; | 1931 return WebMediaPlayer::PreloadAuto; |
| 1928 } | 1932 } |
| 1929 | 1933 |
| 1930 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const | 1934 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const |
| 1931 { | 1935 { |
| 1932 return autoplay() ? WebMediaPlayer::PreloadAuto : preloadType(); | 1936 return autoplay() ? WebMediaPlayer::PreloadAuto : preloadType(); |
| 1933 } | 1937 } |
| 1934 | 1938 |
| 1935 void HTMLMediaElement::play() | 1939 ScriptPromise HTMLMediaElement::playForBindings(ScriptState* scriptState) |
| 1940 { | |
| 1941 Nullable<ExceptionCode> code = play(); | |
| 1942 if (!code.isNull()) { | |
| 1943 String message; | |
| 1944 switch (code.get()) { | |
| 1945 case NotAllowedError: | |
| 1946 message = "play() can only be initiated by a user gesture."; | |
| 1947 break; | |
| 1948 case NotSupportedError: | |
| 1949 message = "The element has no supported sources."; | |
| 1950 break; | |
| 1951 default: | |
| 1952 ASSERT_NOT_REACHED(); | |
| 1953 } | |
| 1954 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(code.get(), message)); | |
| 1955 } | |
| 1956 | |
| 1957 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; | |
| 1958 ScriptPromise promise = resolver->promise(); | |
| 1959 | |
| 1960 m_playResolvers.append(resolver); | |
| 1961 return promise; | |
| 1962 } | |
| 1963 | |
| 1964 Nullable<ExceptionCode> HTMLMediaElement::play() | |
| 1936 { | 1965 { |
| 1937 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); | 1966 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); |
| 1938 | 1967 |
| 1939 m_autoplayHelper.playMethodCalled(); | 1968 m_autoplayHelper.playMethodCalled(); |
| 1940 | 1969 |
| 1941 if (!UserGestureIndicator::processingUserGesture()) { | 1970 if (!UserGestureIndicator::processingUserGesture()) { |
| 1942 autoplayMediaEncountered(); | 1971 autoplayMediaEncountered(); |
| 1943 | 1972 |
| 1944 if (m_userGestureRequiredForPlay) { | 1973 if (m_userGestureRequiredForPlay) { |
| 1945 recordAutoplayMetric(PlayMethodFailed); | 1974 recordAutoplayMetric(PlayMethodFailed); |
| 1946 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); | 1975 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); |
| 1947 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); | 1976 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); |
| 1948 return; | 1977 return NotAllowedError; |
| 1949 } | 1978 } |
| 1950 } else if (m_userGestureRequiredForPlay) { | 1979 } else if (m_userGestureRequiredForPlay) { |
| 1951 if (m_autoplayMediaCounted) | 1980 if (m_autoplayMediaCounted) |
| 1952 recordAutoplayMetric(AutoplayManualStart); | 1981 recordAutoplayMetric(AutoplayManualStart); |
| 1953 m_userGestureRequiredForPlay = false; | 1982 m_userGestureRequiredForPlay = false; |
| 1954 } | 1983 } |
| 1955 | 1984 |
| 1985 if (m_error && m_error->code() == MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED) | |
| 1986 return NotSupportedError; | |
| 1987 | |
| 1956 playInternal(); | 1988 playInternal(); |
| 1989 | |
| 1990 return nullptr; | |
| 1957 } | 1991 } |
| 1958 | 1992 |
| 1959 void HTMLMediaElement::playInternal() | 1993 void HTMLMediaElement::playInternal() |
| 1960 { | 1994 { |
| 1961 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); | 1995 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); |
| 1962 | 1996 |
| 1963 // Always return the buffering strategy to normal when not paused, | 1997 // Always return the buffering strategy to normal when not paused, |
| 1964 // regardless of the cause. (In contrast with aggressive buffering which is | 1998 // regardless of the cause. (In contrast with aggressive buffering which is |
| 1965 // only enabled by pause(), not pauseInternal().) | 1999 // only enabled by pause(), not pauseInternal().) |
| 1966 if (webMediaPlayer()) | 2000 if (webMediaPlayer()) |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1977 seek(0); | 2011 seek(0); |
| 1978 | 2012 |
| 1979 if (m_paused) { | 2013 if (m_paused) { |
| 1980 m_paused = false; | 2014 m_paused = false; |
| 1981 invalidateCachedTime(); | 2015 invalidateCachedTime(); |
| 1982 scheduleEvent(EventTypeNames::play); | 2016 scheduleEvent(EventTypeNames::play); |
| 1983 | 2017 |
| 1984 if (m_readyState <= HAVE_CURRENT_DATA) | 2018 if (m_readyState <= HAVE_CURRENT_DATA) |
| 1985 scheduleEvent(EventTypeNames::waiting); | 2019 scheduleEvent(EventTypeNames::waiting); |
| 1986 else if (m_readyState >= HAVE_FUTURE_DATA) | 2020 else if (m_readyState >= HAVE_FUTURE_DATA) |
| 1987 scheduleEvent(EventTypeNames::playing); | 2021 scheduleNotifyPlaying(); |
| 2022 } else if (m_readyState >= HAVE_FUTURE_DATA) { | |
| 2023 scheduleResolvePlayPromises(); | |
| 1988 } | 2024 } |
| 2025 | |
| 1989 m_autoplaying = false; | 2026 m_autoplaying = false; |
| 1990 | 2027 |
| 1991 updatePlayState(); | 2028 updatePlayState(); |
| 1992 } | 2029 } |
| 1993 | 2030 |
| 1994 void HTMLMediaElement::autoplayMediaEncountered() | 2031 void HTMLMediaElement::autoplayMediaEncountered() |
| 1995 { | 2032 { |
| 1996 if (!m_autoplayMediaCounted) { | 2033 if (!m_autoplayMediaCounted) { |
| 1997 m_autoplayMediaCounted = true; | 2034 m_autoplayMediaCounted = true; |
| 1998 recordAutoplayMetric(AutoplayMediaFound); | 2035 recordAutoplayMetric(AutoplayMediaFound); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2033 m_autoplayHelper.pauseMethodCalled(); | 2070 m_autoplayHelper.pauseMethodCalled(); |
| 2034 | 2071 |
| 2035 m_autoplaying = false; | 2072 m_autoplaying = false; |
| 2036 | 2073 |
| 2037 if (!m_paused) { | 2074 if (!m_paused) { |
| 2038 recordMetricsIfPausing(); | 2075 recordMetricsIfPausing(); |
| 2039 | 2076 |
| 2040 m_paused = true; | 2077 m_paused = true; |
| 2041 scheduleTimeupdateEvent(false); | 2078 scheduleTimeupdateEvent(false); |
| 2042 scheduleEvent(EventTypeNames::pause); | 2079 scheduleEvent(EventTypeNames::pause); |
| 2080 scheduleRejectPlayPromises(AbortError, "The play() request was interrupt ed by a call to pause()."); | |
| 2043 } | 2081 } |
| 2044 | 2082 |
| 2045 updatePlayState(); | 2083 updatePlayState(); |
| 2046 } | 2084 } |
| 2047 | 2085 |
| 2048 void HTMLMediaElement::requestRemotePlayback() | 2086 void HTMLMediaElement::requestRemotePlayback() |
| 2049 { | 2087 { |
| 2050 ASSERT(m_remoteRoutesAvailable); | 2088 ASSERT(m_remoteRoutesAvailable); |
| 2051 webMediaPlayer()->requestRemotePlayback(); | 2089 webMediaPlayer()->requestRemotePlayback(); |
| 2052 } | 2090 } |
| (...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3487 visitor->trace(m_asyncEventQueue); | 3525 visitor->trace(m_asyncEventQueue); |
| 3488 visitor->trace(m_error); | 3526 visitor->trace(m_error); |
| 3489 visitor->trace(m_currentSourceNode); | 3527 visitor->trace(m_currentSourceNode); |
| 3490 visitor->trace(m_nextChildNodeToConsider); | 3528 visitor->trace(m_nextChildNodeToConsider); |
| 3491 visitor->trace(m_mediaSource); | 3529 visitor->trace(m_mediaSource); |
| 3492 visitor->trace(m_audioTracks); | 3530 visitor->trace(m_audioTracks); |
| 3493 visitor->trace(m_videoTracks); | 3531 visitor->trace(m_videoTracks); |
| 3494 visitor->trace(m_cueTimeline); | 3532 visitor->trace(m_cueTimeline); |
| 3495 visitor->trace(m_textTracks); | 3533 visitor->trace(m_textTracks); |
| 3496 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3534 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
| 3535 visitor->trace(m_playResolvers); | |
| 3497 visitor->trace(m_audioSourceProvider); | 3536 visitor->trace(m_audioSourceProvider); |
| 3498 visitor->template registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::c learWeakMembers>(this); | 3537 visitor->template registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::c learWeakMembers>(this); |
| 3499 visitor->trace(m_autoplayHelper); | 3538 visitor->trace(m_autoplayHelper); |
| 3500 HeapSupplementable<HTMLMediaElement>::trace(visitor); | 3539 HeapSupplementable<HTMLMediaElement>::trace(visitor); |
| 3501 #endif | 3540 #endif |
| 3502 HTMLElement::trace(visitor); | 3541 HTMLElement::trace(visitor); |
| 3503 ActiveDOMObject::trace(visitor); | 3542 ActiveDOMObject::trace(visitor); |
| 3504 } | 3543 } |
| 3505 | 3544 |
| 3506 void HTMLMediaElement::createPlaceholderTracksIfNecessary() | 3545 void HTMLMediaElement::createPlaceholderTracksIfNecessary() |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3564 { | 3603 { |
| 3565 m_autoplayHelper.updatePositionNotificationRegistration(); | 3604 m_autoplayHelper.updatePositionNotificationRegistration(); |
| 3566 } | 3605 } |
| 3567 | 3606 |
| 3568 // TODO(liberato): remove once autoplay gesture override experiment concludes. | 3607 // TODO(liberato): remove once autoplay gesture override experiment concludes. |
| 3569 void HTMLMediaElement::triggerAutoplayViewportCheckForTesting() | 3608 void HTMLMediaElement::triggerAutoplayViewportCheckForTesting() |
| 3570 { | 3609 { |
| 3571 m_autoplayHelper.triggerAutoplayViewportCheckForTesting(); | 3610 m_autoplayHelper.triggerAutoplayViewportCheckForTesting(); |
| 3572 } | 3611 } |
| 3573 | 3612 |
| 3613 void HTMLMediaElement::scheduleResolvePlayPromises() | |
| 3614 { | |
| 3615 Platform::current()->currentThread()->taskRunner()->postTask( | |
| 3616 BLINK_FROM_HERE, new Task(threadSafeBind(&HTMLMediaElement::resolvePlayP romises, AllowCrossThreadAccess(this)))); | |
|
hiroshige
2016/02/18 18:32:41
(1) The code seems single threaded, because schedu
mlamouri (slow - plz ping)
2016/02/18 19:24:42
You are correct, it doesn't need to be thread safe
| |
| 3617 } | |
| 3618 | |
| 3619 void HTMLMediaElement::scheduleRejectPlayPromises(ExceptionCode code, const Stri ng& message) | |
| 3620 { | |
| 3621 Platform::current()->currentThread()->taskRunner()->postTask( | |
| 3622 BLINK_FROM_HERE, new Task(threadSafeBind(&HTMLMediaElement::rejectPlayPr omises, AllowCrossThreadAccess(this), code, message))); | |
| 3623 } | |
| 3624 | |
| 3625 void HTMLMediaElement::scheduleNotifyPlaying() | |
| 3626 { | |
| 3627 scheduleEvent(EventTypeNames::playing); | |
| 3628 scheduleResolvePlayPromises(); | |
| 3629 } | |
| 3630 | |
| 3631 void HTMLMediaElement::resolvePlayPromises() | |
| 3632 { | |
| 3633 for (auto& resolver: m_playResolvers) | |
| 3634 resolver->resolve(); | |
| 3635 | |
| 3636 m_playResolvers.clear(); | |
| 3637 } | |
| 3638 | |
| 3639 void HTMLMediaElement::rejectPlayPromises(ExceptionCode code, const String& mess age) | |
| 3640 { | |
| 3641 ASSERT(code == AbortError || code == NotSupportedError); | |
| 3642 | |
| 3643 for (auto& resolver: m_playResolvers) | |
| 3644 resolver->reject(DOMException::create(code, message)); | |
| 3645 | |
| 3646 m_playResolvers.clear(); | |
| 3647 } | |
| 3648 | |
| 3574 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3649 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3575 { | 3650 { |
| 3576 if (!Heap::isHeapObjectAlive(m_audioSourceNode)) | 3651 if (!Heap::isHeapObjectAlive(m_audioSourceNode)) |
| 3577 audioSourceProvider().setClient(nullptr); | 3652 audioSourceProvider().setClient(nullptr); |
| 3578 } | 3653 } |
| 3579 | 3654 |
| 3580 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider) | 3655 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider) |
| 3581 { | 3656 { |
| 3582 MutexLocker locker(provideInputLock); | 3657 MutexLocker locker(provideInputLock); |
| 3583 | 3658 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3631 { | 3706 { |
| 3632 visitor->trace(m_client); | 3707 visitor->trace(m_client); |
| 3633 } | 3708 } |
| 3634 | 3709 |
| 3635 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) | 3710 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) |
| 3636 { | 3711 { |
| 3637 visitor->trace(m_client); | 3712 visitor->trace(m_client); |
| 3638 } | 3713 } |
| 3639 | 3714 |
| 3640 } // namespace blink | 3715 } // namespace blink |
| OLD | NEW |