Chromium Code Reviews| 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/V8Binding.h" | |
| 8 #include "bindings/core/v8/V8ThrowException.h" | |
| 9 #include "core/dom/Modulator.h" | |
| 10 | |
| 7 namespace blink { | 11 namespace blink { |
| 8 | 12 |
| 9 void ModuleScript::SetInstantiationError(v8::Isolate* isolate, | 13 void ModuleScript::SetInstantiationError(v8::Isolate* isolate, |
| 10 v8::Local<v8::Value> error) { | 14 v8::Local<v8::Value> error) { |
| 11 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); | 15 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); |
| 12 instantiation_state_ = ModuleInstantiationState::kErrored; | 16 instantiation_state_ = ModuleInstantiationState::kErrored; |
| 13 | 17 |
| 14 DCHECK(!error.IsEmpty()); | 18 DCHECK(!error.IsEmpty()); |
| 15 instantiation_error_.Set(isolate, error); | 19 instantiation_error_.Set(isolate, error); |
| 16 } | 20 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 33 } | 37 } |
| 34 | 38 |
| 35 bool ModuleScript::CheckMIMETypeBeforeRunScript(Document* context_document, | 39 bool ModuleScript::CheckMIMETypeBeforeRunScript(Document* context_document, |
| 36 const SecurityOrigin*) const { | 40 const SecurityOrigin*) const { |
| 37 // We don't check MIME type here because we check the MIME type in | 41 // We don't check MIME type here because we check the MIME type in |
| 38 // ModuleScriptLoader::WasModuleLoadSuccessful(). | 42 // ModuleScriptLoader::WasModuleLoadSuccessful(). |
| 39 return true; | 43 return true; |
| 40 } | 44 } |
| 41 | 45 |
| 42 void ModuleScript::RunScript(LocalFrame* frame, const SecurityOrigin*) const { | 46 void ModuleScript::RunScript(LocalFrame* frame, const SecurityOrigin*) const { |
| 43 // TODO(hiroshige): Implement this once Modulator::ExecuteModule() is landed. | 47 // FOXME: What if the isolate is different from the isolate used for |
| 44 NOTREACHED(); | 48 // m_record's compilation? |
| 49 fprintf(stderr, "ModuleScript: isNull=%d state=%d\n", record_.IsNull(), | |
| 50 InstantiationState()); | |
| 51 | |
| 52 Modulator::From(ToScriptStateForMainWorld(frame))->ExecuteModule(this); | |
|
hiroshige
2017/04/12 19:57:05
I think we should have |m_modulator| in ModuleScri
| |
| 45 } | 53 } |
| 46 | 54 |
| 47 String ModuleScript::InlineSourceTextForCSP() const { | 55 String ModuleScript::InlineSourceTextForCSP() const { |
| 48 // Currently we don't support inline module scripts. | 56 // Currently we don't support inline module scripts. |
| 49 // TODO(hiroshige): Implement this. | 57 // TODO(hiroshige): Implement this. |
| 50 NOTREACHED(); | 58 NOTREACHED(); |
| 51 return String(); | 59 return String(); |
| 52 } | 60 } |
| 53 | 61 |
| 54 } // namespace blink | 62 } // namespace blink |
| OLD | NEW |