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

Unified Diff: third_party/WebKit/Source/core/dom/ScriptLoader.h

Issue 2541613002: DO NOT SUBMIT: Sketching out ScriptLoader::executeScriptAsync.
Patch Set: . Created 4 years 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/dom/ScriptLoader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/ScriptLoader.h
diff --git a/third_party/WebKit/Source/core/dom/ScriptLoader.h b/third_party/WebKit/Source/core/dom/ScriptLoader.h
index abad9d2e1bf80eaed356e00aa7b3c7637c989441..5eb3c0992dbe1e36bc51e32ed6d55925dd2908b5 100644
--- a/third_party/WebKit/Source/core/dom/ScriptLoader.h
+++ b/third_party/WebKit/Source/core/dom/ScriptLoader.h
@@ -24,14 +24,17 @@
#include "core/CoreExport.h"
#include "core/dom/PendingScript.h"
#include "core/dom/ScriptRunner.h"
+#include "core/fetch/AccessControlStatus.h"
#include "core/fetch/FetchRequest.h"
#include "core/fetch/ResourceClient.h"
#include "core/loader/resource/ScriptResource.h"
+#include "wtf/Functional.h"
#include "wtf/text/TextPosition.h"
#include "wtf/text/WTFString.h"
namespace blink {
+class CompiledScript;
class Element;
class ScriptLoaderClient;
class ScriptSourceCode;
@@ -70,8 +73,21 @@ class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>,
String scriptCharset() const { return m_characterEncoding; }
String scriptContent() const;
+
// Returns false if and only if execution was blocked.
bool executeScript(const ScriptSourceCode&);
+
+ // Similar to executeScript, except that the actual execution of the script
+ // may be scheduled to run asynchronously. The provided callback will be
+ // invoked immediately after execution completes (or immediately, if there is
+ // nothing to do), with true iff the execution completed without error
+ // (including if there is nothing to do). Only policy errors (that should
+ // produce an error event) are reported this way; compile errors are still OK.
+ using ExecuteScriptAsyncCallback =
+ WTF::Function<void(bool completedWithoutError)>;
+ void executeScriptAsync(const ScriptSourceCode&,
+ std::unique_ptr<ExecuteScriptAsyncCallback>);
+
virtual void execute();
// XML parser calls these
@@ -130,7 +146,36 @@ class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>,
void logScriptMIMEType(LocalFrame*, ScriptResource*, const String&);
bool fetchScript(const String& sourceUrl, FetchRequest::DeferOption);
- bool doExecuteScript(const ScriptSourceCode&);
+
+ // Separate stages of executeScript/executeScriptAsync.
+
+ // Called asynchronously after script compilation, to actually execute the
+ // script, after executeScriptAsync is invoked.
+ void continueExecuteScriptAsync(CompiledScript*,
+ Document* elementDocumentWhenCompiled,
+ std::unique_ptr<ExecuteScriptAsyncCallback>);
+
+ // Determines whether the script should be proceed to execution.
+ // Includes Content Security Policy and MIME type checks.
+ // Must be called directly before execution, to ensure that current policy is
+ // applied.
+ enum class CheckScriptResult { NothingToDo, Proceed, Abort };
+ CheckScriptResult checkScript(const ScriptSourceCode&);
+
+ // Called before script compilation, to determine the extent to which cached
+ // data about the script is sharable.
+ AccessControlStatus computeAccessControlStatus(const ScriptSourceCode&);
+
+ // Invokes the functor with the ScriptController, in a context where it script
+ // can run. Applies (and unapplies) state such as document.currentScript.
+ // This should be used to wrap the actual execution of the script.
+ template <typename Functor>
+ void asCurrentScript(const Functor&);
+
+ // Records time that the parser has been blocked on script execution.
+ void recordParserBlockedOnScriptExecutionSince(double startTime);
+
+ // End stages of executeScript/executeScriptAsync.
ScriptLoaderClient* client() const;
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/ScriptLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698