Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ModuleController.cpp

Issue 2555653002: [WIP Prototype] ES6 https://html.spec.whatwg.org/#fetch-a-single-module-script implementation (Closed)
Patch Set: ModuleScriptLoaderTest Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "bindings/core/v8/ModuleController.h"
6
7 #include "bindings/core/v8/ScriptModule.h"
8 #include "bindings/core/v8/V8PerIsolateData.h"
9 #include <v8.h>
10
11 namespace blink {
12
13 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.
14 : m_scriptState(std::move(scriptState)) {
15 DCHECK(m_scriptState);
16 }
17
18 ModuleController::~ModuleController() {}
19
20 ScriptModule ModuleController::compileModule(const String& script,
21 const String& urlStr) {
22 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate();
23 v8::HandleScope handleScope(isolate);
24
25 ScriptState::Scope scope(m_scriptState.get());
26 return ScriptModule::compile(isolate, script, urlStr);
27 }
28
29 bool ModuleController::instantiateModule(ScriptModule scriptModule) {
30 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate();
31 v8::HandleScope handleScope(isolate);
32
33 ScriptState::Scope scope(m_scriptState.get());
34 return scriptModule.instantiate(m_scriptState.get());
35 }
36
37 Vector<String> ModuleController::moduleRequestsFromScriptModule(
38 ScriptModule scriptModule) {
39 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate();
40 v8::HandleScope handleScope(isolate);
41
42 ScriptState::Scope scope(m_scriptState.get());
43 return scriptModule.moduleRequests(m_scriptState.get());
44 }
45
46 void ModuleController::executeModule(ScriptModule scriptModule) {
47 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate();
48 v8::HandleScope handleScope(isolate);
49
50 ScriptState::Scope scope(m_scriptState.get());
51
52 v8::MicrotasksScope microtasksScope(isolate,
53 v8::MicrotasksScope::kRunMicrotasks);
54 scriptModule.evaluate(m_scriptState.get());
55 }
56
57 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698