Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/ModuleController.cpp |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ModuleController.cpp b/third_party/WebKit/Source/bindings/core/v8/ModuleController.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5246894c10f6a04f7966e74251621bebc0dbaaf1 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/bindings/core/v8/ModuleController.cpp |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "bindings/core/v8/ModuleController.h" |
| + |
| +#include "bindings/core/v8/ScriptModule.h" |
| +#include "bindings/core/v8/V8PerIsolateData.h" |
| +#include <v8.h> |
| + |
| +namespace blink { |
| + |
| +ModuleController::ModuleController(RefPtr<ScriptState> scriptState) |
|
haraken
2017/01/06 05:47:58
It seems to me that ModuleController is an unneces
kouhei (in TOK)
2017/01/11 01:41:57
Done.
|
| + : m_scriptState(std::move(scriptState)) { |
| + DCHECK(m_scriptState); |
| +} |
| + |
| +ModuleController::~ModuleController() {} |
| + |
| +ScriptModule ModuleController::compileModule(const String& script, |
| + const String& urlStr) { |
| + v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); |
| + v8::HandleScope handleScope(isolate); |
| + |
| + ScriptState::Scope scope(m_scriptState.get()); |
| + return ScriptModule::compile(isolate, script, urlStr); |
| +} |
| + |
| +bool ModuleController::instantiateModule(ScriptModule scriptModule) { |
| + v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); |
| + v8::HandleScope handleScope(isolate); |
| + |
| + ScriptState::Scope scope(m_scriptState.get()); |
| + return scriptModule.instantiate(m_scriptState.get()); |
| +} |
| + |
| +Vector<String> ModuleController::moduleRequestsFromScriptModule( |
| + ScriptModule scriptModule) { |
| + v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); |
| + v8::HandleScope handleScope(isolate); |
| + |
| + ScriptState::Scope scope(m_scriptState.get()); |
| + return scriptModule.moduleRequests(m_scriptState.get()); |
| +} |
| + |
| +void ModuleController::executeModule(ScriptModule scriptModule) { |
| + v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); |
| + v8::HandleScope handleScope(isolate); |
| + |
| + ScriptState::Scope scope(m_scriptState.get()); |
| + |
| + v8::MicrotasksScope microtasksScope(isolate, |
| + v8::MicrotasksScope::kRunMicrotasks); |
| + scriptModule.evaluate(m_scriptState.get()); |
| +} |
| + |
| +} // namespace blink |