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