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

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

Issue 2242223003: Preload tokens even if a <meta> csp tag is found (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix up layout test Created 4 years, 4 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: third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.h
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.h b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.h
index 84a12b1b2b83237923cff750cd9b0edfbdbaec63..edd51cd1494e08816c273ae9ae3a78c706efe382 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.h
+++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.h
@@ -113,6 +113,12 @@ public:
bool startingScript;
// Indices into |tokens|.
Vector<int> likelyDocumentWriteScriptIndices;
+ // Index into |tokens| of the last <meta> csp tag in |tokens|. Preloads
+ // will be deferred until this token is parsed. Will be
+ // noPendingToken if there are no csp tokens.
+ int pendingCSPMetaTokenIndex;
+
+ static constexpr int noPendingToken = -1;
};
void notifyPendingTokenizedChunks();
void didReceiveEncodingDataFromBackgroundParser(const DocumentEncodingData&);
@@ -186,7 +192,8 @@ private:
std::unique_ptr<HTMLPreloadScanner> createPreloadScanner();
- int preloadInsertion(const SegmentedString& source);
+ void fetchQueuedPreloads();
+
void evaluateAndPreloadScriptForDocumentWrite(const String& source);
// Temporary enum for the ParseHTMLOnMainThread experiment. This is used to
@@ -235,6 +242,15 @@ private:
RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue;
std::unique_ptr<DocumentWriteEvaluator> m_evaluator;
+ // If this is non-null, then there is a meta CSP token somewhere in the
+ // speculation buffer. Preloads will be deferred until a token matching this
+ // pointer is parsed and the CSP policy is applied. Note that this pointer
+ // tracks the *last* meta token in the speculation buffer, so it
+ // overestimates how long to defer preloads. This is for simplicity, as the
+ // alternative would require keeping track of token positions of preload
+ // requests.
+ CompactHTMLToken* m_pendingCSPMetaToken;
+
bool m_shouldUseThreading;
bool m_endWasDelayed;
bool m_haveBackgroundParser;

Powered by Google App Engine
This is Rietveld 408576698