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

Side by Side Diff: gin/modules/module_runner_delegate.cc

Issue 90203002: [Mojo] Remove static "bootstrap" state in mojo_js (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CHECK, CHECK, CHECK Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « gin/modules/module_runner_delegate.h ('k') | mojo/apps/js/bootstrap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 "gin/modules/module_runner_delegate.h" 5 #include "gin/modules/module_runner_delegate.h"
6 6
7 #include "gin/modules/module_registry.h" 7 #include "gin/modules/module_registry.h"
8 8
9 namespace gin { 9 namespace gin {
10 10
11 ModuleRunnerDelegate::ModuleRunnerDelegate( 11 ModuleRunnerDelegate::ModuleRunnerDelegate(
12 const std::vector<base::FilePath>& search_paths) 12 const std::vector<base::FilePath>& search_paths)
13 : module_provider_(search_paths) { 13 : module_provider_(search_paths) {
14 } 14 }
15 15
16 ModuleRunnerDelegate::~ModuleRunnerDelegate() { 16 ModuleRunnerDelegate::~ModuleRunnerDelegate() {
17 } 17 }
18 18
19 void ModuleRunnerDelegate::AddBuiltinModule(const std::string& id, 19 void ModuleRunnerDelegate::AddBuiltinModule(const std::string& id,
20 ModuleTemplateGetter templ) { 20 ModuleTemplateGetter templ) {
21 builtin_modules_[id] = templ; 21 builtin_modules_[id] = templ;
22 } 22 }
23 23
24 void ModuleRunnerDelegate::AttemptToLoadMoreModules(Runner* runner) {
25 ModuleRegistry* registry = ModuleRegistry::From(runner->context());
26 registry->AttemptToLoadMoreModules(runner->isolate());
27 module_provider_.AttempToLoadModules(
28 runner, registry->unsatisfied_dependencies());
29 }
30
24 v8::Handle<v8::ObjectTemplate> ModuleRunnerDelegate::GetGlobalTemplate( 31 v8::Handle<v8::ObjectTemplate> ModuleRunnerDelegate::GetGlobalTemplate(
25 Runner* runner) { 32 Runner* runner) {
26 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); 33 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
27 ModuleRegistry::RegisterGlobals(runner->isolate(), templ); 34 ModuleRegistry::RegisterGlobals(runner->isolate(), templ);
28 return templ; 35 return templ;
29 } 36 }
30 37
31 void ModuleRunnerDelegate::DidCreateContext(Runner* runner) { 38 void ModuleRunnerDelegate::DidCreateContext(Runner* runner) {
32 RunnerDelegate::DidCreateContext(runner); 39 RunnerDelegate::DidCreateContext(runner);
33 40
34 v8::Handle<v8::Context> context = runner->context(); 41 v8::Handle<v8::Context> context = runner->context();
35 ModuleRegistry* registry = ModuleRegistry::From(context); 42 ModuleRegistry* registry = ModuleRegistry::From(context);
36 43
37 for (BuiltinModuleMap::const_iterator it = builtin_modules_.begin(); 44 for (BuiltinModuleMap::const_iterator it = builtin_modules_.begin();
38 it != builtin_modules_.end(); ++it) { 45 it != builtin_modules_.end(); ++it) {
39 registry->AddBuiltinModule(runner->isolate(), it->first, 46 registry->AddBuiltinModule(runner->isolate(), it->first,
40 it->second(runner->isolate())); 47 it->second(runner->isolate()));
41 } 48 }
42 } 49 }
43 50
44 void ModuleRunnerDelegate::DidRunScript(Runner* runner) { 51 void ModuleRunnerDelegate::DidRunScript(Runner* runner) {
45 ModuleRegistry* registry = ModuleRegistry::From(runner->context()); 52 AttemptToLoadMoreModules(runner);
46 registry->AttemptToLoadMoreModules(runner->isolate());
47 module_provider_.AttempToLoadModules(
48 runner, registry->unsatisfied_dependencies());
49 } 53 }
50 54
51 } // namespace gin 55 } // namespace gin
OLDNEW
« no previous file with comments | « gin/modules/module_runner_delegate.h ('k') | mojo/apps/js/bootstrap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698