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

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

Issue 552303006: Prevent more script-observable cases of HTMLMediaElement GC (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: make gc-while-seeking.html non-flaky Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/media/track/track-remove-track.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index f1a270cdece73a6f1201df876ebba5beab02f0df..aa0e739c739872e522e63a0d98cf72047fe2d455 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -3523,7 +3523,39 @@ void HTMLMediaElement::stop()
bool HTMLMediaElement::hasPendingActivity() const
{
- return (hasAudio() && isPlaying()) || m_asyncEventQueue->hasPendingEvents();
+ // After the document becomes inactive, no events can ever be fired.
+ if (!document().isActive()) {
+ ASSERT(!m_asyncEventQueue->hasPendingEvents());
+ return false;
+ }
+
+ // The delaying-the-load-event flag is set by resource selection algorithm when looking for a
+ // resource to load, before networkState has reached to NETWORK_LOADING.
+ if (m_shouldDelayLoadEvent)
+ return true;
+
+ // When networkState is NETWORK_LOADING, progress and stalled events may be fired.
+ if (m_networkState == NETWORK_LOADING)
+ return true;
+
+ // When playing or if playback may continue, timeupdate events may be fired.
+ if (couldPlayIfEnoughData())
+ return true;
+
+ // When the seek finishes timeupdate and seeked events will be fired.
+ if (m_seeking)
+ return true;
+
+ // When connected to a MediaSource, e.g. setting MediaSource.duration will cause a
+ // durationchange event to be fired.
+ if (m_mediaSource)
+ return true;
+
+ // Wait for any pending events to be fired.
+ if (m_asyncEventQueue->hasPendingEvents())
+ return true;
+
+ return false;
}
void HTMLMediaElement::contextDestroyed()
« no previous file with comments | « LayoutTests/media/track/track-remove-track.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698