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

Side by Side Diff: third_party/WebKit/Source/core/dom/ScriptLoader.h

Issue 2260303002: Sending an async GET request for doc.written blocked scripts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Windows compile error for GetResourcePriority return type fixed. Created 4 years, 3 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) 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 void handleAsyncAttribute(); 84 void handleAsyncAttribute();
85 85
86 virtual bool isReady() const { return m_pendingScript && m_pendingScript->is Ready(); } 86 virtual bool isReady() const { return m_pendingScript && m_pendingScript->is Ready(); }
87 bool errorOccurred() const { return m_pendingScript && m_pendingScript->erro rOccurred(); } 87 bool errorOccurred() const { return m_pendingScript && m_pendingScript->erro rOccurred(); }
88 88
89 // Clears the connection to the PendingScript (and Element and Resource). 89 // Clears the connection to the PendingScript (and Element and Resource).
90 void detach(); 90 void detach();
91 91
92 bool wasCreatedDuringDocumentWrite() { return m_createdDuringDocumentWrite; } 92 bool wasCreatedDuringDocumentWrite() { return m_createdDuringDocumentWrite; }
93 93
94 bool disallowedFetchForDocWrittenScript() { return m_documentWriteInterventi on == DocumentWriteIntervention::DoNotFetchDocWrittenScript; }
95 void setFetchDocWrittenScriptDeferIdle();
96
94 protected: 97 protected:
95 ScriptLoader(Element*, bool createdByParser, bool isEvaluated, bool createdD uringDocumentWrite); 98 ScriptLoader(Element*, bool createdByParser, bool isEvaluated, bool createdD uringDocumentWrite);
96 99
97 private: 100 private:
98 bool ignoresLoadRequest() const; 101 bool ignoresLoadRequest() const;
99 bool isScriptForEventSupported() const; 102 bool isScriptForEventSupported() const;
100 void logScriptMimetype(ScriptResource*, LocalFrame*, String); 103 void logScriptMimetype(ScriptResource*, LocalFrame*, String);
101 104
102 bool fetchScript(const String& sourceUrl, FetchRequest::DeferOption); 105 bool fetchScript(const String& sourceUrl, FetchRequest::DeferOption);
103 bool doExecuteScript(const ScriptSourceCode&); 106 bool doExecuteScript(const ScriptSourceCode&);
(...skipping 14 matching lines...) Expand all
118 bool m_isExternalScript : 1; 121 bool m_isExternalScript : 1;
119 bool m_alreadyStarted : 1; 122 bool m_alreadyStarted : 1;
120 bool m_haveFiredLoad : 1; 123 bool m_haveFiredLoad : 1;
121 bool m_willBeParserExecuted : 1; // Same as "The parser will handle executin g the script." 124 bool m_willBeParserExecuted : 1; // Same as "The parser will handle executin g the script."
122 bool m_readyToBeParserExecuted : 1; 125 bool m_readyToBeParserExecuted : 1;
123 bool m_willExecuteWhenDocumentFinishedParsing : 1; 126 bool m_willExecuteWhenDocumentFinishedParsing : 1;
124 bool m_forceAsync : 1; 127 bool m_forceAsync : 1;
125 const bool m_createdDuringDocumentWrite : 1; 128 const bool m_createdDuringDocumentWrite : 1;
126 129
127 ScriptRunner::AsyncExecutionType m_asyncExecType; 130 ScriptRunner::AsyncExecutionType m_asyncExecType;
131 enum DocumentWriteIntervention {
132 DocumentWriteInterventionNone = 0,
133 // Based on what shouldDisallowFetchForMainFrameScript() returns.
134 // This script will be blocked if not present in http cache.
135 DoNotFetchDocWrittenScript,
136 // If a parser blocking doc.written script was not fetched and was not
137 // present in the http cache, send a GET for it with an interventions
138 // header to allow the server to know of the intervention. This fetch
139 // will be using DeferOption::IdleLoad to keep it out of the critical
140 // path.
141 FetchDocWrittenScriptDeferIdle,
142 };
143
144 DocumentWriteIntervention m_documentWriteIntervention;
128 145
129 Member<PendingScript> m_pendingScript; 146 Member<PendingScript> m_pendingScript;
130 }; 147 };
131 148
132 ScriptLoader* toScriptLoaderIfPossible(Element*); 149 ScriptLoader* toScriptLoaderIfPossible(Element*);
133 150
134 } // namespace blink 151 } // namespace blink
135 152
136 #endif // ScriptLoader_h 153 #endif // ScriptLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698