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 ScriptModule_h | 5 #ifndef ScriptModule_h |
6 #define ScriptModule_h | 6 #define ScriptModule_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "platform/bindings/ScriptState.h" | 9 #include "platform/bindings/ScriptState.h" |
10 #include "platform/bindings/SharedPersistent.h" | 10 #include "platform/bindings/SharedPersistent.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 return *left == *right; | 70 return *left == *right; |
71 } | 71 } |
72 | 72 |
73 bool operator!=(const blink::ScriptModule& other) const { | 73 bool operator!=(const blink::ScriptModule& other) const { |
74 return !(*this == other); | 74 return !(*this == other); |
75 } | 75 } |
76 | 76 |
77 bool IsNull() const { return !module_ || module_->IsEmpty(); } | 77 bool IsNull() const { return !module_ || module_->IsEmpty(); } |
78 | 78 |
79 private: | 79 private: |
| 80 // ModuleScript instances store their record as |
| 81 // TraceWrapperV8Reference<v8::Module>, and reconstructs ScriptModule from it. |
| 82 friend class ModuleScript; |
| 83 |
80 ScriptModule(v8::Isolate*, v8::Local<v8::Module>); | 84 ScriptModule(v8::Isolate*, v8::Local<v8::Module>); |
81 | 85 |
| 86 v8::Local<v8::Module> NewLocal(v8::Isolate* isolate) { |
| 87 return module_->NewLocal(isolate); |
| 88 } |
| 89 |
82 static v8::MaybeLocal<v8::Module> ResolveModuleCallback( | 90 static v8::MaybeLocal<v8::Module> ResolveModuleCallback( |
83 v8::Local<v8::Context>, | 91 v8::Local<v8::Context>, |
84 v8::Local<v8::String> specifier, | 92 v8::Local<v8::String> specifier, |
85 v8::Local<v8::Module> referrer); | 93 v8::Local<v8::Module> referrer); |
86 | 94 |
87 RefPtr<SharedPersistent<v8::Module>> module_; | 95 RefPtr<SharedPersistent<v8::Module>> module_; |
88 unsigned identity_hash_ = 0; | 96 unsigned identity_hash_ = 0; |
89 | 97 |
90 friend struct ScriptModuleHash; | 98 friend struct ScriptModuleHash; |
91 }; | 99 }; |
(...skipping 23 matching lines...) Expand all Loading... |
115 using Hash = blink::ScriptModuleHash; | 123 using Hash = blink::ScriptModuleHash; |
116 }; | 124 }; |
117 | 125 |
118 template <> | 126 template <> |
119 struct HashTraits<blink::ScriptModule> | 127 struct HashTraits<blink::ScriptModule> |
120 : public SimpleClassHashTraits<blink::ScriptModule> {}; | 128 : public SimpleClassHashTraits<blink::ScriptModule> {}; |
121 | 129 |
122 } // namespace WTF | 130 } // namespace WTF |
123 | 131 |
124 #endif // ScriptModule_h | 132 #endif // ScriptModule_h |
OLD | NEW |