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

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

Issue 2329243002: Implement WTF::WeakPtr in terms of base::WeakPtr (Closed)
Patch Set: Thread-safety fix with comment Created 4 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
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 3002ac9ad7bfc93d64a921b431914a13f54c6383..0a9187b1cb9175fb0a4352f7eaaea695aa665815 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
@@ -761,9 +761,6 @@ void HTMLDocumentParser::startBackgroundParser()
if (document()->loader())
document()->ensureStyleResolver();
- RefPtr<WeakReference<BackgroundHTMLParser>> reference = WeakReference<BackgroundHTMLParser>::createUnbound();
- m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference);
-
std::unique_ptr<BackgroundHTMLParser::Configuration> config = wrapUnique(new BackgroundHTMLParser::Configuration);
config->options = m_options;
config->parser = m_weakFactory.createWeakPtr();
@@ -781,15 +778,15 @@ void HTMLDocumentParser::startBackgroundParser()
}
ASSERT(config->xssAuditor->isSafeToSendToAnotherThread());
- postTaskToLookaheadParser(
- Synchronous,
- &BackgroundHTMLParser::start,
- reference.release(),
- passed(std::move(config)),
- document()->url(),
- passed(CachedDocumentParameters::create(document())),
- MediaValuesCached::MediaValuesCachedData(*document()),
- passed(m_loadingTaskRunner->clone()));
+
+ // The background parser is created on the main thread, but may otherwise
+ // only be used from the parser thread.
+ m_backgroundParser = BackgroundHTMLParser::create(
+ std::move(config),
+ m_loadingTaskRunner->clone());
+ // TODO(csharrison): This is a hack to initialize MediaValuesCached on the
+ // correct thread. We should get rid of it.
+ postTaskToLookaheadParser(Synchronous, &BackgroundHTMLParser::init, m_backgroundParser, document()->url(), passed(CachedDocumentParameters::create(document())), MediaValuesCached::MediaValuesCachedData(*document()));
}
void HTMLDocumentParser::stopBackgroundParser()

Powered by Google App Engine
This is Rietveld 408576698