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

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

Issue 863113004: Make WebThreadedDataReceiver wrap a Blink-managed object instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix msvc compilation Created 5 years, 11 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: Source/core/html/parser/HTMLDocumentParser.cpp
diff --git a/Source/core/html/parser/HTMLDocumentParser.cpp b/Source/core/html/parser/HTMLDocumentParser.cpp
index 8d3cd6f7db2dddf05b4ebbd6515430a12e49edf2..738a0c6425d634b02e25e678d96dec54373c57ca 100644
--- a/Source/core/html/parser/HTMLDocumentParser.cpp
+++ b/Source/core/html/parser/HTMLDocumentParser.cpp
@@ -39,13 +39,15 @@
#include "core/html/parser/HTMLParserThread.h"
#include "core/html/parser/HTMLScriptRunner.h"
#include "core/html/parser/HTMLTreeBuilder.h"
+#include "core/html/parser/ThreadedDataReceiver.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/InspectorTraceEvents.h"
#include "core/loader/DocumentLoader.h"
#include "platform/SharedBuffer.h"
#include "platform/TraceEvent.h"
-#include "public/platform/WebThreadedDataReceiver.h"
+#include "platform/heap/Handle.h"
#include "wtf/Functional.h"
+#include "wtf/RefCounted.h"
#include "wtf/TemporaryChange.h"
namespace blink {
@@ -77,23 +79,28 @@ static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem
return HTMLTokenizer::DataState;
}
-class ParserDataReceiver : public WebThreadedDataReceiver, public DocumentLifecycleObserver {
+class ParserDataReceiver final : public RefCountedWillBeGarbageCollectedFinalized<ParserDataReceiver>, public ThreadedDataReceiver, public DocumentLifecycleObserver {
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ParserDataReceiver);
public:
- explicit ParserDataReceiver(WeakPtr<BackgroundHTMLParser> backgroundParser, Document* document)
- : DocumentLifecycleObserver(document)
- , m_backgroundParser(backgroundParser)
+ static PassRefPtrWillBeRawPtr<ParserDataReceiver> create(WeakPtr<BackgroundHTMLParser> backgroundParser, Document* document)
{
+ return adoptRefWillBeNoop(new ParserDataReceiver(backgroundParser, document));
}
- // WebThreadedDataReceiver
- virtual void acceptData(const char* data, int dataLength) override final
+#if !ENABLE(OILPAN)
+ virtual void ref() override { RefCounted<ParserDataReceiver>::ref(); }
+ virtual void deref() override { RefCounted<ParserDataReceiver>::deref(); }
+#endif
+
+ // ThreadedDataReceiver
+ void acceptData(const char* data, int dataLength) override
{
ASSERT(backgroundThread() && backgroundThread()->isCurrentThread());
if (m_backgroundParser.get())
m_backgroundParser.get()->appendRawBytesFromParserThread(data, dataLength);
}
- virtual blink::WebThread* backgroundThread() override final
+ WebThread* backgroundThread() override
{
if (HTMLParserThread::shared())
return &HTMLParserThread::shared()->platformThread();
@@ -101,15 +108,26 @@ public:
return nullptr;
}
- virtual bool needsMainthreadDataCopy() override final { return InspectorInstrumentation::hasFrontends(); }
- virtual void acceptMainthreadDataNotification(const char* data, int dataLength, int encodedDataLength) override final
+ bool needsMainthreadDataCopy() override { return InspectorInstrumentation::hasFrontends(); }
+ void acceptMainthreadDataNotification(const char* data, int dataLength, int encodedDataLength) override
{
ASSERT(!data || needsMainthreadDataCopy());
if (lifecycleContext())
lifecycleContext()->loader()->acceptDataFromThreadedReceiver(data, dataLength, encodedDataLength);
}
+ void trace(Visitor* visitor) override
+ {
+ DocumentLifecycleObserver::trace(visitor);
+ }
+
private:
+ ParserDataReceiver(WeakPtr<BackgroundHTMLParser> backgroundParser, Document* document)
+ : DocumentLifecycleObserver(document)
+ , m_backgroundParser(backgroundParser)
+ {
+ }
+
WeakPtr<BackgroundHTMLParser> m_backgroundParser;
};
@@ -755,7 +773,7 @@ void HTMLDocumentParser::startBackgroundParser()
// FIXME(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, document()->contextDocument().get())));
+ loader->attachThreadedDataReceiver(ParserDataReceiver::create(m_backgroundParser, document()->contextDocument().get()));
}
OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new BackgroundHTMLParser::Configuration);

Powered by Google App Engine
This is Rietveld 408576698