| 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 "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
| 10 #include "platform/weborigin/KURL.h" | 10 #include "platform/weborigin/KURL.h" |
| 11 #include "platform/weborigin/ReferrerPolicy.h" |
| 12 #include "wtf/text/WTFString.h" |
| 11 | 13 |
| 12 namespace blink { | 14 namespace blink { |
| 13 | 15 |
| 14 class LocalFrame; | 16 class LocalFrame; |
| 15 class ModuleScript; | 17 class ModuleScript; |
| 16 class ModuleScriptFetchRequest; | 18 class ModuleScriptFetchRequest; |
| 17 class ModuleScriptLoaderClient; | 19 class ModuleScriptLoaderClient; |
| 20 class ScriptModule; |
| 18 class ScriptModuleResolver; | 21 class ScriptModuleResolver; |
| 22 class SecurityOrigin; |
| 19 class WebTaskRunner; | 23 class WebTaskRunner; |
| 20 | 24 |
| 21 // A SingleModuleClient is notified when single module script node (node as in a | 25 // A SingleModuleClient is notified when single module script node (node as in a |
| 22 // module tree graph) load is complete and its corresponding entry is created in | 26 // module tree graph) load is complete and its corresponding entry is created in |
| 23 // module map. | 27 // module map. |
| 24 class SingleModuleClient : public GarbageCollectedMixin { | 28 class SingleModuleClient : public GarbageCollectedMixin { |
| 25 public: | 29 public: |
| 26 virtual void notifyModuleLoadFinished(ModuleScript*) = 0; | 30 virtual void notifyModuleLoadFinished(ModuleScript*) = 0; |
| 27 }; | 31 }; |
| 28 | 32 |
| 29 // spec: "top-level module fetch flag" | 33 // spec: "top-level module fetch flag" |
| 30 // https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-is-to
p-level | 34 // https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-is-to
p-level |
| 31 enum class ModuleGraphLevel { TopLevelModuleFetch, DependentModuleFetch }; | 35 enum class ModuleGraphLevel { TopLevelModuleFetch, DependentModuleFetch }; |
| 32 | 36 |
| 33 // A Modulator is an interface for "environment settings object" concept for | 37 // A Modulator is an interface for "environment settings object" concept for |
| 34 // module scripts. | 38 // module scripts. |
| 35 // https://html.spec.whatwg.org/#environment-settings-object | 39 // https://html.spec.whatwg.org/#environment-settings-object |
| 36 // | 40 // |
| 37 // A Modulator also serves as an entry point for various module spec algorithms. | 41 // A Modulator also serves as an entry point for various module spec algorithms. |
| 38 class CORE_EXPORT Modulator : public GarbageCollectedMixin { | 42 class CORE_EXPORT Modulator : public GarbageCollectedMixin { |
| 39 public: | 43 public: |
| 40 static Modulator* from(LocalFrame*); | 44 static Modulator* from(LocalFrame*); |
| 41 | 45 |
| 42 virtual ScriptModuleResolver* scriptModuleResolver() = 0; | 46 virtual ScriptModuleResolver* scriptModuleResolver() = 0; |
| 43 virtual WebTaskRunner* taskRunner() = 0; | 47 virtual WebTaskRunner* taskRunner() = 0; |
| 48 virtual ReferrerPolicy referrerPolicy() = 0; |
| 49 virtual SecurityOrigin* securityOrigin() = 0; |
| 44 | 50 |
| 45 // https://html.spec.whatwg.org/#resolve-a-module-specifier | 51 // https://html.spec.whatwg.org/#resolve-a-module-specifier |
| 46 static KURL resolveModuleSpecifier(const String& moduleRequest, | 52 static KURL resolveModuleSpecifier(const String& moduleRequest, |
| 47 const KURL& baseURL); | 53 const KURL& baseURL); |
| 48 | 54 |
| 55 virtual ScriptModule compileModule(const String& script, |
| 56 const String& urlStr) = 0; |
| 57 |
| 49 private: | 58 private: |
| 50 friend class ModuleMap; | 59 friend class ModuleMap; |
| 51 | 60 |
| 52 // Fetches a single module script. | 61 // Fetches a single module script. |
| 53 // This is triggered from fetchSingle() implementation (which is in ModuleMap) | 62 // This is triggered from fetchSingle() implementation (which is in ModuleMap) |
| 54 // if the cached entry doesn't exist. | 63 // if the cached entry doesn't exist. |
| 55 // The client can be notified either synchronously or asynchronously. | 64 // The client can be notified either synchronously or asynchronously. |
| 56 virtual void fetchNewSingleModule(const ModuleScriptFetchRequest&, | 65 virtual void fetchNewSingleModule(const ModuleScriptFetchRequest&, |
| 57 ModuleGraphLevel, | 66 ModuleGraphLevel, |
| 58 ModuleScriptLoaderClient*) = 0; | 67 ModuleScriptLoaderClient*) = 0; |
| 59 }; | 68 }; |
| 60 | 69 |
| 61 } // namespace blink | 70 } // namespace blink |
| 62 | 71 |
| 63 #endif | 72 #endif |
| OLD | NEW |