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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 aa007910512d3a0bd953112c939a71c091ab4275..69f8d510dc4e3d0fa584237ed3c124a2acd1ed92 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
@@ -55,9 +55,7 @@
#include "public/platform/WebLoadingBehaviorFlag.h"
#include "public/platform/WebScheduler.h"
#include "public/platform/WebThread.h"
-#include "wtf/PtrUtil.h"
#include "wtf/TemporaryChange.h"
-#include <memory>
namespace blink {
@@ -91,11 +89,11 @@ static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem
HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, ParserSynchronizationPolicy syncPolicy)
: ScriptableDocumentParser(document)
, m_options(&document)
- , m_token(syncPolicy == ForceSynchronousParsing ? wrapUnique(new HTMLToken) : nullptr)
+ , m_token(syncPolicy == ForceSynchronousParsing ? adoptPtr(new HTMLToken) : nullptr)
, m_tokenizer(syncPolicy == ForceSynchronousParsing ? HTMLTokenizer::create(m_options) : nullptr)
, m_scriptRunner(HTMLScriptRunner::create(&document, this))
, m_treeBuilder(HTMLTreeBuilder::create(this, &document, getParserContentPolicy(), m_options))
- , m_loadingTaskRunner(wrapUnique(document.loadingTaskRunner()->clone()))
+ , m_loadingTaskRunner(adoptPtr(document.loadingTaskRunner()->clone()))
, m_parserScheduler(HTMLParserScheduler::create(this, m_loadingTaskRunner.get()))
, m_xssAuditorDelegate(&document)
, m_weakFactory(this)
@@ -119,10 +117,10 @@ HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, ParserSynchroniza
HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* contextElement, ParserContentPolicy parserContentPolicy)
: ScriptableDocumentParser(fragment->document(), parserContentPolicy)
, m_options(&fragment->document())
- , m_token(wrapUnique(new HTMLToken))
+ , m_token(adoptPtr(new HTMLToken))
, m_tokenizer(HTMLTokenizer::create(m_options))
, m_treeBuilder(HTMLTreeBuilder::create(this, fragment, contextElement, this->getParserContentPolicy(), m_options))
- , m_loadingTaskRunner(wrapUnique(fragment->document().loadingTaskRunner()->clone()))
+ , m_loadingTaskRunner(adoptPtr(fragment->document().loadingTaskRunner()->clone()))
, m_xssAuditorDelegate(&fragment->document())
, m_weakFactory(this)
, m_shouldUseThreading(false)
@@ -292,7 +290,7 @@ void HTMLDocumentParser::notifyPendingParsedChunks()
TRACE_EVENT0("blink", "HTMLDocumentParser::notifyPendingParsedChunks");
ASSERT(m_parsedChunkQueue);
- Vector<std::unique_ptr<ParsedChunk>> pendingChunks;
+ Vector<OwnPtr<ParsedChunk>> pendingChunks;
m_parsedChunkQueue->takeAll(pendingChunks);
if (!isParsing())
@@ -343,7 +341,7 @@ void HTMLDocumentParser::didReceiveEncodingDataFromBackgroundParser(const Docume
document()->setEncodingData(data);
}
-void HTMLDocumentParser::validateSpeculations(std::unique_ptr<ParsedChunk> chunk)
+void HTMLDocumentParser::validateSpeculations(PassOwnPtr<ParsedChunk> chunk)
{
ASSERT(chunk);
if (isWaitingForScripts()) {
@@ -357,8 +355,8 @@ void HTMLDocumentParser::validateSpeculations(std::unique_ptr<ParsedChunk> chunk
}
ASSERT(!m_lastChunkBeforeScript);
- std::unique_ptr<HTMLTokenizer> tokenizer = std::move(m_tokenizer);
- std::unique_ptr<HTMLToken> token = std::move(m_token);
+ OwnPtr<HTMLTokenizer> tokenizer = std::move(m_tokenizer);
+ OwnPtr<HTMLToken> token = std::move(m_token);
if (!tokenizer) {
// There must not have been any changes to the HTMLTokenizer state on
@@ -382,12 +380,12 @@ void HTMLDocumentParser::validateSpeculations(std::unique_ptr<ParsedChunk> chunk
discardSpeculationsAndResumeFrom(std::move(chunk), std::move(token), std::move(tokenizer));
}
-void HTMLDocumentParser::discardSpeculationsAndResumeFrom(std::unique_ptr<ParsedChunk> lastChunkBeforeScript, std::unique_ptr<HTMLToken> token, std::unique_ptr<HTMLTokenizer> tokenizer)
+void HTMLDocumentParser::discardSpeculationsAndResumeFrom(PassOwnPtr<ParsedChunk> lastChunkBeforeScript, PassOwnPtr<HTMLToken> token, PassOwnPtr<HTMLTokenizer> tokenizer)
{
m_weakFactory.revokeAll();
m_speculations.clear();
- std::unique_ptr<BackgroundHTMLParser::Checkpoint> checkpoint = wrapUnique(new BackgroundHTMLParser::Checkpoint);
+ OwnPtr<BackgroundHTMLParser::Checkpoint> checkpoint = adoptPtr(new BackgroundHTMLParser::Checkpoint);
checkpoint->parser = m_weakFactory.createWeakPtr();
checkpoint->token = std::move(token);
checkpoint->tokenizer = std::move(tokenizer);
@@ -401,7 +399,7 @@ void HTMLDocumentParser::discardSpeculationsAndResumeFrom(std::unique_ptr<Parsed
HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::resumeFrom, m_backgroundParser, passed(std::move(checkpoint))));
}
-size_t HTMLDocumentParser::processParsedChunkFromBackgroundParser(std::unique_ptr<ParsedChunk> popChunk)
+size_t HTMLDocumentParser::processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk> popChunk)
{
TRACE_EVENT_WITH_FLOW0("blink,loading", "HTMLDocumentParser::processParsedChunkFromBackgroundParser", popChunk.get(), TRACE_EVENT_FLAG_FLOW_IN);
TemporaryChange<bool> hasLineNumber(m_isParsingAtLineNumber, true);
@@ -416,8 +414,8 @@ size_t HTMLDocumentParser::processParsedChunkFromBackgroundParser(std::unique_pt
ASSERT(!m_token);
ASSERT(!m_lastChunkBeforeScript);
- std::unique_ptr<ParsedChunk> chunk(std::move(popChunk));
- std::unique_ptr<CompactHTMLTokenStream> tokens = std::move(chunk->tokens);
+ OwnPtr<ParsedChunk> chunk(std::move(popChunk));
+ OwnPtr<CompactHTMLTokenStream> tokens = std::move(chunk->tokens);
size_t elementTokenCount = 0;
HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::startedChunkWithCheckpoint, m_backgroundParser, chunk->inputCheckpoint));
@@ -586,7 +584,7 @@ void HTMLDocumentParser::pumpTokenizer()
// We do not XSS filter innerHTML, which means we (intentionally) fail
// http/tests/security/xssAuditor/dom-write-innerHTML.html
- if (std::unique_ptr<XSSInfo> xssInfo = m_xssAuditor.filterToken(FilterTokenRequest(token(), m_sourceTracker, m_tokenizer->shouldAllowCDATA())))
+ if (OwnPtr<XSSInfo> xssInfo = m_xssAuditor.filterToken(FilterTokenRequest(token(), m_sourceTracker, m_tokenizer->shouldAllowCDATA())))
m_xssAuditorDelegate.didBlockScript(*xssInfo);
}
@@ -675,7 +673,7 @@ void HTMLDocumentParser::insert(const SegmentedString& source)
if (!m_tokenizer) {
ASSERT(!inPumpSession());
ASSERT(m_haveBackgroundParser || wasCreatedByScript());
- m_token = wrapUnique(new HTMLToken);
+ m_token = adoptPtr(new HTMLToken);
m_tokenizer = HTMLTokenizer::create(m_options);
}
@@ -711,10 +709,10 @@ void HTMLDocumentParser::startBackgroundParser()
RefPtr<WeakReference<BackgroundHTMLParser>> reference = WeakReference<BackgroundHTMLParser>::createUnbound();
m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference);
- std::unique_ptr<BackgroundHTMLParser::Configuration> config = wrapUnique(new BackgroundHTMLParser::Configuration);
+ OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new BackgroundHTMLParser::Configuration);
config->options = m_options;
config->parser = m_weakFactory.createWeakPtr();
- config->xssAuditor = wrapUnique(new XSSAuditor);
+ config->xssAuditor = adoptPtr(new XSSAuditor);
config->xssAuditor->init(document(), &m_xssAuditorDelegate);
config->decoder = takeDecoder();
@@ -734,7 +732,7 @@ void HTMLDocumentParser::startBackgroundParser()
document()->url(),
passed(CachedDocumentParameters::create(document())),
MediaValuesCached::MediaValuesCachedData(*document()),
- passed(wrapUnique(m_loadingTaskRunner->clone()))));
+ passed(adoptPtr(m_loadingTaskRunner->clone()))));
}
void HTMLDocumentParser::stopBackgroundParser()
@@ -860,7 +858,7 @@ void HTMLDocumentParser::finish()
// We're finishing before receiving any data. Rather than booting up
// the background parser just to spin it down, we finish parsing
// synchronously.
- m_token = wrapUnique(new HTMLToken);
+ m_token = adoptPtr(new HTMLToken);
m_tokenizer = HTMLTokenizer::create(m_options);
}
@@ -1012,7 +1010,7 @@ void HTMLDocumentParser::appendBytes(const char* data, size_t length)
if (!m_haveBackgroundParser)
startBackgroundParser();
- std::unique_ptr<Vector<char>> buffer = wrapUnique(new Vector<char>(length));
+ OwnPtr<Vector<char>> buffer = adoptPtr(new Vector<char>(length));
memcpy(buffer->data(), data, length);
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "HTMLDocumentParser::appendBytes", "size", (unsigned)length);
@@ -1034,7 +1032,7 @@ void HTMLDocumentParser::flush()
// appendBytes. Fallback to synchronous parsing in that case.
if (!m_haveBackgroundParser) {
m_shouldUseThreading = false;
- m_token = wrapUnique(new HTMLToken);
+ m_token = adoptPtr(new HTMLToken);
m_tokenizer = HTMLTokenizer::create(m_options);
DecodedDataDocumentParser::flush();
return;
@@ -1046,7 +1044,7 @@ void HTMLDocumentParser::flush()
}
}
-void HTMLDocumentParser::setDecoder(std::unique_ptr<TextResourceDecoder> decoder)
+void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder)
{
ASSERT(decoder);
DecodedDataDocumentParser::setDecoder(std::move(decoder));
@@ -1068,7 +1066,7 @@ void HTMLDocumentParser::documentElementAvailable()
m_preloader->takeAndPreload(m_queuedPreloads);
}
-std::unique_ptr<HTMLPreloadScanner> HTMLDocumentParser::createPreloadScanner()
+PassOwnPtr<HTMLPreloadScanner> HTMLDocumentParser::createPreloadScanner()
{
return HTMLPreloadScanner::create(
m_options,
@@ -1095,7 +1093,7 @@ void HTMLDocumentParser::evaluateAndPreloadScriptForDocumentWrite(const String&
double duration = monotonicallyIncreasingTimeMS() - startTime;
int currentPreloadCount = document()->loader()->fetcher()->countPreloads();
- std::unique_ptr<HTMLPreloadScanner> scanner = createPreloadScanner();
+ OwnPtr<HTMLPreloadScanner> scanner = createPreloadScanner();
scanner->appendToEnd(SegmentedString(writtenSource));
scanner->scanAndPreload(m_preloader.get(), document()->baseElementURL(), nullptr);
int numPreloads = document()->loader()->fetcher()->countPreloads() - currentPreloadCount;

Powered by Google App Engine
This is Rietveld 408576698