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/V8BindingForCore.h" | 7 #include "bindings/core/v8/V8BindingForCore.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 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 return ScriptModule(isolate, module); | 61 return ScriptModule(isolate, module); |
62 } | 62 } |
63 | 63 |
64 ScriptValue ScriptModule::Instantiate(ScriptState* script_state) { | 64 ScriptValue ScriptModule::Instantiate(ScriptState* script_state) { |
65 v8::Isolate* isolate = script_state->GetIsolate(); | 65 v8::Isolate* isolate = script_state->GetIsolate(); |
66 v8::TryCatch try_catch(isolate); | 66 v8::TryCatch try_catch(isolate); |
67 try_catch.SetVerbose(true); | 67 try_catch.SetVerbose(true); |
68 | 68 |
69 DCHECK(!IsNull()); | 69 DCHECK(!IsNull()); |
70 v8::Local<v8::Context> context = script_state->GetContext(); | 70 v8::Local<v8::Context> context = script_state->GetContext(); |
71 bool success = module_->NewLocal(script_state->GetIsolate()) | 71 bool success = NewLocal(script_state->GetIsolate()) |
72 ->Instantiate(context, &ResolveModuleCallback); | 72 ->Instantiate(context, &ResolveModuleCallback); |
73 if (!success) { | 73 if (!success) { |
74 DCHECK(try_catch.HasCaught()); | 74 DCHECK(try_catch.HasCaught()); |
75 return ScriptValue(script_state, try_catch.Exception()); | 75 return ScriptValue(script_state, try_catch.Exception()); |
76 } | 76 } |
77 DCHECK(!try_catch.HasCaught()); | 77 DCHECK(!try_catch.HasCaught()); |
78 return ScriptValue(); | 78 return ScriptValue(); |
79 } | 79 } |
80 | 80 |
81 void ScriptModule::Evaluate(ScriptState* script_state) const { | 81 void ScriptModule::Evaluate(ScriptState* script_state) const { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 if (resolved.IsNull()) { | 149 if (resolved.IsNull()) { |
150 DCHECK(exception_state.HadException()); | 150 DCHECK(exception_state.HadException()); |
151 return v8::MaybeLocal<v8::Module>(); | 151 return v8::MaybeLocal<v8::Module>(); |
152 } | 152 } |
153 | 153 |
154 DCHECK(!exception_state.HadException()); | 154 DCHECK(!exception_state.HadException()); |
155 return v8::MaybeLocal<v8::Module>(resolved.module_->NewLocal(isolate)); | 155 return v8::MaybeLocal<v8::Module>(resolved.module_->NewLocal(isolate)); |
156 } | 156 } |
157 | 157 |
158 } // namespace blink | 158 } // namespace blink |
OLD | NEW |