| 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 namespace blink { | 7 namespace blink { |
| 8 | 8 |
| 9 void ModuleScript::SetInstantiationError(v8::Isolate* isolate, | 9 void ModuleScript::SetInstantiationError(v8::Isolate* isolate, |
| 10 v8::Local<v8::Value> error) { | 10 v8::Local<v8::Value> error) { |
| 11 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); | 11 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); |
| 12 instantiation_state_ = ModuleInstantiationState::kErrored; | 12 instantiation_state_ = ModuleInstantiationState::kErrored; |
| 13 | 13 |
| 14 DCHECK(!error.IsEmpty()); | 14 DCHECK(!error.IsEmpty()); |
| 15 instantiation_error_.Set(isolate, error); | 15 instantiation_error_.Set(isolate, error); |
| 16 } | 16 } |
| 17 | 17 |
| 18 void ModuleScript::SetInstantiationSuccess() { | 18 void ModuleScript::SetInstantiationSuccess() { |
| 19 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); | 19 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); |
| 20 instantiation_state_ = ModuleInstantiationState::kInstantiated; | 20 instantiation_state_ = ModuleInstantiationState::kInstantiated; |
| 21 } | 21 } |
| 22 | 22 |
| 23 DEFINE_TRACE(ModuleScript) { | 23 DEFINE_TRACE(ModuleScript) { |
| 24 Script::Trace(visitor); | 24 Script::Trace(visitor); |
| 25 } | 25 } |
| 26 DEFINE_TRACE_WRAPPERS(ModuleScript) { | 26 DEFINE_TRACE_WRAPPERS(ModuleScript) { |
| 27 Script::TraceWrappers(visitor); | |
| 28 visitor->TraceWrappers(instantiation_error_); | 27 visitor->TraceWrappers(instantiation_error_); |
| 29 } | 28 } |
| 30 | 29 |
| 31 bool ModuleScript::IsEmpty() const { | 30 bool ModuleScript::IsEmpty() const { |
| 32 return false; | 31 return false; |
| 33 } | 32 } |
| 34 | 33 |
| 35 bool ModuleScript::CheckMIMETypeBeforeRunScript(Document* context_document, | 34 bool ModuleScript::CheckMIMETypeBeforeRunScript(Document* context_document, |
| 36 const SecurityOrigin*) const { | 35 const SecurityOrigin*) const { |
| 37 // We don't check MIME type here because we check the MIME type in | 36 // We don't check MIME type here because we check the MIME type in |
| 38 // ModuleScriptLoader::WasModuleLoadSuccessful(). | 37 // ModuleScriptLoader::WasModuleLoadSuccessful(). |
| 39 return true; | 38 return true; |
| 40 } | 39 } |
| 41 | 40 |
| 42 void ModuleScript::RunScript(LocalFrame* frame, const SecurityOrigin*) const { | 41 void ModuleScript::RunScript(LocalFrame* frame, const SecurityOrigin*) const { |
| 43 // TODO(hiroshige): Implement this once Modulator::ExecuteModule() is landed. | 42 // TODO(hiroshige): Implement this once Modulator::ExecuteModule() is landed. |
| 44 NOTREACHED(); | 43 NOTREACHED(); |
| 45 } | 44 } |
| 46 | 45 |
| 47 String ModuleScript::InlineSourceTextForCSP() const { | 46 String ModuleScript::InlineSourceTextForCSP() const { |
| 48 // Currently we don't support inline module scripts. | 47 // Currently we don't support inline module scripts. |
| 49 // TODO(hiroshige): Implement this. | 48 // TODO(hiroshige): Implement this. |
| 50 NOTREACHED(); | 49 NOTREACHED(); |
| 51 return String(); | 50 return String(); |
| 52 } | 51 } |
| 53 | 52 |
| 54 } // namespace blink | 53 } // namespace blink |
| OLD | NEW |