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

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 1481913002: Remove userCancelledLoad and refactor the code at the call sites (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
index 3bae974c27f776b7d77c0d3f2de88d5fd937df28..eea696b9fdc1426c8c2c5a52a749efaef3757720 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -384,7 +384,7 @@ HTMLMediaElement::~HTMLMediaElement()
removeElementFromDocumentMap(this, &document());
// Destroying the player may cause a resource load to be canceled,
- // which could result in userCancelledLoad() being called back.
+ // which could result in cancelledLoad() being called back.
philipj_slow 2015/11/27 14:01:28 This comment seems inaccurate, destroying the play
Srirama 2015/11/30 12:43:34 Done.
// Setting m_isFinalizing ensures that such a call will not cause
// us to dispatch an abort event, which would result in a crash.
// See http://crbug.com/233654 for more details.
@@ -477,7 +477,7 @@ void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument)
// previous document. A proper fix would provide a mechanism to allow this
// object to refresh the MediaPlayer's LocalFrame and FrameLoader references on
// document changes so that playback can be resumed properly.
- userCancelledLoad();
+ cancelledLoad();
// Decrement the load event delay count on oldDocument now that m_webMediaPlayer has been destroyed
// and there is no risk of dispatching a load event from within the destructor.
@@ -2975,16 +2975,13 @@ void HTMLMediaElement::stopPeriodicTimers()
m_playbackProgressTimer.stop();
}
-void HTMLMediaElement::userCancelledLoad()
+// TODO(srirama.m): Refactor this along with clearMediaPlayer and resetMediaPlayerAndMediaSource.
+void HTMLMediaElement::cancelledLoad()
philipj_slow 2015/11/27 14:01:27 OK, so this is called from didMoveToNewDocument()
Srirama 2015/11/30 12:43:34 Done, But the changes for didMoveToNewDocument() a
{
- WTF_LOG(Media, "HTMLMediaElement::userCancelledLoad(%p)", this);
+ WTF_LOG(Media, "HTMLMediaElement::cancelledLoad(%p)", this);
- // If the media data fetching process is aborted by the user:
-
- // 1 - The user agent should cancel the fetching process.
clearMediaPlayer(-1);
// Reset m_readyState and m_readyStateMaximum since m_webMediaPlayer is gone.
- ReadyState readyState = m_readyState;
m_readyState = HAVE_NOTHING;
m_readyStateMaximum = HAVE_NOTHING;
@@ -2992,27 +2989,11 @@ void HTMLMediaElement::userCancelledLoad()
if (m_networkState == NETWORK_EMPTY || m_completelyLoaded || m_isFinalizing)
return;
- // 2 - Set the error attribute to a new MediaError object whose code attribute is set to MEDIA_ERR_ABORTED.
- m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED);
-
- // 3 - Queue a task to fire a simple event named error at the media element.
- scheduleEvent(EventTypeNames::abort);
+ setNetworkState(NETWORK_EMPTY);
+ scheduleEvent(EventTypeNames::emptied);
- // 4 - If the media element's readyState attribute has a value equal to HAVE_NOTHING, set the
- // element's networkState attribute to the NETWORK_EMPTY value and queue a task to fire a
- // simple event named emptied at the element. Otherwise, set the element's networkState
- // attribute to the NETWORK_IDLE value.
- if (readyState == HAVE_NOTHING) {
- setNetworkState(NETWORK_EMPTY);
- scheduleEvent(EventTypeNames::emptied);
- } else {
- setNetworkState(NETWORK_IDLE);
- }
-
- // 5 - Set the element's delaying-the-load-event flag to false. This stops delaying the load event.
setShouldDelayLoadEvent(false);
- // 6 - Abort the overall resource selection algorithm.
m_currentSourceNode = nullptr;
invalidateCachedTime();
@@ -3067,11 +3048,11 @@ void HTMLMediaElement::stop()
recordMetricsIfPausing();
- // Close the async event queue so that no events are enqueued by userCancelledLoad.
+ // Close the async event queue so that no events are enqueued by cancelledLoad.
philipj_slow 2015/11/27 14:01:28 If cancelledLoad() is removed, in principle I thin
Srirama 2015/11/30 12:43:34 Acknowledged.
cancelPendingEventsAndCallbacks();
m_asyncEventQueue->close();
- userCancelledLoad();
+ cancelledLoad();
// Stop the playback without generating events
m_playing = false;
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698