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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.h

Issue 2683653004: Put the BackgroundHTMLParser on oilpan heap (Closed)
Patch Set: Save ASSERT->DCHECK for another patch 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 class HTMLPreloadScanner; 64 class HTMLPreloadScanner;
65 class HTMLResourcePreloader; 65 class HTMLResourcePreloader;
66 class HTMLTreeBuilder; 66 class HTMLTreeBuilder;
67 class SegmentedString; 67 class SegmentedString;
68 class TokenizedChunkQueue; 68 class TokenizedChunkQueue;
69 class DocumentWriteEvaluator; 69 class DocumentWriteEvaluator;
70 70
71 class CORE_EXPORT HTMLDocumentParser : public ScriptableDocumentParser, 71 class CORE_EXPORT HTMLDocumentParser : public ScriptableDocumentParser,
72 private HTMLParserScriptRunnerHost { 72 private HTMLParserScriptRunnerHost {
73 USING_GARBAGE_COLLECTED_MIXIN(HTMLDocumentParser); 73 USING_GARBAGE_COLLECTED_MIXIN(HTMLDocumentParser);
74 USING_PRE_FINALIZER(HTMLDocumentParser, dispose);
75 74
76 public: 75 public:
77 static HTMLDocumentParser* create( 76 static HTMLDocumentParser* create(
78 HTMLDocument& document, 77 HTMLDocument& document,
79 ParserSynchronizationPolicy backgroundParsingPolicy) { 78 ParserSynchronizationPolicy backgroundParsingPolicy) {
80 return new HTMLDocumentParser(document, backgroundParsingPolicy); 79 return new HTMLDocumentParser(document, backgroundParsingPolicy);
81 } 80 }
82 ~HTMLDocumentParser() override; 81 ~HTMLDocumentParser() override;
83 DECLARE_VIRTUAL_TRACE(); 82 DECLARE_VIRTUAL_TRACE();
84 83
85 // TODO(alexclarke): Remove when background parser goes away.
86 void dispose();
87
88 // Exposed for HTMLParserScheduler 84 // Exposed for HTMLParserScheduler
89 void resumeParsingAfterYield(); 85 void resumeParsingAfterYield();
90 86
91 static void parseDocumentFragment( 87 static void parseDocumentFragment(
92 const String&, 88 const String&,
93 DocumentFragment*, 89 DocumentFragment*,
94 Element* contextElement, 90 Element* contextElement,
95 ParserContentPolicy = AllowScriptingContent); 91 ParserContentPolicy = AllowScriptingContent);
96 92
97 // Exposed for testing. 93 // Exposed for testing.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 178
183 // HTMLParserScriptRunnerHost 179 // HTMLParserScriptRunnerHost
184 void notifyScriptLoaded(PendingScript*) final; 180 void notifyScriptLoaded(PendingScript*) final;
185 HTMLInputStream& inputStream() final { return m_input; } 181 HTMLInputStream& inputStream() final { return m_input; }
186 bool hasPreloadScanner() const final { 182 bool hasPreloadScanner() const final {
187 return m_preloadScanner.get() && !shouldUseThreading(); 183 return m_preloadScanner.get() && !shouldUseThreading();
188 } 184 }
189 void appendCurrentInputStreamToPreloadScannerAndScan() final; 185 void appendCurrentInputStreamToPreloadScannerAndScan() final;
190 186
191 void startBackgroundParser(); 187 void startBackgroundParser();
192 void stopBackgroundParser();
193 void validateSpeculations(std::unique_ptr<TokenizedChunk> lastChunk); 188 void validateSpeculations(std::unique_ptr<TokenizedChunk> lastChunk);
194 void discardSpeculationsAndResumeFrom( 189 void discardSpeculationsAndResumeFrom(
195 std::unique_ptr<TokenizedChunk> lastChunk, 190 std::unique_ptr<TokenizedChunk> lastChunk,
196 std::unique_ptr<HTMLToken>, 191 std::unique_ptr<HTMLToken>,
197 std::unique_ptr<HTMLTokenizer>); 192 std::unique_ptr<HTMLTokenizer>);
198 size_t processTokenizedChunkFromBackgroundParser( 193 size_t processTokenizedChunkFromBackgroundParser(
199 std::unique_ptr<TokenizedChunk>); 194 std::unique_ptr<TokenizedChunk>);
200 void pumpPendingSpeculations(); 195 void pumpPendingSpeculations();
201 196
202 bool canTakeNextToken(); 197 bool canTakeNextToken();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 235
241 std::unique_ptr<HTMLToken> m_token; 236 std::unique_ptr<HTMLToken> m_token;
242 std::unique_ptr<HTMLTokenizer> m_tokenizer; 237 std::unique_ptr<HTMLTokenizer> m_tokenizer;
243 Member<HTMLParserScriptRunner> m_scriptRunner; 238 Member<HTMLParserScriptRunner> m_scriptRunner;
244 Member<HTMLTreeBuilder> m_treeBuilder; 239 Member<HTMLTreeBuilder> m_treeBuilder;
245 240
246 std::unique_ptr<HTMLPreloadScanner> m_preloadScanner; 241 std::unique_ptr<HTMLPreloadScanner> m_preloadScanner;
247 // A scanner used only for input provided to the insert() method. 242 // A scanner used only for input provided to the insert() method.
248 std::unique_ptr<HTMLPreloadScanner> m_insertionPreloadScanner; 243 std::unique_ptr<HTMLPreloadScanner> m_insertionPreloadScanner;
249 244
250 RefPtr<WebTaskRunner> m_loadingTaskRunner;
251 Member<HTMLParserScheduler> m_parserScheduler; 245 Member<HTMLParserScheduler> m_parserScheduler;
252 HTMLSourceTracker m_sourceTracker; 246 HTMLSourceTracker m_sourceTracker;
253 TextPosition m_textPosition; 247 TextPosition m_textPosition;
254 XSSAuditor m_xssAuditor; 248 XSSAuditor m_xssAuditor;
255 XSSAuditorDelegate m_xssAuditorDelegate; 249 XSSAuditorDelegate m_xssAuditorDelegate;
256 250
257 // FIXME: m_lastChunkBeforePause, m_tokenizer, m_token, and m_input should be 251 // FIXME: m_lastChunkBeforePause, m_tokenizer, m_token, and m_input should be
258 // combined into a single state object so they can be set and cleared together 252 // combined into a single state object so they can be set and cleared together
259 // and passed between threads together. 253 // and passed between threads together.
260 std::unique_ptr<TokenizedChunk> m_lastChunkBeforePause; 254 std::unique_ptr<TokenizedChunk> m_lastChunkBeforePause;
261 Deque<std::unique_ptr<TokenizedChunk>> m_speculations; 255 Deque<std::unique_ptr<TokenizedChunk>> m_speculations;
262 WeakPtrFactory<HTMLDocumentParser> m_weakFactory; 256 Member<BackgroundHTMLParser> m_backgroundParser;
263 WeakPtr<BackgroundHTMLParser> m_backgroundParser;
264 Member<HTMLResourcePreloader> m_preloader; 257 Member<HTMLResourcePreloader> m_preloader;
265 PreloadRequestStream m_queuedPreloads; 258 PreloadRequestStream m_queuedPreloads;
266 Vector<String> m_queuedDocumentWriteScripts; 259 Vector<String> m_queuedDocumentWriteScripts;
267 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue; 260 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue;
268 std::unique_ptr<DocumentWriteEvaluator> m_evaluator; 261 std::unique_ptr<DocumentWriteEvaluator> m_evaluator;
269 262
270 // If this is non-null, then there is a meta CSP token somewhere in the 263 // If this is non-null, then there is a meta CSP token somewhere in the
271 // speculation buffer. Preloads will be deferred until a token matching this 264 // speculation buffer. Preloads will be deferred until a token matching this
272 // pointer is parsed and the CSP policy is applied. Note that this pointer 265 // pointer is parsed and the CSP policy is applied. Note that this pointer
273 // tracks the *last* meta token in the speculation buffer, so it overestimates 266 // tracks the *last* meta token in the speculation buffer, so it overestimates
274 // how long to defer preloads. This is for simplicity, as the alternative 267 // how long to defer preloads. This is for simplicity, as the alternative
275 // would require keeping track of token positions of preload requests. 268 // would require keeping track of token positions of preload requests.
276 CompactHTMLToken* m_pendingCSPMetaToken; 269 CompactHTMLToken* m_pendingCSPMetaToken;
277 270
278 TaskHandle m_resumeParsingTaskHandle; 271 TaskHandle m_resumeParsingTaskHandle;
279 272
280 bool m_shouldUseThreading; 273 bool m_shouldUseThreading;
281 bool m_endWasDelayed; 274 bool m_endWasDelayed;
282 bool m_haveBackgroundParser;
283 bool m_tasksWereSuspended; 275 bool m_tasksWereSuspended;
284 unsigned m_pumpSessionNestingLevel; 276 unsigned m_pumpSessionNestingLevel;
285 unsigned m_pumpSpeculationsSessionNestingLevel; 277 unsigned m_pumpSpeculationsSessionNestingLevel;
286 bool m_isParsingAtLineNumber; 278 bool m_isParsingAtLineNumber;
287 bool m_triedLoadingLinkHeaders; 279 bool m_triedLoadingLinkHeaders;
288 bool m_addedPendingStylesheetInBody; 280 bool m_addedPendingStylesheetInBody;
289 bool m_isWaitingForStylesheets; 281 bool m_isWaitingForStylesheets;
290 }; 282 };
291 283
292 } // namespace blink 284 } // namespace blink
293 285
294 #endif // HTMLDocumentParser_h 286 #endif // HTMLDocumentParser_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698