| Index: third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
|
| diff --git a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
|
| index 18f5934429f17ac31852e2913bbd258ce3b033e5..7908a5d662ad1803203fed61efc3a9c9597b5b0d 100644
|
| --- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
|
| +++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
|
| @@ -410,7 +410,7 @@ void HTMLDocumentParser::discardSpeculationsAndResumeFrom(std::unique_ptr<Parsed
|
| m_input.current().clear(); // FIXME: This should be passed in instead of cleared.
|
|
|
| ASSERT(checkpoint->unparsedInput.isSafeToSendToAnotherThread());
|
| - postTaskToLookaheadParser(crossThreadBind(&BackgroundHTMLParser::resumeFrom, m_backgroundParser, passed(std::move(checkpoint))));
|
| + postTaskToLookaheadParser(Asynchronous, &BackgroundHTMLParser::resumeFrom, m_backgroundParser, passed(std::move(checkpoint)));
|
| }
|
|
|
| size_t HTMLDocumentParser::processParsedChunkFromBackgroundParser(std::unique_ptr<ParsedChunk> popChunk)
|
| @@ -432,7 +432,7 @@ size_t HTMLDocumentParser::processParsedChunkFromBackgroundParser(std::unique_pt
|
| std::unique_ptr<CompactHTMLTokenStream> tokens = std::move(chunk->tokens);
|
| size_t elementTokenCount = 0;
|
|
|
| - postTaskToLookaheadParser(crossThreadBind(&BackgroundHTMLParser::startedChunkWithCheckpoint, m_backgroundParser, chunk->inputCheckpoint));
|
| + postTaskToLookaheadParser(Asynchronous, &BackgroundHTMLParser::startedChunkWithCheckpoint, m_backgroundParser, chunk->inputCheckpoint);
|
|
|
| for (const auto& xssInfo : chunk->xssInfos) {
|
| m_textPosition = xssInfo->m_textPosition;
|
| @@ -563,7 +563,7 @@ void HTMLDocumentParser::forcePlaintextForTextDocument()
|
| if (!m_haveBackgroundParser)
|
| startBackgroundParser();
|
|
|
| - postTaskToLookaheadParser(crossThreadBind(&BackgroundHTMLParser::forcePlaintextForTextDocument, m_backgroundParser));
|
| + postTaskToLookaheadParser(Asynchronous, &BackgroundHTMLParser::forcePlaintextForTextDocument, m_backgroundParser);
|
| } else
|
| m_tokenizer->setState(HTMLTokenizer::PLAINTEXTState);
|
| }
|
| @@ -739,14 +739,15 @@ void HTMLDocumentParser::startBackgroundParser()
|
| }
|
|
|
| ASSERT(config->xssAuditor->isSafeToSendToAnotherThread());
|
| - postTaskToLookaheadParser(crossThreadBind(
|
| + postTaskToLookaheadParser(
|
| + Synchronous,
|
| &BackgroundHTMLParser::start,
|
| reference.release(),
|
| passed(std::move(config)),
|
| document()->url(),
|
| passed(CachedDocumentParameters::create(document())),
|
| MediaValuesCached::MediaValuesCachedData(*document()),
|
| - passed(wrapUnique(m_loadingTaskRunner->clone()))), Synchronous);
|
| + passed(wrapUnique(m_loadingTaskRunner->clone())));
|
| }
|
|
|
| void HTMLDocumentParser::stopBackgroundParser()
|
| @@ -758,7 +759,7 @@ void HTMLDocumentParser::stopBackgroundParser()
|
| // Make this sync, as lsan triggers on some unittests if the task runner is
|
| // used. Note that these lifetimes will be much more concrete if
|
| // ParseHTMLOnMainThread lands (the lookahead parser will be a member).
|
| - postTaskToLookaheadParser(crossThreadBind(&BackgroundHTMLParser::stop, m_backgroundParser), Synchronous);
|
| + postTaskToLookaheadParser(Synchronous, &BackgroundHTMLParser::stop, m_backgroundParser);
|
| m_weakFactory.revokeAll();
|
| }
|
|
|
| @@ -866,7 +867,7 @@ void HTMLDocumentParser::finish()
|
| if (m_haveBackgroundParser) {
|
| if (!m_input.haveSeenEndOfFile())
|
| m_input.closeWithoutMarkingEndOfFile();
|
| - postTaskToLookaheadParser(crossThreadBind(&BackgroundHTMLParser::finish, m_backgroundParser));
|
| + postTaskToLookaheadParser(Asynchronous, &BackgroundHTMLParser::finish, m_backgroundParser);
|
| return;
|
| }
|
|
|
| @@ -1033,7 +1034,7 @@ void HTMLDocumentParser::appendBytes(const char* data, size_t length)
|
| TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "HTMLDocumentParser::appendBytes", "size", (unsigned)length);
|
|
|
| LookaheadParserTaskSynchrony policy = document()->settings() && document()->settings()->parseHTMLOnMainThreadSyncTokenize() ? Synchronous : Asynchronous;
|
| - postTaskToLookaheadParser(crossThreadBind(&BackgroundHTMLParser::appendRawBytesFromMainThread, m_backgroundParser, passed(std::move(buffer)), bytesReceivedTime), policy);
|
| + postTaskToLookaheadParser(policy, &BackgroundHTMLParser::appendRawBytesFromMainThread, m_backgroundParser, passed(std::move(buffer)), bytesReceivedTime);
|
| return;
|
| }
|
|
|
| @@ -1057,7 +1058,7 @@ void HTMLDocumentParser::flush()
|
| return;
|
| }
|
|
|
| - postTaskToLookaheadParser(crossThreadBind(&BackgroundHTMLParser::flush, m_backgroundParser));
|
| + postTaskToLookaheadParser(Asynchronous, &BackgroundHTMLParser::flush, m_backgroundParser);
|
| } else {
|
| DecodedDataDocumentParser::flush();
|
| }
|
| @@ -1069,7 +1070,7 @@ void HTMLDocumentParser::setDecoder(std::unique_ptr<TextResourceDecoder> decoder
|
| DecodedDataDocumentParser::setDecoder(std::move(decoder));
|
|
|
| if (m_haveBackgroundParser)
|
| - postTaskToLookaheadParser(crossThreadBind(&BackgroundHTMLParser::setDecoder, m_backgroundParser, passed(takeDecoder())));
|
| + postTaskToLookaheadParser(Asynchronous, &BackgroundHTMLParser::setDecoder, m_backgroundParser, passed(takeDecoder()));
|
| }
|
|
|
| void HTMLDocumentParser::documentElementAvailable()
|
| @@ -1134,10 +1135,11 @@ void HTMLDocumentParser::evaluateAndPreloadScriptForDocumentWrite(const String&
|
| }
|
| }
|
|
|
| -void HTMLDocumentParser::postTaskToLookaheadParser(std::unique_ptr<CrossThreadClosure> closure, LookaheadParserTaskSynchrony synchronyPolicy)
|
| +template <typename FunctionType, typename... Ps>
|
| +void HTMLDocumentParser::postTaskToLookaheadParser(LookaheadParserTaskSynchrony synchronyPolicy, FunctionType function, Ps&&... parameters)
|
| {
|
| if (!RuntimeEnabledFeatures::parseHTMLOnMainThreadEnabled()) {
|
| - HTMLParserThread::shared()->postTask(std::move(closure));
|
| + HTMLParserThread::shared()->postTask(crossThreadBind(function, std::forward<Ps>(parameters)...));
|
| return;
|
| }
|
|
|
| @@ -1145,10 +1147,10 @@ void HTMLDocumentParser::postTaskToLookaheadParser(std::unique_ptr<CrossThreadCl
|
| // just post to the loading task runner.
|
| switch (synchronyPolicy) {
|
| case Synchronous:
|
| - (*closure)();
|
| + (*WTF::bind(function, std::forward<Ps>(parameters)...))();
|
| return;
|
| case Asynchronous:
|
| - m_loadingTaskRunner->postTask(BLINK_FROM_HERE, std::move(closure));
|
| + m_loadingTaskRunner->postTask(BLINK_FROM_HERE, WTF::bind(function, std::forward<Ps>(parameters)...));
|
| return;
|
| }
|
| NOTREACHED();
|
|
|