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 ScriptModuleResolver_h | 5 #ifndef ScriptModuleResolver_h |
6 #define ScriptModuleResolver_h | 6 #define ScriptModuleResolver_h |
7 | 7 |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
11 #include "platform/wtf/text/WTFString.h" | 11 #include "platform/wtf/text/WTFString.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class ScriptModule; | 15 class ScriptModule; |
16 class ModuleScript; | 16 class ModuleScript; |
17 | 17 |
18 // The ScriptModuleResolver interface is used from V8 module bindings | 18 // The ScriptModuleResolver interface is used from V8 module bindings |
19 // when it need the ScriptModule's descendants. | 19 // when it need the ScriptModule's descendants. |
20 // | 20 // |
21 // When a module writes import 'x', the module is called the referrer, 'x' is | 21 // When a module writes import 'x', the module is called the referrer, 'x' is |
22 // the specifier, and the module identified by 'x' is the descendant. | 22 // the specifier, and the module identified by 'x' is the descendant. |
23 // ScriptModuleResolver, given a referrer and specifier, can look up the | 23 // ScriptModuleResolver, given a referrer and specifier, can look up the |
24 // descendant. | 24 // descendant. |
| 25 // |
| 26 // In terms of spec, ScriptModuleResolver is also used to set |
| 27 // "referencingModule.[[HostDefined]]" used in: |
| 28 // https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-speci
fier |
25 class CORE_EXPORT ScriptModuleResolver | 29 class CORE_EXPORT ScriptModuleResolver |
26 : public GarbageCollectedFinalized<ScriptModuleResolver> { | 30 : public GarbageCollectedFinalized<ScriptModuleResolver> { |
27 public: | 31 public: |
28 virtual ~ScriptModuleResolver() {} | 32 virtual ~ScriptModuleResolver() {} |
29 DEFINE_INLINE_VIRTUAL_TRACE() {} | 33 DEFINE_INLINE_VIRTUAL_TRACE() {} |
30 | 34 |
31 // Notify the ScriptModuleResolver that a ModuleScript exists. | 35 // Notify the ScriptModuleResolver that a ModuleScript exists. |
32 // This hook gives a chance for the resolver impl to populate module record | 36 // This hook gives a chance for the resolver impl to populate module record |
33 // identifier -> ModuleScript mapping entry. | 37 // identifier -> ModuleScript mapping entry. |
34 virtual void RegisterModuleScript(ModuleScript*) = 0; | 38 virtual void RegisterModuleScript(ModuleScript*) = 0; |
35 | 39 |
36 // Implements "Runtime Semantics: HostResolveImportedModule" | 40 // Implements "Runtime Semantics: HostResolveImportedModule" |
37 // https://tc39.github.io/ecma262/#sec-hostresolveimportedmodule | 41 // https://tc39.github.io/ecma262/#sec-hostresolveimportedmodule |
38 // This returns a null ScriptModule when an exception is thrown. | 42 // This returns a null ScriptModule when an exception is thrown. |
39 virtual ScriptModule Resolve(const String& specifier, | 43 virtual ScriptModule Resolve(const String& specifier, |
40 const ScriptModule& referrer, | 44 const ScriptModule& referrer, |
41 ExceptionState&) = 0; | 45 ExceptionState&) = 0; |
42 }; | 46 }; |
43 | 47 |
44 } // namespace blink | 48 } // namespace blink |
45 | 49 |
46 #endif // ScriptModuleResolver_h | 50 #endif // ScriptModuleResolver_h |
OLD | NEW |