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

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

Issue 2555653002: [WIP Prototype] ES6 https://html.spec.whatwg.org/#fetch-a-single-module-script implementation (Closed)
Patch Set: rebased Created 3 years, 8 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 // 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 "core/CoreExport.h" 9 #include "core/CoreExport.h"
10 #include "core/dom/AncestorList.h"
9 #include "platform/heap/Handle.h" 11 #include "platform/heap/Handle.h"
10 #include "platform/weborigin/KURL.h" 12 #include "platform/weborigin/KURL.h"
11 #include "platform/weborigin/ReferrerPolicy.h" 13 #include "platform/weborigin/ReferrerPolicy.h"
12 #include "wtf/text/WTFString.h" 14 #include "wtf/text/WTFString.h"
13 15
14 namespace blink { 16 namespace blink {
15 17
18 class ExecutionContext;
16 class LocalFrame; 19 class LocalFrame;
17 class ModuleScript; 20 class ModuleScript;
18 class ModuleScriptFetchRequest; 21 class ModuleScriptFetchRequest;
19 class ModuleScriptLoaderClient; 22 class ModuleScriptLoaderClient;
20 class ScriptModule; 23 class ScriptModule;
21 class ScriptModuleResolver; 24 class ScriptModuleResolver;
25 class ScriptValue;
22 class SecurityOrigin; 26 class SecurityOrigin;
23 class WebTaskRunner; 27 class WebTaskRunner;
24 28
25 // A SingleModuleClient is notified when single module script node (node as in a 29 // A SingleModuleClient is notified when single module script node (node as in a
26 // module tree graph) load is complete and its corresponding entry is created in 30 // module tree graph) load is complete and its corresponding entry is created in
27 // module map. 31 // module map.
28 class SingleModuleClient : public GarbageCollectedMixin { 32 class SingleModuleClient : public GarbageCollectedMixin {
29 public: 33 public:
30 virtual void notifyModuleLoadFinished(ModuleScript*) = 0; 34 virtual void notifyModuleLoadFinished(ModuleScript*) = 0;
31 }; 35 };
32 36
37 // A ModuleTreeClient is notified when a module script and its whole descendent
38 // tree load is complete.
39 class ModuleTreeClient : public GarbageCollectedMixin {
40 public:
41 virtual void notifyModuleTreeLoadFinished(ModuleScript*) = 0;
42 };
43
33 // spec: "top-level module fetch flag" 44 // spec: "top-level module fetch flag"
34 // https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-is-to p-level 45 // https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-is-to p-level
35 enum class ModuleGraphLevel { TopLevelModuleFetch, DependentModuleFetch }; 46 enum class ModuleGraphLevel { TopLevelModuleFetch, DependentModuleFetch };
36 47
37 // A Modulator is an interface for "environment settings object" concept for 48 // A Modulator is an interface for "environment settings object" concept for
38 // module scripts. 49 // module scripts.
39 // https://html.spec.whatwg.org/#environment-settings-object 50 // https://html.spec.whatwg.org/#environment-settings-object
40 // 51 //
41 // A Modulator also serves as an entry point for various module spec algorithms. 52 // A Modulator also serves as an entry point for various module spec algorithms.
42 class CORE_EXPORT Modulator : public GarbageCollectedMixin { 53 class CORE_EXPORT Modulator : public GarbageCollectedFinalized<Modulator>, publi c TraceWrapperBase {
43 public: 54 public:
44 static Modulator* from(LocalFrame*); 55 static Modulator* from(LocalFrame*);
56 virtual ~Modulator();
57
58 DEFINE_INLINE_VIRTUAL_TRACE() {}
45 59
46 virtual ScriptModuleResolver* scriptModuleResolver() = 0; 60 virtual ScriptModuleResolver* scriptModuleResolver() = 0;
47 virtual WebTaskRunner* taskRunner() = 0; 61 virtual WebTaskRunner* taskRunner() = 0;
62 virtual ExecutionContext* executionContext() = 0;
48 virtual ReferrerPolicy referrerPolicy() = 0; 63 virtual ReferrerPolicy referrerPolicy() = 0;
49 virtual SecurityOrigin* securityOrigin() = 0; 64 virtual SecurityOrigin* securityOrigin() = 0;
50 65
66 // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-module-scrip t-tree
67 virtual void fetchTree(const ModuleScriptFetchRequest&,
68 ModuleTreeClient*) = 0;
69
70 // https://html.spec.whatwg.org/#internal-module-script-graph-fetching-procedu re
71 virtual void fetchTreeInternal(const ModuleScriptFetchRequest&,
72 const AncestorList&,
73 ModuleGraphLevel,
74 ModuleTreeClient*) = 0;
75
76 // Asynchronously retrieve a module script from the module map, or fetch it
77 // and put it in the map if it's not there already.
78 // https://html.spec.whatwg.org/#fetch-a-single-module-script
79 virtual void fetchSingle(const ModuleScriptFetchRequest&,
80 ModuleGraphLevel,
81 SingleModuleClient*) = 0;
82
83 // Synchronously retrieves a single module script from existing module map
84 // entry.
85 virtual ModuleScript* getFetchedModuleScript(const KURL&) = 0;
86
51 // https://html.spec.whatwg.org/#resolve-a-module-specifier 87 // https://html.spec.whatwg.org/#resolve-a-module-specifier
52 static KURL resolveModuleSpecifier(const String& moduleRequest, 88 static KURL resolveModuleSpecifier(const String& moduleRequest,
53 const KURL& baseURL); 89 const KURL& baseURL);
54 90
55 virtual ScriptModule compileModule(const String& script, 91 virtual ScriptModule compileModule(const String& script,
56 const String& urlStr) = 0; 92 const String& urlStr) = 0;
57 93
94 virtual ScriptValue instantiateModule(ScriptModule) = 0;
95
96 virtual Vector<String> moduleRequestsFromScriptModule(ScriptModule) = 0;
97
98 virtual void executeModule(ScriptModule) = 0;
99
58 private: 100 private:
59 friend class ModuleMap; 101 friend class ModuleMap;
60 102
61 // Fetches a single module script. 103 // Fetches a single module script.
62 // This is triggered from fetchSingle() implementation (which is in ModuleMap) 104 // This is triggered from fetchSingle() implementation (which is in ModuleMap)
63 // if the cached entry doesn't exist. 105 // if the cached entry doesn't exist.
64 // The client can be notified either synchronously or asynchronously. 106 // The client can be notified either synchronously or asynchronously.
65 virtual void fetchNewSingleModule(const ModuleScriptFetchRequest&, 107 virtual void fetchNewSingleModule(const ModuleScriptFetchRequest&,
66 ModuleGraphLevel, 108 ModuleGraphLevel,
67 ModuleScriptLoaderClient*) = 0; 109 ModuleScriptLoaderClient*) = 0;
68 }; 110 };
69 111
70 } // namespace blink 112 } // namespace blink
71 113
72 #endif 114 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698