Index: Source/core/html/parser/HTMLDocumentParser.cpp |
diff --git a/Source/core/html/parser/HTMLDocumentParser.cpp b/Source/core/html/parser/HTMLDocumentParser.cpp |
index 210185ef31d373e7382b9358cf672412d8a6b671..470ea4baa36d7813d8cb3a974277213a628db21f 100644 |
--- a/Source/core/html/parser/HTMLDocumentParser.cpp |
+++ b/Source/core/html/parser/HTMLDocumentParser.cpp |
@@ -38,8 +38,10 @@ |
#include "core/html/parser/HTMLScriptRunner.h" |
#include "core/html/parser/HTMLTreeBuilder.h" |
#include "core/inspector/InspectorInstrumentation.h" |
+#include "core/loader/DocumentLoader.h" |
#include "platform/SharedBuffer.h" |
#include "platform/TraceEvent.h" |
+#include "public/platform/WebThreadedDataReceiver.h" |
#include "wtf/Functional.h" |
namespace WebCore { |
@@ -71,6 +73,30 @@ static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem |
return HTMLTokenizer::DataState; |
} |
+class ParserDataReceiver : public blink::WebThreadedDataReceiver { |
+public: |
+ ParserDataReceiver(WeakPtr<BackgroundHTMLParser> backgroundParser) |
abarth-chromium
2014/03/10 21:52:20
Please make one-argument constructors explicit.
oystein (OOO til 10th of July)
2014/03/17 21:19:11
Done.
|
+ : m_backgroundParser(backgroundParser) |
+ { |
+ } |
+ |
+ // WebThreadedDataReceiver |
+ virtual void acceptData(const char* data, int dataLength) OVERRIDE FINAL |
+ { |
+ ASSERT(backgroundThread()->isCurrentThread()); |
+ if (m_backgroundParser.get()) |
+ m_backgroundParser.get()->acceptData(data, dataLength); |
+ } |
+ |
+ virtual blink::WebThread* backgroundThread() OVERRIDE FINAL |
+ { |
+ return &HTMLParserThread::shared()->ensureThread(); |
+ } |
+ |
+private: |
+ WeakPtr<BackgroundHTMLParser> m_backgroundParser; |
+}; |
+ |
HTMLDocumentParser::HTMLDocumentParser(HTMLDocument* document, bool reportErrors) |
: ScriptableDocumentParser(document) |
, m_options(document) |
@@ -667,6 +693,8 @@ void HTMLDocumentParser::startBackgroundParser() |
RefPtr<WeakReference<BackgroundHTMLParser> > reference = WeakReference<BackgroundHTMLParser>::createUnbound(); |
m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); |
+ document()->loader()->attachThreadedDataReceiver(new ParserDataReceiver(m_backgroundParser)); |
abarth-chromium
2014/03/10 21:52:20
adoptPtr(new ParserDataReceiver(...
oystein (OOO til 10th of July)
2014/03/17 21:19:11
Done.
|
+ |
OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new BackgroundHTMLParser::Configuration); |
config->options = m_options; |
config->parser = m_weakFactory.createWeakPtr(); |