OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef Modulator_h | |
6 #define Modulator_h | |
7 | |
8 #include "core/CoreExport.h" | |
9 #include "platform/heap/Handle.h" | |
10 #include "platform/weborigin/KURL.h" | |
11 #include "wtf/text/WTFString.h" | |
12 | |
13 namespace blink { | |
14 | |
15 class LocalFrame; | |
16 class ModuleScript; | |
17 class ModuleScriptLoaderClient; | |
18 class ScriptModule; | |
19 class ScriptModuleResolver; | |
20 class WebTaskRunner; | |
21 | |
22 // A SingleModuleClient is notified when single module script node load is | |
dominicc (has gone to gerrit)
2017/01/11 03:23:48
node -> element, might be clearer by being slightl
kouhei (in TOK)
2017/01/19 02:14:57
clarified this is module tree graph node.
| |
23 // complete and its corresponding entry is created in module map. | |
24 class SingleModuleClient : public GarbageCollectedMixin { | |
dominicc (has gone to gerrit)
2017/01/11 03:23:48
Meta-level comment, the design is pretty clear so
| |
25 public: | |
26 virtual void notifyFinishedSingleModule(ModuleScript*) = 0; | |
dominicc (has gone to gerrit)
2017/01/11 03:23:48
This name has too much (SingleModule repeats part
kouhei (in TOK)
2017/01/19 02:14:57
Done.
| |
27 }; | |
28 | |
29 // A ModuleTreeClient is notified when a module script and its whole descendent | |
dominicc (has gone to gerrit)
2017/01/11 03:23:48
Superb comment.
| |
30 // tree load is complete. | |
31 class ModuleTreeClient : public GarbageCollectedMixin { | |
32 public: | |
33 virtual void notifyFinishedModuleTree(ModuleScript*) = 0; | |
dominicc (has gone to gerrit)
2017/01/11 03:23:48
If you change the SingleModuleClient names above,
kouhei (in TOK)
2017/01/19 02:14:57
Done.
| |
34 }; | |
35 | |
36 // A Modulator is an interface for "environment settings object" concept for | |
37 // module scripts. | |
38 // https://html.spec.whatwg.org/#environment-settings-object | |
39 // | |
40 // A Modulator also serves as an entry point for various module spec algorithms. | |
41 class CORE_EXPORT Modulator : public GarbageCollectedMixin { | |
42 public: | |
43 static Modulator* from(LocalFrame*); | |
44 | |
45 virtual ScriptModuleResolver* scriptModuleResolver() { return nullptr; } | |
46 virtual WebTaskRunner* taskRunner() { return nullptr; }; | |
47 | |
48 // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-module-scrip t-tree | |
49 virtual void fetchTree(const KURL&, | |
50 const KURL& baseURL, | |
51 ModuleTreeClient*) = 0; | |
52 | |
53 // fetchSingle asynchronously retrieves a single module script from module | |
dominicc (has gone to gerrit)
2017/01/11 03:23:48
I'm not sure repeating the method name adds much?
| |
54 // map, | |
dominicc (has gone to gerrit)
2017/01/11 03:23:48
wrapping weird
| |
55 // or initiates its fetch if corresponding module map entry doesn't exist. | |
dominicc (has gone to gerrit)
2017/01/11 03:23:48
module map -> the module map
if corresponding -> i
kouhei (in TOK)
2017/01/19 02:14:57
Done.
| |
56 // https://html.spec.whatwg.org/#fetch-a-single-module-script | |
57 virtual void fetchSingle( | |
dominicc (has gone to gerrit)
2017/01/11 03:23:48
Another nit: when you say "initiate its fetch" you
kouhei (in TOK)
2017/01/19 02:14:57
Done.
| |
58 const KURL&, | |
59 const KURL& baseURL, | |
60 SingleModuleClient* | |
61 /*, a fetch client settings object, a destination, a cryptographic nonce, a parser state, a credentials mode, a module map settings object, a referrer, an d a top-level module fetch flag*/) = 0; | |
62 | |
63 // fetchNewSingleModule asynchronously fetches a single module script. | |
64 // This is triggered from fetchSingle() implementation if the cached entry | |
65 // doesn't exist. | |
66 virtual void fetchNewSingleModule( | |
dominicc (has gone to gerrit)
2017/01/11 03:23:48
Should we hide this and just make it friends with
kouhei (in TOK)
2017/01/19 02:14:56
Done.
| |
67 const KURL&, | |
68 const KURL& baseURL, | |
69 ModuleScriptLoaderClient* | |
70 /*, a fetch client settings object, a destination, a cryptographic nonce, a parser state, a credentials mode, a module map settings object, a referrer, an d a top-level module fetch flag*/) = 0; | |
71 | |
72 // Synchronously retrieves a single module script from existing module map | |
73 // entry. | |
74 virtual ModuleScript* retrieveFetchedModuleScript(const KURL&) = 0; | |
75 | |
76 // https://html.spec.whatwg.org/#resolve-a-module-specifier | |
77 static KURL resolveModuleSpecifier(const String& moduleRequest, | |
78 const KURL& baseURL); | |
79 | |
80 // TODO(kouhei): script should be a ScriptSourceCode. | |
81 virtual ScriptModule compileModule(const String& script, | |
dominicc (has gone to gerrit)
2017/01/11 03:23:48
Hmm, feels odd to have a ScriptModule poking out h
kouhei (in TOK)
2017/01/19 02:14:56
These methods were originally split as ModuleContr
| |
82 const String& urlStr) = 0; | |
83 | |
84 virtual bool instantiateModule(ScriptModule) = 0; | |
85 | |
86 virtual Vector<String> moduleRequestsFromScriptModule(ScriptModule) = 0; | |
87 | |
88 virtual void executeModule(ScriptModule) = 0; | |
89 }; | |
90 | |
91 } // namespace blink | |
92 | |
93 #endif | |
OLD | NEW |