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

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

Issue 2134323002: Remove threading primitives from ParseHTMLOnMainThread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on 405128 Created 4 years, 5 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 e9eb5f63c3d802548cc4e38b8bfa0a8f4f7520b0..2481625632d884b49b75ed3081823bb4bbc04486 100644
--- a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp
+++ b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp
@@ -159,7 +159,7 @@ void BackgroundHTMLParser::updateDocument(const String& decodedData)
m_lastSeenEncodingData = encodingData;
m_xssAuditor->setEncoding(encodingData.encoding());
- runOnMainThread(crossThreadBind(&HTMLDocumentParser::didReceiveEncodingDataFromBackgroundParser, m_parser, encodingData));
+ runOnMainThread(&HTMLDocumentParser::didReceiveEncodingDataFromBackgroundParser, m_parser, encodingData);
}
if (decodedData.isEmpty())
@@ -317,7 +317,7 @@ void BackgroundHTMLParser::sendTokensToMainThread()
chunkEnqueueTime.count(monotonicallyIncreasingTimeMS() - chunkStartTime);
if (isEmpty) {
- runOnMainThread(crossThreadBind(&HTMLDocumentParser::notifyPendingParsedChunks, m_parser));
+ runOnMainThread(&HTMLDocumentParser::notifyPendingParsedChunks, m_parser);
}
m_pendingTokens = wrapUnique(new CompactHTMLTokenStream);
@@ -328,12 +328,14 @@ void BackgroundHTMLParser::sendTokensToMainThread()
// main parser deals with chunking up its own work.
// TODO(csharrison): This is a pretty big hack because we don't actually need a
// CrossThreadClosure in these cases. This is just experimental.
-void BackgroundHTMLParser::runOnMainThread(std::unique_ptr<CrossThreadClosure> closure)
+template <typename FunctionType, typename... Ps>
+void BackgroundHTMLParser::runOnMainThread(FunctionType function, Ps&&... parameters)
{
- if (isMainThread())
- (*closure)();
- else
- m_loadingTaskRunner->postTask(BLINK_FROM_HERE, std::move(closure));
+ if (isMainThread()) {
+ (*WTF::bind(function, std::forward<Ps>(parameters)...))();
+ } else {
+ m_loadingTaskRunner->postTask(BLINK_FROM_HERE, crossThreadBind(function, std::forward<Ps>(parameters)...));
+ }
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698