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