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 #include "bindings/core/v8/ScriptModule.h" | 5 #include "bindings/core/v8/ScriptModule.h" |
6 | 6 |
7 #include "bindings/core/v8/V8Binding.h" | 7 #include "bindings/core/v8/V8Binding.h" |
8 #include "core/dom/Modulator.h" | 8 #include "core/dom/Modulator.h" |
9 #include "core/dom/ScriptModuleResolver.h" | 9 #include "core/dom/ScriptModuleResolver.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 ScriptModule::ScriptModule(v8::Isolate* isolate, v8::Local<v8::Module> module) | 13 ScriptModule::ScriptModule(v8::Isolate* isolate, v8::Local<v8::Module> module) |
14 : m_module(SharedPersistent<v8::Module>::create(module, isolate)), | 14 : m_module(SharedPersistent<v8::Module>::create(module, isolate)), |
15 m_identityHash(static_cast<unsigned>(module->GetIdentityHash())) { | 15 m_identityHash(static_cast<unsigned>(module->GetIdentityHash())) { |
16 DCHECK(!m_module->isEmpty()); | 16 DCHECK(!m_module->isEmpty()); |
17 } | 17 } |
18 | 18 |
19 ScriptModule::~ScriptModule() {} | 19 ScriptModule::~ScriptModule() {} |
20 | 20 |
21 ScriptModule ScriptModule::compile(v8::Isolate* isolate, | 21 ScriptModule ScriptModule::compile(v8::Isolate* isolate, |
22 const String& source, | 22 const String& source, |
23 const String& fileName) { | 23 const String& fileName, |
| 24 AccessControlStatus accessControlStatus) { |
24 v8::TryCatch tryCatch(isolate); | 25 v8::TryCatch tryCatch(isolate); |
25 tryCatch.SetVerbose(true); | 26 tryCatch.SetVerbose(true); |
26 v8::Local<v8::Module> module; | 27 v8::Local<v8::Module> module; |
27 if (!v8Call(V8ScriptRunner::compileModule(isolate, source, fileName), module, | 28 if (!v8Call(V8ScriptRunner::compileModule(isolate, source, fileName, |
28 tryCatch)) { | 29 accessControlStatus), |
| 30 module, tryCatch)) { |
29 // Compilation error is not used in Blink implementaion logic. | 31 // Compilation error is not used in Blink implementaion logic. |
30 // Note: Error message is delivered to user (e.g. console) by message | 32 // Note: Error message is delivered to user (e.g. console) by message |
31 // listeners set on v8::Isolate. See V8Initializer::initalizeMainThread(). | 33 // listeners set on v8::Isolate. See V8Initializer::initalizeMainThread(). |
32 // TODO(nhiroki): Revisit this when supporting modules on worker threads. | 34 // TODO(nhiroki): Revisit this when supporting modules on worker threads. |
33 DCHECK(tryCatch.HasCaught()); | 35 DCHECK(tryCatch.HasCaught()); |
34 return ScriptModule(); | 36 return ScriptModule(); |
35 } | 37 } |
36 DCHECK(!tryCatch.HasCaught()); | 38 DCHECK(!tryCatch.HasCaught()); |
37 return ScriptModule(isolate, module); | 39 return ScriptModule(isolate, module); |
38 } | 40 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 if (resolved.isNull()) { | 100 if (resolved.isNull()) { |
99 DCHECK(exceptionState.hadException()); | 101 DCHECK(exceptionState.hadException()); |
100 return v8::MaybeLocal<v8::Module>(); | 102 return v8::MaybeLocal<v8::Module>(); |
101 } | 103 } |
102 | 104 |
103 DCHECK(!exceptionState.hadException()); | 105 DCHECK(!exceptionState.hadException()); |
104 return v8::MaybeLocal<v8::Module>(resolved.m_module->newLocal(isolate)); | 106 return v8::MaybeLocal<v8::Module>(resolved.m_module->newLocal(isolate)); |
105 } | 107 } |
106 | 108 |
107 } // namespace blink | 109 } // namespace blink |
OLD | NEW |