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 "core/dom/ModuleScript.h" | 5 #include "core/dom/ModuleScript.h" |
6 | 6 |
| 7 #include "bindings/core/v8/ScriptState.h" |
| 8 #include "bindings/core/v8/ScriptValue.h" |
| 9 #include "v8/include/v8.h" |
| 10 |
7 namespace blink { | 11 namespace blink { |
8 | 12 |
9 void ModuleScript::SetInstantiationError(v8::Isolate* isolate, | 13 void ModuleScript::SetInstantiationErrorAndClearRecord(ScriptValue error) { |
10 v8::Local<v8::Value> error) { | 14 // Implements Step 7.1 of: |
| 15 // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-scri
pt-graph-fetching-procedure |
| 16 |
| 17 // "set script's instantiation state to "errored", ..." |
11 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); | 18 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); |
12 instantiation_state_ = ModuleInstantiationState::kErrored; | 19 instantiation_state_ = ModuleInstantiationState::kErrored; |
13 | 20 |
| 21 // "its instantiation error to instantiationStatus.[[Value]], and ..." |
14 DCHECK(!error.IsEmpty()); | 22 DCHECK(!error.IsEmpty()); |
15 instantiation_error_.Set(isolate, error); | 23 { |
| 24 ScriptState::Scope scope(error.GetScriptState()); |
| 25 instantiation_error_.Set(error.GetIsolate(), error.V8Value()); |
| 26 } |
| 27 |
| 28 // "its module record to null." |
| 29 record_ = ScriptModule(); |
16 } | 30 } |
17 | 31 |
18 void ModuleScript::SetInstantiationSuccess() { | 32 void ModuleScript::SetInstantiationSuccess() { |
| 33 // Implements Step 7.2 of: |
| 34 // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-scri
pt-graph-fetching-procedure |
| 35 |
| 36 // "set script's instantiation state to "instantiated"." |
19 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); | 37 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); |
20 instantiation_state_ = ModuleInstantiationState::kInstantiated; | 38 instantiation_state_ = ModuleInstantiationState::kInstantiated; |
21 } | 39 } |
22 | 40 |
23 DEFINE_TRACE(ModuleScript) { | 41 DEFINE_TRACE(ModuleScript) { |
24 visitor->Trace(settings_object_); | 42 visitor->Trace(settings_object_); |
25 Script::Trace(visitor); | 43 Script::Trace(visitor); |
26 } | 44 } |
27 DEFINE_TRACE_WRAPPERS(ModuleScript) { | 45 DEFINE_TRACE_WRAPPERS(ModuleScript) { |
28 visitor->TraceWrappers(instantiation_error_); | 46 visitor->TraceWrappers(instantiation_error_); |
(...skipping 16 matching lines...) Expand all Loading... |
45 } | 63 } |
46 | 64 |
47 String ModuleScript::InlineSourceTextForCSP() const { | 65 String ModuleScript::InlineSourceTextForCSP() const { |
48 // Currently we don't support inline module scripts. | 66 // Currently we don't support inline module scripts. |
49 // TODO(hiroshige): Implement this. | 67 // TODO(hiroshige): Implement this. |
50 NOTREACHED(); | 68 NOTREACHED(); |
51 return String(); | 69 return String(); |
52 } | 70 } |
53 | 71 |
54 } // namespace blink | 72 } // namespace blink |
OLD | NEW |