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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 if (m_textTracks) | 377 if (m_textTracks) |
| 378 m_textTracks->clearOwner(); | 378 m_textTracks->clearOwner(); |
| 379 m_audioTracks->shutdown(); | 379 m_audioTracks->shutdown(); |
| 380 m_videoTracks->shutdown(); | 380 m_videoTracks->shutdown(); |
| 381 | 381 |
| 382 closeMediaSource(); | 382 closeMediaSource(); |
| 383 | 383 |
| 384 removeElementFromDocumentMap(this, &document()); | 384 removeElementFromDocumentMap(this, &document()); |
| 385 | 385 |
| 386 // Destroying the player may cause a resource load to be canceled, | 386 // Destroying the player may cause a resource load to be canceled, |
| 387 // which could result in userCancelledLoad() being called back. | |
| 388 // Setting m_isFinalizing ensures that such a call will not cause | |
| 389 // us to dispatch an abort event, which would result in a crash. | |
| 390 // See http://crbug.com/233654 for more details. | |
| 391 m_isFinalizing = true; | |
| 392 | |
| 393 // Destroying the player may cause a resource load to be canceled, | |
| 394 // which could result in Document::dispatchWindowLoadEvent() being | 387 // which could result in Document::dispatchWindowLoadEvent() being |
| 395 // called via ResourceFetch::didLoadResource() then | 388 // called via ResourceFetch::didLoadResource() then |
| 396 // FrameLoader::checkCompleted(). To prevent load event dispatching during | 389 // FrameLoader::checkCompleted(). To prevent load event dispatching during |
| 397 // object destruction, we use Document::incrementLoadEventDelayCount(). | 390 // object destruction, we use Document::incrementLoadEventDelayCount(). |
| 398 // See http://crbug.com/275223 for more details. | 391 // See http://crbug.com/275223 for more details. |
| 399 document().incrementLoadEventDelayCount(); | 392 document().incrementLoadEventDelayCount(); |
| 400 | 393 |
| 401 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 394 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
| 402 | 395 |
| 403 document().decrementLoadEventDelayCount(); | 396 document().decrementLoadEventDelayCount(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 } | 463 } |
| 471 | 464 |
| 472 removeElementFromDocumentMap(this, &oldDocument); | 465 removeElementFromDocumentMap(this, &oldDocument); |
| 473 addElementToDocumentMap(this, &document()); | 466 addElementToDocumentMap(this, &document()); |
| 474 | 467 |
| 475 // FIXME: This is a temporary fix to prevent this object from causing the | 468 // FIXME: This is a temporary fix to prevent this object from causing the |
| 476 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the | 469 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the |
| 477 // previous document. A proper fix would provide a mechanism to allow this | 470 // previous document. A proper fix would provide a mechanism to allow this |
| 478 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on | 471 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on |
| 479 // document changes so that playback can be resumed properly. | 472 // document changes so that playback can be resumed properly. |
| 480 userCancelledLoad(); | 473 clearMediaPlayer(LoadMediaResource); |
| 474 scheduleDelayedAction(LoadMediaResource); | |
| 481 | 475 |
| 482 // Decrement the load event delay count on oldDocument now that m_webMediaPl ayer has been destroyed | 476 // Decrement the load event delay count on oldDocument now that m_webMediaPl ayer has been destroyed |
| 483 // and there is no risk of dispatching a load event from within the destruct or. | 477 // and there is no risk of dispatching a load event from within the destruct or. |
| 484 oldDocument.decrementLoadEventDelayCount(); | 478 oldDocument.decrementLoadEventDelayCount(); |
| 485 | 479 |
| 486 ActiveDOMObject::didMoveToNewExecutionContext(&document()); | 480 ActiveDOMObject::didMoveToNewExecutionContext(&document()); |
| 487 HTMLElement::didMoveToNewDocument(oldDocument); | 481 HTMLElement::didMoveToNewDocument(oldDocument); |
| 488 } | 482 } |
| 489 | 483 |
| 490 bool HTMLMediaElement::supportsFocus() const | 484 bool HTMLMediaElement::supportsFocus() const |
| (...skipping 2477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2968 if (layoutObject()) | 2962 if (layoutObject()) |
| 2969 layoutObject()->updateFromElement(); | 2963 layoutObject()->updateFromElement(); |
| 2970 } | 2964 } |
| 2971 | 2965 |
| 2972 void HTMLMediaElement::stopPeriodicTimers() | 2966 void HTMLMediaElement::stopPeriodicTimers() |
| 2973 { | 2967 { |
| 2974 m_progressEventTimer.stop(); | 2968 m_progressEventTimer.stop(); |
| 2975 m_playbackProgressTimer.stop(); | 2969 m_playbackProgressTimer.stop(); |
| 2976 } | 2970 } |
| 2977 | 2971 |
| 2978 void HTMLMediaElement::userCancelledLoad() | |
| 2979 { | |
| 2980 WTF_LOG(Media, "HTMLMediaElement::userCancelledLoad(%p)", this); | |
| 2981 | |
| 2982 // If the media data fetching process is aborted by the user: | |
| 2983 | |
| 2984 // 1 - The user agent should cancel the fetching process. | |
| 2985 clearMediaPlayer(-1); | |
| 2986 // Reset m_readyState and m_readyStateMaximum since m_webMediaPlayer is gone . | |
| 2987 ReadyState readyState = m_readyState; | |
| 2988 m_readyState = HAVE_NOTHING; | |
| 2989 m_readyStateMaximum = HAVE_NOTHING; | |
| 2990 | |
| 2991 // TODO(srirama.m): Investigate if this condition can be dropped entirely wi thout any issues. | |
| 2992 if (m_networkState == NETWORK_EMPTY || m_completelyLoaded || m_isFinalizing) | |
| 2993 return; | |
| 2994 | |
| 2995 // 2 - Set the error attribute to a new MediaError object whose code attribu te is set to MEDIA_ERR_ABORTED. | |
| 2996 m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED); | |
| 2997 | |
| 2998 // 3 - Queue a task to fire a simple event named error at the media element. | |
| 2999 scheduleEvent(EventTypeNames::abort); | |
| 3000 | |
| 3001 // 4 - If the media element's readyState attribute has a value equal to HAVE _NOTHING, set the | |
| 3002 // element's networkState attribute to the NETWORK_EMPTY value and queue a t ask to fire a | |
| 3003 // simple event named emptied at the element. Otherwise, set the element's n etworkState | |
| 3004 // attribute to the NETWORK_IDLE value. | |
| 3005 if (readyState == HAVE_NOTHING) { | |
| 3006 setNetworkState(NETWORK_EMPTY); | |
| 3007 scheduleEvent(EventTypeNames::emptied); | |
| 3008 } else { | |
| 3009 setNetworkState(NETWORK_IDLE); | |
| 3010 } | |
| 3011 | |
| 3012 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. | |
| 3013 setShouldDelayLoadEvent(false); | |
| 3014 | |
| 3015 // 6 - Abort the overall resource selection algorithm. | |
| 3016 m_currentSourceNode = nullptr; | |
| 3017 | |
| 3018 invalidateCachedTime(); | |
| 3019 cueTimeline().updateActiveCues(0); | |
| 3020 } | |
| 3021 | |
| 3022 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g() | 2972 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g() |
| 3023 { | 2973 { |
| 3024 #if ENABLE(WEB_AUDIO) | 2974 #if ENABLE(WEB_AUDIO) |
| 3025 audioSourceProvider().setClient(nullptr); | 2975 audioSourceProvider().setClient(nullptr); |
| 3026 #endif | 2976 #endif |
| 3027 if (m_webMediaPlayer) { | 2977 if (m_webMediaPlayer) { |
| 3028 #if ENABLE(WEB_AUDIO) | 2978 #if ENABLE(WEB_AUDIO) |
| 3029 m_audioSourceProvider.wrap(nullptr); | 2979 m_audioSourceProvider.wrap(nullptr); |
| 3030 #endif | 2980 #endif |
| 3031 m_webMediaPlayer.clear(); | 2981 m_webMediaPlayer.clear(); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 3060 if (layoutObject()) | 3010 if (layoutObject()) |
| 3061 layoutObject()->setShouldDoFullPaintInvalidation(); | 3011 layoutObject()->setShouldDoFullPaintInvalidation(); |
| 3062 } | 3012 } |
| 3063 | 3013 |
| 3064 void HTMLMediaElement::stop() | 3014 void HTMLMediaElement::stop() |
| 3065 { | 3015 { |
| 3066 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); | 3016 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); |
| 3067 | 3017 |
| 3068 recordMetricsIfPausing(); | 3018 recordMetricsIfPausing(); |
| 3069 | 3019 |
| 3070 // Close the async event queue so that no events are enqueued by userCancell edLoad. | 3020 // Close the async event queue so that no events are enqueued by cancelledLo ad. |
|
philipj_slow
2015/11/30 12:55:17
Update this comment.
| |
| 3071 cancelPendingEventsAndCallbacks(); | 3021 cancelPendingEventsAndCallbacks(); |
| 3072 m_asyncEventQueue->close(); | 3022 m_asyncEventQueue->close(); |
| 3073 | 3023 |
| 3074 userCancelledLoad(); | 3024 clearMediaPlayer(-1); |
|
philipj_slow
2015/11/30 12:55:17
I'd say move these bits into the "Stop the playbac
| |
| 3025 setNetworkState(NETWORK_EMPTY); | |
| 3026 setShouldDelayLoadEvent(false); | |
| 3075 | 3027 |
| 3076 // Stop the playback without generating events | 3028 // Stop the playback without generating events |
| 3077 m_playing = false; | 3029 m_playing = false; |
| 3078 m_paused = true; | 3030 m_paused = true; |
| 3079 m_seeking = false; | 3031 m_seeking = false; |
| 3080 | 3032 |
| 3081 if (layoutObject()) | 3033 if (layoutObject()) |
| 3082 layoutObject()->updateFromElement(); | 3034 layoutObject()->updateFromElement(); |
| 3083 | 3035 |
| 3084 stopPeriodicTimers(); | 3036 stopPeriodicTimers(); |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3682 visitor->trace(m_client); | 3634 visitor->trace(m_client); |
| 3683 } | 3635 } |
| 3684 | 3636 |
| 3685 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) | 3637 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) |
| 3686 { | 3638 { |
| 3687 visitor->trace(m_client); | 3639 visitor->trace(m_client); |
| 3688 } | 3640 } |
| 3689 #endif | 3641 #endif |
| 3690 | 3642 |
| 3691 } | 3643 } |
| OLD | NEW |