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

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

Issue 179803007: Refactors parts of gin: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix gin_shell Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « gin/modules/module_runner_delegate.h ('k') | gin/modules/timer.cc » ('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 #include "gin/object_template_builder.h" 8 #include "gin/object_template_builder.h"
9 #include "gin/public/context_holder.h"
9 10
10 namespace gin { 11 namespace gin {
11 12
12 ModuleRunnerDelegate::ModuleRunnerDelegate( 13 ModuleRunnerDelegate::ModuleRunnerDelegate(
13 const std::vector<base::FilePath>& search_paths) 14 const std::vector<base::FilePath>& search_paths)
14 : module_provider_(search_paths) { 15 : module_provider_(search_paths) {
15 } 16 }
16 17
17 ModuleRunnerDelegate::~ModuleRunnerDelegate() { 18 ModuleRunnerDelegate::~ModuleRunnerDelegate() {
18 } 19 }
19 20
20 void ModuleRunnerDelegate::AddBuiltinModule(const std::string& id, 21 void ModuleRunnerDelegate::AddBuiltinModule(const std::string& id,
21 ModuleGetter getter) { 22 ModuleGetter getter) {
22 builtin_modules_[id] = getter; 23 builtin_modules_[id] = getter;
23 } 24 }
24 25
25 void ModuleRunnerDelegate::AttemptToLoadMoreModules(Runner* runner) { 26 void ModuleRunnerDelegate::AttemptToLoadMoreModules(Runner* runner) {
26 ModuleRegistry* registry = ModuleRegistry::From(runner->context()); 27 ModuleRegistry* registry = ModuleRegistry::From(
27 registry->AttemptToLoadMoreModules(runner->isolate()); 28 runner->GetContextHolder()->context());
29 registry->AttemptToLoadMoreModules(runner->GetContextHolder()->isolate());
28 module_provider_.AttempToLoadModules( 30 module_provider_.AttempToLoadModules(
29 runner, registry->unsatisfied_dependencies()); 31 runner, registry->unsatisfied_dependencies());
30 } 32 }
31 33
32 v8::Handle<v8::ObjectTemplate> ModuleRunnerDelegate::GetGlobalTemplate( 34 v8::Handle<v8::ObjectTemplate> ModuleRunnerDelegate::GetGlobalTemplate(
33 Runner* runner) { 35 ShellRunner* runner,
34 v8::Handle<v8::ObjectTemplate> templ = 36 v8::Isolate* isolate) {
35 ObjectTemplateBuilder(runner->isolate()).Build(); 37 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplateBuilder(isolate).Build();
36 ModuleRegistry::RegisterGlobals(runner->isolate(), templ); 38 ModuleRegistry::RegisterGlobals(isolate, templ);
37 return templ; 39 return templ;
38 } 40 }
39 41
40 void ModuleRunnerDelegate::DidCreateContext(Runner* runner) { 42 void ModuleRunnerDelegate::DidCreateContext(ShellRunner* runner) {
41 RunnerDelegate::DidCreateContext(runner); 43 ShellRunnerDelegate::DidCreateContext(runner);
42 44
43 v8::Handle<v8::Context> context = runner->context(); 45 v8::Handle<v8::Context> context = runner->GetContextHolder()->context();
44 ModuleRegistry* registry = ModuleRegistry::From(context); 46 ModuleRegistry* registry = ModuleRegistry::From(context);
45 47
48 v8::Isolate* isolate = runner->GetContextHolder()->isolate();
46 for (BuiltinModuleMap::const_iterator it = builtin_modules_.begin(); 49 for (BuiltinModuleMap::const_iterator it = builtin_modules_.begin();
47 it != builtin_modules_.end(); ++it) { 50 it != builtin_modules_.end(); ++it) {
48 registry->AddBuiltinModule(runner->isolate(), it->first, 51 registry->AddBuiltinModule(isolate, it->first, it->second(isolate));
49 it->second(runner->isolate()));
50 } 52 }
51 } 53 }
52 54
53 void ModuleRunnerDelegate::DidRunScript(Runner* runner) { 55 void ModuleRunnerDelegate::DidRunScript(ShellRunner* runner) {
54 AttemptToLoadMoreModules(runner); 56 AttemptToLoadMoreModules(runner);
55 } 57 }
56 58
57 } // namespace gin 59 } // namespace gin
OLDNEW
« no previous file with comments | « gin/modules/module_runner_delegate.h ('k') | gin/modules/timer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698