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

Unified Diff: third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp

Issue 1394663004: Reland: BackgroundHTMLParser: Introduce ParsedChunkQueue to pass ParsedChunks to main thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ParsedChunkQueue should be ThreadSafeRefCounted Created 5 years, 2 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
Index: third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp
diff --git a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp
index 8d08984b220477899accd7d6207abfca35eaf9f4..946fe85d3d7d6ee973de8c00182f3dfe3594323d 100644
--- a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp
+++ b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp
@@ -107,6 +107,7 @@ BackgroundHTMLParser::BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHT
, m_preloadScanner(config->preloadScanner.release())
, m_decoder(config->decoder.release())
, m_loadingTaskRunner(loadingTaskRunner)
+ , m_parsedChunkQueue(config->parsedChunkQueue.release())
, m_startingScript(false)
{
ASSERT(m_outstandingTokenLimit > 0);
@@ -177,6 +178,7 @@ void BackgroundHTMLParser::resumeFrom(PassOwnPtr<Checkpoint> checkpoint)
m_input.rewindTo(checkpoint->inputCheckpoint, checkpoint->unparsedInput);
m_preloadScanner->rewindTo(checkpoint->preloadScannerCheckpoint);
m_startingScript = false;
+ m_parsedChunkQueue->clear();
pumpTokenizer();
}
@@ -291,9 +293,12 @@ void BackgroundHTMLParser::sendTokensToMainThread()
chunk->startingScript = m_startingScript;
m_startingScript = false;
- m_loadingTaskRunner->postTask(
- BLINK_FROM_HERE,
- new Task(threadSafeBind(&HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser, AllowCrossThreadAccess(m_parser), chunk.release())));
+ bool isEmpty = m_parsedChunkQueue->enqueue(chunk.release());
+ if (isEmpty) {
+ m_loadingTaskRunner->postTask(
+ BLINK_FROM_HERE,
+ new Task(threadSafeBind(&HTMLDocumentParser::notifyPendingParsedChunks, AllowCrossThreadAccess(m_parser))));
+ }
m_pendingTokens = adoptPtr(new CompactHTMLTokenStream);
}

Powered by Google App Engine
This is Rietveld 408576698