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

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

Issue 74513003: Moved text decoding to the parser thread (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@parserthread_step25
Patch Set: Created 7 years, 1 month 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: Source/core/html/parser/HTMLDocumentParser.cpp
diff --git a/Source/core/html/parser/HTMLDocumentParser.cpp b/Source/core/html/parser/HTMLDocumentParser.cpp
index f3a7f49f75121a265fcd27f833d2356e1963e752..5b95cbb4d237bf43af0849ae5b4a032f2ce8aa54 100644
--- a/Source/core/html/parser/HTMLDocumentParser.cpp
+++ b/Source/core/html/parser/HTMLDocumentParser.cpp
@@ -42,6 +42,7 @@
#include "core/html/parser/HTMLTreeBuilder.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/frame/Frame.h"
+#include "platform/SharedBuffer.h"
#include "platform/TraceEvent.h"
#include "wtf/Functional.h"
@@ -319,6 +320,10 @@ void HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<Pa
m_speculations.append(chunk);
pumpPendingSpeculations();
}
+void HTMLDocumentParser::didReceiveEncodingDataFromBackgroundParser(const DocumentEncodingData& data)
abarth-chromium 2013/11/18 06:57:10 Missing a blank line above this line.
oystein (OOO til 10th of July) 2013/11/18 22:18:42 Done.
+{
+ document()->setEncodingData(data);
+}
void HTMLDocumentParser::validateSpeculations(PassOwnPtr<ParsedChunk> chunk)
{
@@ -675,7 +680,8 @@ void HTMLDocumentParser::startBackgroundParser()
ASSERT(config->xssAuditor->isSafeToSendToAnotherThread());
ASSERT(config->preloadScanner->isSafeToSendToAnotherThread());
- HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::create, reference.release(), config.release()));
+ OwnPtr<TextResourceDecoder> decoder = adoptDecoder();
+ HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::create, reference.release(), config.release(), decoder.release()));
}
void HTMLDocumentParser::stopBackgroundParser()
@@ -693,19 +699,9 @@ void HTMLDocumentParser::append(PassRefPtr<StringImpl> inputSource)
if (isStopped())
return;
- if (shouldUseThreading()) {
- if (!m_haveBackgroundParser)
- startBackgroundParser();
-
- ASSERT(inputSource->hasOneRef());
- TRACE_EVENT1("net", "HTMLDocumentParser::append", "size", inputSource->length());
eseidel 2013/11/18 20:07:40 We've lost this trace event now. I'm not sure tha
oystein (OOO til 10th of July) 2013/11/18 22:18:42 Added to appendBytes() now, just in case.
- // NOTE: Important that the String temporary is destroyed before we post the task
- // otherwise the String could call deref() on a StringImpl now owned by the background parser.
- // We would like to ASSERT(closure.arg3()->hasOneRef()) but sadly the args are private.
- Closure closure = bind(&BackgroundHTMLParser::append, m_backgroundParser, String(inputSource));
- HTMLParserThread::shared()->postTask(closure);
- return;
- }
+ // We should never reach this point if we're using a parser thread,
+ // as appendBytes() will directly ship the data to the thread.
+ ASSERT(!shouldUseThreading());
// pumpTokenizer can cause this parser to be detached from the Document,
// but we need to ensure it isn't deleted yet.
@@ -971,4 +967,32 @@ void HTMLDocumentParser::resumeScheduledTasks()
m_parserScheduler->resume();
}
+void HTMLDocumentParser::appendBytes(const char* data, size_t length)
+{
+ if (!length || isDetached())
+ return;
+
+ if (shouldUseThreading()) {
+ if (!m_haveBackgroundParser)
+ startBackgroundParser();
+
+ HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::appendBytes, m_backgroundParser, SharedBuffer::create(data, length)));
abarth-chromium 2013/11/18 06:57:10 Why a SharedBuffer and not just a Vector? It's to
oystein (OOO til 10th of July) 2013/11/18 22:18:42 I didn't see any other buffer classes when I looke
+ return;
+ }
+
+ DecodedDataDocumentParser::appendBytes(data, length);
+}
+
+void HTMLDocumentParser::flush()
+{
+ // If we've got no decoder, we never received any data.
+ if (isDetached() || needsDecoder())
+ return;
+
+ if (m_haveBackgroundParser)
+ HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::flush, m_backgroundParser));
+ else
+ DecodedDataDocumentParser::flush();
+}
+
}
« Source/core/html/parser/HTMLDocumentParser.h ('K') | « Source/core/html/parser/HTMLDocumentParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698