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

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: Test added, failed bot tests fixed, converted to enum. 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 21 matching lines...) Expand all
32 namespace blink { 32 namespace blink {
33 33
34 class Element; 34 class Element;
35 class ScriptLoaderClient; 35 class ScriptLoaderClient;
36 class ScriptSourceCode; 36 class ScriptSourceCode;
37 class LocalFrame; 37 class LocalFrame;
38 38
39 class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>, public ScriptResourceClient { 39 class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>, public ScriptResourceClient {
40 USING_GARBAGE_COLLECTED_MIXIN(ScriptLoader); 40 USING_GARBAGE_COLLECTED_MIXIN(ScriptLoader);
41 public: 41 public:
42 static ScriptLoader* create(Element* element, bool createdByParser, bool isE valuated, bool createdDuringDocumentWrite = false) 42 static ScriptLoader* create(Element* element, bool createdByParser, bool isE valuated, bool createdDuringDocumentWrite = false, bool blockedDocWriteScriptAsy ncFetch = false)
Nate Chapin 2016/08/22 19:47:03 Rather than adding another boolean parameter to a
shivanisha 2016/08/22 20:44:00 Done.
43 { 43 {
44 return new ScriptLoader(element, createdByParser, isEvaluated, createdDu ringDocumentWrite); 44 return new ScriptLoader(element, createdByParser, isEvaluated, createdDu ringDocumentWrite, blockedDocWriteScriptAsyncFetch);
45 } 45 }
46 46
47 ~ScriptLoader() override; 47 ~ScriptLoader() override;
48 DECLARE_VIRTUAL_TRACE(); 48 DECLARE_VIRTUAL_TRACE();
49 49
50 Element* element() const { return m_element; } 50 Element* element() const { return m_element; }
51 51
52 enum LegacyTypeSupport { DisallowLegacyTypeInTypeAttribute, AllowLegacyTypeI nTypeAttribute }; 52 enum LegacyTypeSupport { DisallowLegacyTypeInTypeAttribute, AllowLegacyTypeI nTypeAttribute };
53 bool prepareScript(const TextPosition& scriptStartPosition = TextPosition::m inimumPosition(), LegacyTypeSupport = DisallowLegacyTypeInTypeAttribute); 53 bool prepareScript(const TextPosition& scriptStartPosition = TextPosition::m inimumPosition(), LegacyTypeSupport = DisallowLegacyTypeInTypeAttribute);
54 54
(...skipping 26 matching lines...) Expand all
81 void handleAsyncAttribute(); 81 void handleAsyncAttribute();
82 82
83 virtual bool isReady() const { return m_pendingScript && m_pendingScript->is Ready(); } 83 virtual bool isReady() const { return m_pendingScript && m_pendingScript->is Ready(); }
84 bool errorOccurred() const { return m_pendingScript && m_pendingScript->erro rOccurred(); } 84 bool errorOccurred() const { return m_pendingScript && m_pendingScript->erro rOccurred(); }
85 85
86 // Clears the connection to the PendingScript (and Element and Resource). 86 // Clears the connection to the PendingScript (and Element and Resource).
87 void detach(); 87 void detach();
88 88
89 bool wasCreatedDuringDocumentWrite() { return m_createdDuringDocumentWrite; } 89 bool wasCreatedDuringDocumentWrite() { return m_createdDuringDocumentWrite; }
90 90
91 bool disallowedFetchForDocWrittenScript() { return m_documentWriteInterventi on == DocumentWriteIntervention::DisallowedFetchForDocWrittenScript; }
92
91 protected: 93 protected:
92 ScriptLoader(Element*, bool createdByParser, bool isEvaluated, bool createdD uringDocumentWrite); 94 ScriptLoader(Element*, bool createdByParser, bool isEvaluated, bool createdD uringDocumentWrite, bool blockedDocWriteScriptAsyncFetch);
93 95
94 private: 96 private:
95 bool ignoresLoadRequest() const; 97 bool ignoresLoadRequest() const;
96 bool isScriptForEventSupported() const; 98 bool isScriptForEventSupported() const;
97 void logScriptMimetype(ScriptResource*, LocalFrame*, String); 99 void logScriptMimetype(ScriptResource*, LocalFrame*, String);
98 100
99 bool fetchScript(const String& sourceUrl, FetchRequest::DeferOption); 101 bool fetchScript(const String& sourceUrl, FetchRequest::DeferOption);
100 102
101 ScriptLoaderClient* client() const; 103 ScriptLoaderClient* client() const;
102 104
(...skipping 11 matching lines...) Expand all
114 bool m_isExternalScript : 1; 116 bool m_isExternalScript : 1;
115 bool m_alreadyStarted : 1; 117 bool m_alreadyStarted : 1;
116 bool m_haveFiredLoad : 1; 118 bool m_haveFiredLoad : 1;
117 bool m_willBeParserExecuted : 1; // Same as "The parser will handle executin g the script." 119 bool m_willBeParserExecuted : 1; // Same as "The parser will handle executin g the script."
118 bool m_readyToBeParserExecuted : 1; 120 bool m_readyToBeParserExecuted : 1;
119 bool m_willExecuteInOrder : 1; 121 bool m_willExecuteInOrder : 1;
120 bool m_willExecuteWhenDocumentFinishedParsing : 1; 122 bool m_willExecuteWhenDocumentFinishedParsing : 1;
121 bool m_forceAsync : 1; 123 bool m_forceAsync : 1;
122 const bool m_createdDuringDocumentWrite : 1; 124 const bool m_createdDuringDocumentWrite : 1;
123 125
126 enum DocumentWriteIntervention {
127 DocumentWriteInterventionNone = 0,
128 // Based on what shouldDisallowFetchForMainFrameScript() returns.
129 // This script will be blocked if not present in http cache.
130 DisallowedFetchForDocWrittenScript,
131 // Is it a fetch (non parser-blocking, lowest priority) for the blocked script.
132 AsyncLowPriorityFetchForBlockedScript,
133 };
134
135 DocumentWriteIntervention m_documentWriteIntervention;
136
124 Member<PendingScript> m_pendingScript; 137 Member<PendingScript> m_pendingScript;
125 }; 138 };
126
Nate Chapin 2016/08/22 19:47:03 Why these deletes?
shivanisha 2016/08/22 20:44:00 reverted.
127 ScriptLoader* toScriptLoaderIfPossible(Element*); 139 ScriptLoader* toScriptLoaderIfPossible(Element*);
128
129 } // namespace blink 140 } // namespace blink
130 141
131 #endif // ScriptLoader_h 142 #endif // ScriptLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698