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

Unified Diff: third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.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/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 5a2174aec5736c20cbbe720f521611b08fc5f69f..d98266fc8e55b1bd06930a8c2cb148d2a37a8d26 100644
--- a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp
+++ b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp
@@ -35,6 +35,7 @@
#include "public/platform/Platform.h"
#include "public/platform/WebTaskRunner.h"
#include "wtf/CurrentTime.h"
+#include "wtf/Functional.h"
#include "wtf/PtrUtil.h"
#include "wtf/text/TextPosition.h"
#include <memory>
@@ -84,12 +85,18 @@ static void checkThatXSSInfosAreSafeToSendToAnotherThread(const XSSInfoStream& i
#endif
-void BackgroundHTMLParser::start(PassRefPtr<WeakReference<BackgroundHTMLParser>> reference, std::unique_ptr<Configuration> config, const KURL& documentURL, std::unique_ptr<CachedDocumentParameters> cachedDocumentParameters, const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData, std::unique_ptr<WebTaskRunner> loadingTaskRunner)
+WeakPtr<BackgroundHTMLParser> BackgroundHTMLParser::create(std::unique_ptr<Configuration> config, std::unique_ptr<WebTaskRunner> loadingTaskRunner)
{
- new BackgroundHTMLParser(reference, std::move(config), documentURL, std::move(cachedDocumentParameters), mediaValuesCachedData, std::move(loadingTaskRunner));
- // Caller must free by calling stop().
+ auto* backgroundParser = new BackgroundHTMLParser(std::move(config), std::move(loadingTaskRunner));
+ return backgroundParser->m_weakFactory.createWeakPtr();
}
+void BackgroundHTMLParser::init(const KURL& documentURL, std::unique_ptr<CachedDocumentParameters> cachedDocumentParameters, const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData)
+{
+ m_preloadScanner.reset(new TokenPreloadScanner(documentURL, std::move(cachedDocumentParameters), mediaValuesCachedData));
+}
+
+
BackgroundHTMLParser::Configuration::Configuration()
: outstandingTokenLimit(defaultOutstandingTokenLimit)
, pendingTokenLimit(defaultPendingTokenLimit)
@@ -97,8 +104,8 @@ BackgroundHTMLParser::Configuration::Configuration()
{
}
-BackgroundHTMLParser::BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser>> reference, std::unique_ptr<Configuration> config, const KURL& documentURL, std::unique_ptr<CachedDocumentParameters> cachedDocumentParameters, const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData, std::unique_ptr<WebTaskRunner> loadingTaskRunner)
- : m_weakFactory(reference, this)
+BackgroundHTMLParser::BackgroundHTMLParser(std::unique_ptr<Configuration> config, std::unique_ptr<WebTaskRunner> loadingTaskRunner)
+ : m_weakFactory(this)
, m_token(wrapUnique(new HTMLToken))
, m_tokenizer(HTMLTokenizer::create(config->options))
, m_treeBuilderSimulator(config->options)
@@ -108,7 +115,6 @@ BackgroundHTMLParser::BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHT
, m_pendingTokens(wrapUnique(new CompactHTMLTokenStream))
, m_pendingTokenLimit(config->pendingTokenLimit)
, m_xssAuditor(std::move(config->xssAuditor))
- , m_preloadScanner(wrapUnique(new TokenPreloadScanner(documentURL, std::move(cachedDocumentParameters), mediaValuesCachedData)))
, m_decoder(std::move(config->decoder))
, m_loadingTaskRunner(std::move(loadingTaskRunner))
, m_tokenizedChunkQueue(config->tokenizedChunkQueue.release())

Powered by Google App Engine
This is Rietveld 408576698