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

Side by Side 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 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
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. 387 // 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.
388 // Setting m_isFinalizing ensures that such a call will not cause 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. 389 // us to dispatch an abort event, which would result in a crash.
390 // See http://crbug.com/233654 for more details. 390 // See http://crbug.com/233654 for more details.
391 m_isFinalizing = true; 391 m_isFinalizing = true;
392 392
393 // Destroying the player may cause a resource load to be canceled, 393 // Destroying the player may cause a resource load to be canceled,
394 // which could result in Document::dispatchWindowLoadEvent() being 394 // which could result in Document::dispatchWindowLoadEvent() being
395 // called via ResourceFetch::didLoadResource() then 395 // called via ResourceFetch::didLoadResource() then
396 // FrameLoader::checkCompleted(). To prevent load event dispatching during 396 // FrameLoader::checkCompleted(). To prevent load event dispatching during
397 // object destruction, we use Document::incrementLoadEventDelayCount(). 397 // object destruction, we use Document::incrementLoadEventDelayCount().
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 470 }
471 471
472 removeElementFromDocumentMap(this, &oldDocument); 472 removeElementFromDocumentMap(this, &oldDocument);
473 addElementToDocumentMap(this, &document()); 473 addElementToDocumentMap(this, &document());
474 474
475 // FIXME: This is a temporary fix to prevent this object from causing the 475 // FIXME: This is a temporary fix to prevent this object from causing the
476 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the 476 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the
477 // previous document. A proper fix would provide a mechanism to allow this 477 // previous document. A proper fix would provide a mechanism to allow this
478 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on 478 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on
479 // document changes so that playback can be resumed properly. 479 // document changes so that playback can be resumed properly.
480 userCancelledLoad(); 480 cancelledLoad();
481 481
482 // Decrement the load event delay count on oldDocument now that m_webMediaPl ayer has been destroyed 482 // 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. 483 // and there is no risk of dispatching a load event from within the destruct or.
484 oldDocument.decrementLoadEventDelayCount(); 484 oldDocument.decrementLoadEventDelayCount();
485 485
486 ActiveDOMObject::didMoveToNewExecutionContext(&document()); 486 ActiveDOMObject::didMoveToNewExecutionContext(&document());
487 HTMLElement::didMoveToNewDocument(oldDocument); 487 HTMLElement::didMoveToNewDocument(oldDocument);
488 } 488 }
489 489
490 bool HTMLMediaElement::supportsFocus() const 490 bool HTMLMediaElement::supportsFocus() const
(...skipping 2477 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 if (layoutObject()) 2968 if (layoutObject())
2969 layoutObject()->updateFromElement(); 2969 layoutObject()->updateFromElement();
2970 } 2970 }
2971 2971
2972 void HTMLMediaElement::stopPeriodicTimers() 2972 void HTMLMediaElement::stopPeriodicTimers()
2973 { 2973 {
2974 m_progressEventTimer.stop(); 2974 m_progressEventTimer.stop();
2975 m_playbackProgressTimer.stop(); 2975 m_playbackProgressTimer.stop();
2976 } 2976 }
2977 2977
2978 void HTMLMediaElement::userCancelledLoad() 2978 // TODO(srirama.m): Refactor this along with clearMediaPlayer and resetMediaPlay erAndMediaSource.
2979 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
2979 { 2980 {
2980 WTF_LOG(Media, "HTMLMediaElement::userCancelledLoad(%p)", this); 2981 WTF_LOG(Media, "HTMLMediaElement::cancelledLoad(%p)", this);
2981 2982
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); 2983 clearMediaPlayer(-1);
2986 // Reset m_readyState and m_readyStateMaximum since m_webMediaPlayer is gone . 2984 // Reset m_readyState and m_readyStateMaximum since m_webMediaPlayer is gone .
2987 ReadyState readyState = m_readyState;
2988 m_readyState = HAVE_NOTHING; 2985 m_readyState = HAVE_NOTHING;
2989 m_readyStateMaximum = HAVE_NOTHING; 2986 m_readyStateMaximum = HAVE_NOTHING;
2990 2987
2991 // TODO(srirama.m): Investigate if this condition can be dropped entirely wi thout any issues. 2988 // 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) 2989 if (m_networkState == NETWORK_EMPTY || m_completelyLoaded || m_isFinalizing)
2993 return; 2990 return;
2994 2991
2995 // 2 - Set the error attribute to a new MediaError object whose code attribu te is set to MEDIA_ERR_ABORTED. 2992 setNetworkState(NETWORK_EMPTY);
2996 m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED); 2993 scheduleEvent(EventTypeNames::emptied);
2997 2994
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); 2995 setShouldDelayLoadEvent(false);
3014 2996
3015 // 6 - Abort the overall resource selection algorithm.
3016 m_currentSourceNode = nullptr; 2997 m_currentSourceNode = nullptr;
3017 2998
3018 invalidateCachedTime(); 2999 invalidateCachedTime();
3019 cueTimeline().updateActiveCues(0); 3000 cueTimeline().updateActiveCues(0);
3020 } 3001 }
3021 3002
3022 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g() 3003 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g()
3023 { 3004 {
3024 #if ENABLE(WEB_AUDIO) 3005 #if ENABLE(WEB_AUDIO)
3025 audioSourceProvider().setClient(nullptr); 3006 audioSourceProvider().setClient(nullptr);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3060 if (layoutObject()) 3041 if (layoutObject())
3061 layoutObject()->setShouldDoFullPaintInvalidation(); 3042 layoutObject()->setShouldDoFullPaintInvalidation();
3062 } 3043 }
3063 3044
3064 void HTMLMediaElement::stop() 3045 void HTMLMediaElement::stop()
3065 { 3046 {
3066 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); 3047 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this);
3067 3048
3068 recordMetricsIfPausing(); 3049 recordMetricsIfPausing();
3069 3050
3070 // Close the async event queue so that no events are enqueued by userCancell edLoad. 3051 // Close the async event queue so that no events are enqueued by cancelledLo ad.
philipj_slow 2015/11/27 14:01:28 If cancelledLoad() is removed, in principle I thin
Srirama 2015/11/30 12:43:34 Acknowledged.
3071 cancelPendingEventsAndCallbacks(); 3052 cancelPendingEventsAndCallbacks();
3072 m_asyncEventQueue->close(); 3053 m_asyncEventQueue->close();
3073 3054
3074 userCancelledLoad(); 3055 cancelledLoad();
3075 3056
3076 // Stop the playback without generating events 3057 // Stop the playback without generating events
3077 m_playing = false; 3058 m_playing = false;
3078 m_paused = true; 3059 m_paused = true;
3079 m_seeking = false; 3060 m_seeking = false;
3080 3061
3081 if (layoutObject()) 3062 if (layoutObject())
3082 layoutObject()->updateFromElement(); 3063 layoutObject()->updateFromElement();
3083 3064
3084 stopPeriodicTimers(); 3065 stopPeriodicTimers();
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
3682 visitor->trace(m_client); 3663 visitor->trace(m_client);
3683 } 3664 }
3684 3665
3685 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) 3666 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl)
3686 { 3667 {
3687 visitor->trace(m_client); 3668 visitor->trace(m_client);
3688 } 3669 }
3689 #endif 3670 #endif
3690 3671
3691 } 3672 }
OLDNEW
« 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