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