android: disable NLS when building yasm.
[chromium-blink-merge.git] / gin / modules / module_runner_delegate.cc
blob2a9f95cd760575e7be135d2f7f2c4b6482cdcaaf
1 // Copyright 2013 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.
5 #include "gin/modules/module_runner_delegate.h"
7 #include "gin/modules/module_registry.h"
8 #include "gin/object_template_builder.h"
10 namespace gin {
12 ModuleRunnerDelegate::ModuleRunnerDelegate(
13 const std::vector<base::FilePath>& search_paths)
14 : module_provider_(search_paths) {
17 ModuleRunnerDelegate::~ModuleRunnerDelegate() {
20 void ModuleRunnerDelegate::AddBuiltinModule(const std::string& id,
21 ModuleGetter getter) {
22 builtin_modules_[id] = getter;
25 void ModuleRunnerDelegate::AttemptToLoadMoreModules(Runner* runner) {
26 ModuleRegistry* registry = ModuleRegistry::From(runner->context());
27 registry->AttemptToLoadMoreModules(runner->isolate());
28 module_provider_.AttempToLoadModules(
29 runner, registry->unsatisfied_dependencies());
32 v8::Handle<v8::ObjectTemplate> ModuleRunnerDelegate::GetGlobalTemplate(
33 Runner* runner) {
34 v8::Handle<v8::ObjectTemplate> templ =
35 ObjectTemplateBuilder(runner->isolate()).Build();
36 ModuleRegistry::RegisterGlobals(runner->isolate(), templ);
37 return templ;
40 void ModuleRunnerDelegate::DidCreateContext(Runner* runner) {
41 RunnerDelegate::DidCreateContext(runner);
43 v8::Handle<v8::Context> context = runner->context();
44 ModuleRegistry* registry = ModuleRegistry::From(context);
46 for (BuiltinModuleMap::const_iterator it = builtin_modules_.begin();
47 it != builtin_modules_.end(); ++it) {
48 registry->AddBuiltinModule(runner->isolate(), it->first,
49 it->second(runner->isolate()));
53 void ModuleRunnerDelegate::DidRunScript(Runner* runner) {
54 AttemptToLoadMoreModules(runner);
57 } // namespace gin