| OLD | NEW |
| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "gin/modules/module_registry.h" | 9 #include "gin/modules/module_registry.h" |
| 10 #include "gin/object_template_builder.h" | 10 #include "gin/object_template_builder.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 void ModuleRunnerDelegate::AttemptToLoadMoreModules(Runner* runner) { | 33 void ModuleRunnerDelegate::AttemptToLoadMoreModules(Runner* runner) { |
| 34 ModuleRegistry* registry = ModuleRegistry::From( | 34 ModuleRegistry* registry = ModuleRegistry::From( |
| 35 runner->GetContextHolder()->context()); | 35 runner->GetContextHolder()->context()); |
| 36 registry->AttemptToLoadMoreModules(runner->GetContextHolder()->isolate()); | 36 registry->AttemptToLoadMoreModules(runner->GetContextHolder()->isolate()); |
| 37 module_provider_.AttempToLoadModules( | 37 module_provider_.AttempToLoadModules( |
| 38 runner, registry->unsatisfied_dependencies()); | 38 runner, registry->unsatisfied_dependencies()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 v8::Handle<v8::ObjectTemplate> ModuleRunnerDelegate::GetGlobalTemplate( | 41 v8::Local<v8::ObjectTemplate> ModuleRunnerDelegate::GetGlobalTemplate( |
| 42 ShellRunner* runner, | 42 ShellRunner* runner, |
| 43 v8::Isolate* isolate) { | 43 v8::Isolate* isolate) { |
| 44 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplateBuilder(isolate).Build(); | 44 v8::Local<v8::ObjectTemplate> templ = ObjectTemplateBuilder(isolate).Build(); |
| 45 ModuleRegistry::RegisterGlobals(isolate, templ); | 45 ModuleRegistry::RegisterGlobals(isolate, templ); |
| 46 return templ; | 46 return templ; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ModuleRunnerDelegate::DidCreateContext(ShellRunner* runner) { | 49 void ModuleRunnerDelegate::DidCreateContext(ShellRunner* runner) { |
| 50 ShellRunnerDelegate::DidCreateContext(runner); | 50 ShellRunnerDelegate::DidCreateContext(runner); |
| 51 | 51 |
| 52 v8::Handle<v8::Context> context = runner->GetContextHolder()->context(); | 52 v8::Local<v8::Context> context = runner->GetContextHolder()->context(); |
| 53 ModuleRegistry* registry = ModuleRegistry::From(context); | 53 ModuleRegistry* registry = ModuleRegistry::From(context); |
| 54 | 54 |
| 55 v8::Isolate* isolate = runner->GetContextHolder()->isolate(); | 55 v8::Isolate* isolate = runner->GetContextHolder()->isolate(); |
| 56 | 56 |
| 57 for (BuiltinModuleMap::const_iterator it = builtin_modules_.begin(); | 57 for (BuiltinModuleMap::const_iterator it = builtin_modules_.begin(); |
| 58 it != builtin_modules_.end(); ++it) { | 58 it != builtin_modules_.end(); ++it) { |
| 59 registry->AddBuiltinModule(isolate, it->first, it->second.Run(isolate)); | 59 registry->AddBuiltinModule(isolate, it->first, it->second.Run(isolate)); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 | 62 |
| 63 void ModuleRunnerDelegate::DidRunScript(ShellRunner* runner) { | 63 void ModuleRunnerDelegate::DidRunScript(ShellRunner* runner) { |
| 64 AttemptToLoadMoreModules(runner); | 64 AttemptToLoadMoreModules(runner); |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace gin | 67 } // namespace gin |
| OLD | NEW |