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

Unified Diff: third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.h

Issue 2695633007: Revert of Put the BackgroundHTMLParser on oilpan heap (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.h
diff --git a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.h b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.h
index 4428a0e451b19fd9273e3f9c08b5d644a044795d..b2016554e2df5a4eaa1875b75265a45797cc6d8c 100644
--- a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.h
+++ b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.h
@@ -26,7 +26,6 @@
#ifndef BackgroundHTMLParser_h
#define BackgroundHTMLParser_h
-#include <memory>
#include "core/dom/DocumentEncodingData.h"
#include "core/html/parser/BackgroundHTMLInputStream.h"
#include "core/html/parser/CompactHTMLToken.h"
@@ -35,9 +34,10 @@
#include "core/html/parser/HTMLSourceTracker.h"
#include "core/html/parser/HTMLTreeBuilderSimulator.h"
#include "core/html/parser/TextResourceDecoder.h"
+#include "core/html/parser/TokenizedChunkQueue.h"
#include "core/html/parser/XSSAuditorDelegate.h"
-#include "platform/heap/GarbageCollected.h"
#include "wtf/WeakPtr.h"
+#include <memory>
namespace blink {
@@ -45,8 +45,8 @@
class XSSAuditor;
class WebTaskRunner;
-class BackgroundHTMLParser
- : public GarbageCollectedFinalized<BackgroundHTMLParser> {
+class BackgroundHTMLParser {
+ USING_FAST_MALLOC(BackgroundHTMLParser);
WTF_MAKE_NONCOPYABLE(BackgroundHTMLParser);
public:
@@ -56,8 +56,10 @@
public:
Configuration();
HTMLParserOptions options;
+ WeakPtr<HTMLDocumentParser> parser;
std::unique_ptr<XSSAuditor> xssAuditor;
std::unique_ptr<TextResourceDecoder> decoder;
+ RefPtr<TokenizedChunkQueue> tokenizedChunkQueue;
// outstandingTokenLimit must be greater than or equal to
// pendingTokenLimit
size_t outstandingTokenLimit;
@@ -65,12 +67,14 @@
bool shouldCoalesceChunks;
};
- static BackgroundHTMLParser* create(HTMLDocumentParser*,
- Document&,
- std::unique_ptr<Configuration>);
- ~BackgroundHTMLParser();
-
- DECLARE_TRACE();
+ // The returned BackgroundHTMLParser should only be used on the parser
+ // thread: it must first be initialized by calling init(), and free by
+ // calling stop().
+ static WeakPtr<BackgroundHTMLParser> create(std::unique_ptr<Configuration>,
+ RefPtr<WebTaskRunner>);
+ void init(const KURL& documentURL,
+ std::unique_ptr<CachedDocumentParameters>,
+ const MediaValuesCached::MediaValuesCachedData&);
struct Checkpoint {
USING_FAST_MALLOC(Checkpoint);
@@ -92,20 +96,17 @@
void resumeFrom(std::unique_ptr<Checkpoint>);
void startedChunkWithCheckpoint(HTMLInputCheckpoint);
void finish();
+ void stop();
void forcePlaintextForTextDocument();
+
private:
- BackgroundHTMLParser(HTMLDocumentParser*,
- std::unique_ptr<Configuration>,
- RefPtr<WebTaskRunner>,
- std::unique_ptr<TokenPreloadScanner>);
+ BackgroundHTMLParser(std::unique_ptr<Configuration>, RefPtr<WebTaskRunner>);
+ ~BackgroundHTMLParser();
void appendDecodedBytes(const String&);
void markEndOfFile();
void pumpTokenizer();
-
- void onResumeFrom(std::unique_ptr<Checkpoint>);
- void onFinish();
// Returns whether or not the HTMLDocumentParser should be notified of
// pending chunks.
@@ -113,6 +114,10 @@
void notifyMainThreadOfNewChunks();
void updateDocument(const String& decodedData);
+ template <typename FunctionType, typename... Ps>
+ void runOnMainThread(FunctionType, Ps&&...);
+
+ WeakPtrFactory<BackgroundHTMLParser> m_weakFactory;
BackgroundHTMLInputStream m_input;
HTMLSourceTracker m_sourceTracker;
std::unique_ptr<HTMLToken> m_token;
@@ -120,7 +125,7 @@
HTMLTreeBuilderSimulator m_treeBuilderSimulator;
HTMLParserOptions m_options;
const size_t m_outstandingTokenLimit;
- Member<HTMLDocumentParser> m_parser;
+ WeakPtr<HTMLDocumentParser> m_parser;
std::unique_ptr<CompactHTMLTokenStream> m_pendingTokens;
const size_t m_pendingTokenLimit;
@@ -135,6 +140,7 @@
std::unique_ptr<TextResourceDecoder> m_decoder;
DocumentEncodingData m_lastSeenEncodingData;
RefPtr<WebTaskRunner> m_loadingTaskRunner;
+ RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue;
// Index into |m_pendingTokens| of the last <meta> csp token found. Will be
// |TokenizedChunk::noPendingToken| if none have been found.
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698