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