| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef Modulator_h | 5 #ifndef Modulator_h |
| 6 #define Modulator_h | 6 #define Modulator_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "bindings/core/v8/V8PerContextData.h" | 9 #include "bindings/core/v8/V8PerContextData.h" |
| 10 #include "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
| 11 #include "core/dom/AncestorList.h" |
| 11 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 12 #include "platform/loader/fetch/AccessControlStatus.h" | 13 #include "platform/loader/fetch/AccessControlStatus.h" |
| 13 #include "platform/weborigin/KURL.h" | 14 #include "platform/weborigin/KURL.h" |
| 14 #include "platform/weborigin/ReferrerPolicy.h" | 15 #include "platform/weborigin/ReferrerPolicy.h" |
| 15 #include "platform/wtf/text/WTFString.h" | 16 #include "platform/wtf/text/WTFString.h" |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 | 19 |
| 19 class ModuleScript; | 20 class ModuleScript; |
| 20 class ModuleScriptFetchRequest; | 21 class ModuleScriptFetchRequest; |
| 21 class ModuleScriptLoaderClient; | 22 class ModuleScriptLoaderClient; |
| 22 class ScriptModule; | 23 class ScriptModule; |
| 23 class ScriptModuleResolver; | 24 class ScriptModuleResolver; |
| 24 class ScriptState; | 25 class ScriptState; |
| 25 class ScriptValue; | 26 class ScriptValue; |
| 26 class SecurityOrigin; | 27 class SecurityOrigin; |
| 27 class WebTaskRunner; | 28 class WebTaskRunner; |
| 28 | 29 |
| 29 // A SingleModuleClient is notified when single module script node (node as in a | 30 // A SingleModuleClient is notified when single module script node (node as in a |
| 30 // module tree graph) load is complete and its corresponding entry is created in | 31 // module tree graph) load is complete and its corresponding entry is created in |
| 31 // module map. | 32 // module map. |
| 32 class SingleModuleClient : public GarbageCollectedMixin { | 33 class CORE_EXPORT SingleModuleClient : public GarbageCollectedMixin { |
| 33 public: | 34 public: |
| 34 virtual void NotifyModuleLoadFinished(ModuleScript*) = 0; | 35 virtual void NotifyModuleLoadFinished(ModuleScript*) = 0; |
| 35 }; | 36 }; |
| 36 | 37 |
| 38 // A ModuleTreeClient is notified when a module script and its whole descendent |
| 39 // tree load is complete. |
| 40 class CORE_EXPORT ModuleTreeClient : public GarbageCollectedMixin { |
| 41 public: |
| 42 virtual void NotifyModuleTreeLoadFinished(ModuleScript*) = 0; |
| 43 }; |
| 44 |
| 37 // spec: "top-level module fetch flag" | 45 // spec: "top-level module fetch flag" |
| 38 // https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-is-to
p-level | 46 // https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-is-to
p-level |
| 39 enum class ModuleGraphLevel { kTopLevelModuleFetch, kDependentModuleFetch }; | 47 enum class ModuleGraphLevel { kTopLevelModuleFetch, kDependentModuleFetch }; |
| 40 | 48 |
| 41 // A Modulator is an interface for "environment settings object" concept for | 49 // A Modulator is an interface for "environment settings object" concept for |
| 42 // module scripts. | 50 // module scripts. |
| 43 // https://html.spec.whatwg.org/#environment-settings-object | 51 // https://html.spec.whatwg.org/#environment-settings-object |
| 44 // | 52 // |
| 45 // A Modulator also serves as an entry point for various module spec algorithms. | 53 // A Modulator also serves as an entry point for various module spec algorithms. |
| 46 class CORE_EXPORT Modulator : public GarbageCollectedFinalized<Modulator>, | 54 class CORE_EXPORT Modulator : public GarbageCollectedFinalized<Modulator>, |
| 47 public V8PerContextData::Data, | 55 public V8PerContextData::Data, |
| 48 public TraceWrapperBase { | 56 public TraceWrapperBase { |
| 49 USING_GARBAGE_COLLECTED_MIXIN(Modulator); | 57 USING_GARBAGE_COLLECTED_MIXIN(Modulator); |
| 50 | 58 |
| 51 public: | 59 public: |
| 52 static Modulator* From(ScriptState*); | 60 static Modulator* From(ScriptState*); |
| 53 virtual ~Modulator(); | 61 virtual ~Modulator(); |
| 54 | 62 |
| 55 static void SetModulator(ScriptState*, Modulator*); | 63 static void SetModulator(ScriptState*, Modulator*); |
| 56 static void ClearModulator(ScriptState*); | 64 static void ClearModulator(ScriptState*); |
| 57 | 65 |
| 58 DEFINE_INLINE_VIRTUAL_TRACE() {} | 66 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 59 | 67 |
| 60 virtual ScriptModuleResolver* GetScriptModuleResolver() = 0; | 68 virtual ScriptModuleResolver* GetScriptModuleResolver() = 0; |
| 61 virtual WebTaskRunner* TaskRunner() = 0; | 69 virtual WebTaskRunner* TaskRunner() = 0; |
| 62 virtual ReferrerPolicy GetReferrerPolicy() = 0; | 70 virtual ReferrerPolicy GetReferrerPolicy() = 0; |
| 63 virtual SecurityOrigin* GetSecurityOrigin() = 0; | 71 virtual SecurityOrigin* GetSecurityOrigin() = 0; |
| 64 | 72 |
| 73 // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-module-scrip
t-tree |
| 74 virtual void FetchTree(const ModuleScriptFetchRequest&, |
| 75 ModuleTreeClient*) = 0; |
| 76 |
| 77 // https://html.spec.whatwg.org/#internal-module-script-graph-fetching-procedu
re |
| 78 virtual void FetchTreeInternal(const ModuleScriptFetchRequest&, |
| 79 const AncestorList&, |
| 80 ModuleGraphLevel, |
| 81 ModuleTreeClient*) = 0; |
| 82 |
| 83 // Asynchronously retrieve a module script from the module map, or fetch it |
| 84 // and put it in the map if it's not there already. |
| 85 // https://html.spec.whatwg.org/#fetch-a-single-module-script |
| 86 virtual void FetchSingle(const ModuleScriptFetchRequest&, |
| 87 ModuleGraphLevel, |
| 88 SingleModuleClient*) = 0; |
| 89 |
| 65 // Synchronously retrieves a single module script from existing module map | 90 // Synchronously retrieves a single module script from existing module map |
| 66 // entry. | 91 // entry. |
| 67 virtual ModuleScript* GetFetchedModuleScript(const KURL&) = 0; | 92 virtual ModuleScript* GetFetchedModuleScript(const KURL&) = 0; |
| 68 | 93 |
| 69 // https://html.spec.whatwg.org/#resolve-a-module-specifier | 94 // https://html.spec.whatwg.org/#resolve-a-module-specifier |
| 70 static KURL ResolveModuleSpecifier(const String& module_request, | 95 static KURL ResolveModuleSpecifier(const String& module_request, |
| 71 const KURL& base_url); | 96 const KURL& base_url); |
| 72 | 97 |
| 73 virtual ScriptModule CompileModule(const String& script, | 98 virtual ScriptModule CompileModule(const String& script, |
| 74 const String& url_str, | 99 const String& url_str, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 86 // if the cached entry doesn't exist. | 111 // if the cached entry doesn't exist. |
| 87 // The client can be notified either synchronously or asynchronously. | 112 // The client can be notified either synchronously or asynchronously. |
| 88 virtual void FetchNewSingleModule(const ModuleScriptFetchRequest&, | 113 virtual void FetchNewSingleModule(const ModuleScriptFetchRequest&, |
| 89 ModuleGraphLevel, | 114 ModuleGraphLevel, |
| 90 ModuleScriptLoaderClient*) = 0; | 115 ModuleScriptLoaderClient*) = 0; |
| 91 }; | 116 }; |
| 92 | 117 |
| 93 } // namespace blink | 118 } // namespace blink |
| 94 | 119 |
| 95 #endif | 120 #endif |
| OLD | NEW |