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 "mojo/apps/js/mojo_runner_delegate.h" | 5 #include "mojo/apps/js/mojo_runner_delegate.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "gin/converter.h" | 9 #include "gin/converter.h" |
10 #include "gin/modules/console.h" | 10 #include "gin/modules/console.h" |
11 #include "gin/modules/module_registry.h" | 11 #include "gin/modules/module_registry.h" |
12 #include "gin/try_catch.h" | 12 #include "gin/try_catch.h" |
13 #include "mojo/apps/js/bindings/core.h" | 13 #include "mojo/apps/js/bindings/core.h" |
| 14 #include "mojo/apps/js/bindings/gl/module.h" |
14 #include "mojo/apps/js/bindings/support.h" | 15 #include "mojo/apps/js/bindings/support.h" |
15 #include "mojo/apps/js/bindings/threading.h" | 16 #include "mojo/apps/js/bindings/threading.h" |
16 | 17 |
17 namespace mojo { | 18 namespace mojo { |
18 namespace apps { | 19 namespace apps { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 // TODO(abarth): Rather than loading these modules from the file system, we | 23 // TODO(abarth): Rather than loading these modules from the file system, we |
23 // should load them from the network via Mojo IPC. | 24 // should load them from the network via Mojo IPC. |
(...skipping 13 matching lines...) Expand all Loading... |
37 CHECK(gin::ConvertFromV8(isolate, module, &start)); | 38 CHECK(gin::ConvertFromV8(isolate, module, &start)); |
38 | 39 |
39 v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, pipe) }; | 40 v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, pipe) }; |
40 runner->Call(start, runner->global(), 1, args); | 41 runner->Call(start, runner->global(), 1, args); |
41 } | 42 } |
42 | 43 |
43 } // namespace | 44 } // namespace |
44 | 45 |
45 MojoRunnerDelegate::MojoRunnerDelegate() | 46 MojoRunnerDelegate::MojoRunnerDelegate() |
46 : ModuleRunnerDelegate(GetModuleSearchPaths()) { | 47 : ModuleRunnerDelegate(GetModuleSearchPaths()) { |
47 AddBuiltinModule(Threading::kModuleName, Threading::GetTemplate); | |
48 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetTemplate); | 48 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetTemplate); |
49 AddBuiltinModule(js::Core::kModuleName, js::Core::GetTemplate); | 49 AddBuiltinModule(js::Core::kModuleName, js::Core::GetTemplate); |
50 AddBuiltinModule(js::Support::kModuleName, js::Support::GetTemplate); | 50 AddBuiltinModule(js::Support::kModuleName, js::Support::GetTemplate); |
| 51 AddBuiltinModule(mojo::js::gl::kModuleName, mojo::js::gl::GetModuleTemplate); |
| 52 AddBuiltinModule(Threading::kModuleName, Threading::GetTemplate); |
51 } | 53 } |
52 | 54 |
53 MojoRunnerDelegate::~MojoRunnerDelegate() { | 55 MojoRunnerDelegate::~MojoRunnerDelegate() { |
54 } | 56 } |
55 | 57 |
56 void MojoRunnerDelegate::Start(gin::Runner* runner, | 58 void MojoRunnerDelegate::Start(gin::Runner* runner, |
57 MojoHandle pipe, | 59 MojoHandle pipe, |
58 const std::string& module) { | 60 const std::string& module) { |
59 gin::Runner::Scope scope(runner); | 61 gin::Runner::Scope scope(runner); |
60 gin::ModuleRegistry* registry = gin::ModuleRegistry::From(runner->context()); | 62 gin::ModuleRegistry* registry = gin::ModuleRegistry::From(runner->context()); |
61 registry->LoadModule(runner->isolate(), module, | 63 registry->LoadModule(runner->isolate(), module, |
62 base::Bind(StartCallback, runner->GetWeakPtr(), pipe)); | 64 base::Bind(StartCallback, runner->GetWeakPtr(), pipe)); |
63 AttemptToLoadMoreModules(runner); | 65 AttemptToLoadMoreModules(runner); |
64 } | 66 } |
65 | 67 |
66 void MojoRunnerDelegate::UnhandledException(gin::Runner* runner, | 68 void MojoRunnerDelegate::UnhandledException(gin::Runner* runner, |
67 gin::TryCatch& try_catch) { | 69 gin::TryCatch& try_catch) { |
68 gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch); | 70 gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch); |
69 LOG(ERROR) << try_catch.GetStackTrace(); | 71 LOG(ERROR) << try_catch.GetStackTrace(); |
70 } | 72 } |
71 | 73 |
72 } // namespace apps | 74 } // namespace apps |
73 } // namespace mojo | 75 } // namespace mojo |
OLD | NEW |