Chromium Code Reviews| Index: Source/core/html/parser/HTMLDocumentParser.cpp |
| diff --git a/Source/core/html/parser/HTMLDocumentParser.cpp b/Source/core/html/parser/HTMLDocumentParser.cpp |
| index 6ee8405790d03f3d313f37d2118ab19068f20724..8c4454ba3f3d106b6ae7c712dcc303f95dc58902 100644 |
| --- a/Source/core/html/parser/HTMLDocumentParser.cpp |
| +++ b/Source/core/html/parser/HTMLDocumentParser.cpp |
| @@ -75,11 +75,13 @@ static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem |
| return HTMLTokenizer::DataState; |
| } |
| -class ParserDataReceiver : public blink::WebThreadedDataReceiver { |
| +class ParserDataReceiver : public WebThreadedDataReceiver { |
| public: |
| - explicit ParserDataReceiver(WeakPtr<BackgroundHTMLParser> backgroundParser) |
| + explicit ParserDataReceiver(WeakPtr<BackgroundHTMLParser> backgroundParser, WeakPtrWillBeRawPtr<Document> document) |
| : m_backgroundParser(backgroundParser) |
| + , m_document(document) |
| { |
| + m_needMainthreadDataCopy = InspectorInstrumentation::hasFrontends(); |
|
yurys
2014/11/12 06:47:09
It is safe to read InspectorInstrumentation::hasFr
oystein (OOO til 10th of July)
2014/11/17 18:41:42
Done.
|
| } |
| // WebThreadedDataReceiver |
| @@ -98,8 +100,18 @@ public: |
| return 0; |
| } |
| + virtual bool needsMainthreadDataCopy() override final { return m_needMainthreadDataCopy; } |
| + virtual void acceptMainthreadDataNotification(const char* data, int dataLength, int encodedDataLength) override final |
| + { |
| + ASSERT(!data || m_needMainthreadDataCopy); |
| + if (m_document.get()) |
| + m_document.get()->loader()->acceptDataFromThreadedReceiver(data, dataLength, encodedDataLength); |
| + } |
| + |
| private: |
| WeakPtr<BackgroundHTMLParser> m_backgroundParser; |
| + WeakPtrWillBeRawPtr<Document> m_document; |
| + bool m_needMainthreadDataCopy; |
| }; |
| HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors) |
| @@ -712,7 +724,7 @@ void HTMLDocumentParser::startBackgroundParser() |
| // TODO(oysteine): Disabled due to crbug.com/398076 until a full fix can be implemented. |
| if (RuntimeEnabledFeatures::threadedParserDataReceiverEnabled()) { |
| if (DocumentLoader* loader = document()->loader()) |
| - loader->attachThreadedDataReceiver(adoptPtr(new ParserDataReceiver(m_backgroundParser))); |
| + loader->attachThreadedDataReceiver(adoptPtr(new ParserDataReceiver(m_backgroundParser, document()->contextDocument()))); |
| } |
| OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new BackgroundHTMLParser::Configuration); |