| Index: mojo/apps/js/mojo_runner_delegate.cc
|
| diff --git a/mojo/apps/js/mojo_runner_delegate.cc b/mojo/apps/js/mojo_runner_delegate.cc
|
| index 610ede4090006d18bdd123983bb888f201b87d59..c74bf5018215046e53bec475bd02b1753e509c94 100644
|
| --- a/mojo/apps/js/mojo_runner_delegate.cc
|
| +++ b/mojo/apps/js/mojo_runner_delegate.cc
|
| @@ -4,11 +4,13 @@
|
|
|
| #include "mojo/apps/js/mojo_runner_delegate.h"
|
|
|
| +#include "base/bind.h"
|
| #include "base/path_service.h"
|
| +#include "gin/converter.h"
|
| #include "gin/modules/console.h"
|
| #include "gin/modules/module_registry.h"
|
| #include "gin/try_catch.h"
|
| -#include "mojo/apps/js/bootstrap.h"
|
| +#include "mojo/apps/js/threading.h"
|
| #include "mojo/public/bindings/js/core.h"
|
| #include "mojo/public/bindings/js/support.h"
|
|
|
| @@ -27,11 +29,22 @@ std::vector<base::FilePath> GetModuleSearchPaths() {
|
| return search_paths;
|
| }
|
|
|
| +void StartCallback(base::WeakPtr<gin::Runner> runner,
|
| + MojoHandle pipe,
|
| + v8::Handle<v8::Value> module) {
|
| + v8::Isolate* isolate = runner->isolate();
|
| + v8::Handle<v8::Function> start;
|
| + CHECK(gin::ConvertFromV8(isolate, module, &start));
|
| +
|
| + v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, pipe) };
|
| + runner->Call(start, runner->global(), 1, args);
|
| +}
|
| +
|
| } // namespace
|
|
|
| MojoRunnerDelegate::MojoRunnerDelegate()
|
| : ModuleRunnerDelegate(GetModuleSearchPaths()) {
|
| - AddBuiltinModule(Bootstrap::kModuleName, Bootstrap::GetTemplate);
|
| + AddBuiltinModule(Threading::kModuleName, Threading::GetTemplate);
|
| AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetTemplate);
|
| AddBuiltinModule(js::Core::kModuleName, js::Core::GetTemplate);
|
| AddBuiltinModule(js::Support::kModuleName, js::Support::GetTemplate);
|
| @@ -40,6 +53,16 @@ MojoRunnerDelegate::MojoRunnerDelegate()
|
| MojoRunnerDelegate::~MojoRunnerDelegate() {
|
| }
|
|
|
| +void MojoRunnerDelegate::Start(gin::Runner* runner,
|
| + MojoHandle pipe,
|
| + const std::string& module) {
|
| + gin::Runner::Scope scope(runner);
|
| + gin::ModuleRegistry* registry = gin::ModuleRegistry::From(runner->context());
|
| + registry->LoadModule(runner->isolate(), module,
|
| + base::Bind(StartCallback, runner->GetWeakPtr(), pipe));
|
| + AttemptToLoadMoreModules(runner);
|
| +}
|
| +
|
| void MojoRunnerDelegate::UnhandledException(gin::Runner* runner,
|
| gin::TryCatch& try_catch) {
|
| gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch);
|
|
|