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

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

Issue 2697073002: [ES6 modules] Introduce ModuleScriptLoader (Closed)
Patch Set: rebased Created 3 years, 9 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 "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 // TODO(kouhei): script should be a ScriptSourceCode.
hiroshige 2017/03/06 22:20:21 I'm not so sure whether |script| should be a Scrip
kouhei (in TOK) 2017/03/23 00:34:00 Removed for now
56 virtual ScriptModule compileModule(const String& script,
57 const String& urlStr) = 0;
58
49 private: 59 private:
50 friend class ModuleMap; 60 friend class ModuleMap;
51 61
52 // Fetches a single module script. 62 // Fetches a single module script.
53 // This is triggered from fetchSingle() implementation (which is in ModuleMap) 63 // This is triggered from fetchSingle() implementation (which is in ModuleMap)
54 // if the cached entry doesn't exist. 64 // if the cached entry doesn't exist.
55 // The client can be notified either synchronously or asynchronously. 65 // The client can be notified either synchronously or asynchronously.
56 virtual void fetchNewSingleModule(const ModuleScriptFetchRequest&, 66 virtual void fetchNewSingleModule(const ModuleScriptFetchRequest&,
57 ModuleGraphLevel, 67 ModuleGraphLevel,
58 ModuleScriptLoaderClient*) = 0; 68 ModuleScriptLoaderClient*) = 0;
59 }; 69 };
60 70
61 } // namespace blink 71 } // namespace blink
62 72
63 #endif 73 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698