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

Unified Diff: Source/core/html/parser/HTMLDocumentParser.cpp

Issue 625583002: Properly suspend HTMLDocumentParser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: better way to call m_parserScheduler->resume Created 6 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
Index: Source/core/html/parser/HTMLDocumentParser.cpp
diff --git a/Source/core/html/parser/HTMLDocumentParser.cpp b/Source/core/html/parser/HTMLDocumentParser.cpp
index 5e89dc7c97a5cbb5cd0efdcf1bac319f77b55eb2..709f7085ed0f49fabc007b909157110ccaced13a 100644
--- a/Source/core/html/parser/HTMLDocumentParser.cpp
+++ b/Source/core/html/parser/HTMLDocumentParser.cpp
@@ -116,6 +116,7 @@ HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors
, m_isPinnedToMainThread(false)
, m_endWasDelayed(false)
, m_haveBackgroundParser(false)
+ , m_tasksWereSuspended(false)
, m_pumpSessionNestingLevel(0)
{
ASSERT(shouldUseThreading() || (m_token && m_tokenizer));
@@ -134,6 +135,7 @@ HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont
, m_isPinnedToMainThread(true)
, m_endWasDelayed(false)
, m_haveBackgroundParser(false)
+ , m_tasksWereSuspended(false)
, m_pumpSessionNestingLevel(0)
{
ASSERT(!shouldUseThreading());
@@ -334,7 +336,9 @@ void HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<Pa
// alert(), runModalDialog, and the JavaScript Debugger all run nested event loops
// which can cause this method to be re-entered. We detect re-entry using
// hasActiveParser(), save the chunk as a speculation, and return.
- if (isWaitingForScripts() || !m_speculations.isEmpty() || document()->activeParserCount() > 0) {
+ if (isWaitingForScripts() || !m_speculations.isEmpty() || document()->activeParserCount() > 0 || m_tasksWereSuspended) {
+ if (m_tasksWereSuspended)
+ m_parserScheduler->forceResumeAfterYield();
m_preloader->takeAndPreload(chunk->preloads);
m_speculations.append(chunk);
return;
@@ -1003,12 +1007,16 @@ void HTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFra
void HTMLDocumentParser::suspendScheduledTasks()
{
+ ASSERT(!m_tasksWereSuspended);
+ m_tasksWereSuspended = true;
if (m_parserScheduler)
m_parserScheduler->suspend();
}
void HTMLDocumentParser::resumeScheduledTasks()
{
+ ASSERT(m_tasksWereSuspended);
+ m_tasksWereSuspended = false;
if (m_parserScheduler)
m_parserScheduler->resume();
}

Powered by Google App Engine
This is Rietveld 408576698