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/modules/timer.h" | 12 #include "gin/modules/timer.h" |
13 #include "gin/try_catch.h" | 13 #include "gin/try_catch.h" |
14 #include "mojo/apps/js/bindings/gl/module.h" | 14 #include "mojo/apps/js/bindings/gl/module.h" |
15 #include "mojo/apps/js/bindings/monotonic_clock.h" | 15 #include "mojo/apps/js/bindings/monotonic_clock.h" |
16 #include "mojo/apps/js/bindings/threading.h" | 16 #include "mojo/apps/js/bindings/threading.h" |
17 #include "mojo/bindings/js/core.h" | 17 #include "mojo/bindings/js/core.h" |
| 18 #include "mojo/bindings/js/handle.h" |
18 #include "mojo/bindings/js/support.h" | 19 #include "mojo/bindings/js/support.h" |
19 | 20 |
20 namespace mojo { | 21 namespace mojo { |
21 namespace apps { | 22 namespace apps { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 // TODO(abarth): Rather than loading these modules from the file system, we | 26 // TODO(abarth): Rather than loading these modules from the file system, we |
26 // should load them from the network via Mojo IPC. | 27 // should load them from the network via Mojo IPC. |
27 std::vector<base::FilePath> GetModuleSearchPaths() { | 28 std::vector<base::FilePath> GetModuleSearchPaths() { |
28 std::vector<base::FilePath> search_paths(2); | 29 std::vector<base::FilePath> search_paths(2); |
29 PathService::Get(base::DIR_SOURCE_ROOT, &search_paths[0]); | 30 PathService::Get(base::DIR_SOURCE_ROOT, &search_paths[0]); |
30 PathService::Get(base::DIR_EXE, &search_paths[1]); | 31 PathService::Get(base::DIR_EXE, &search_paths[1]); |
31 search_paths[1] = search_paths[1].AppendASCII("gen"); | 32 search_paths[1] = search_paths[1].AppendASCII("gen"); |
32 return search_paths; | 33 return search_paths; |
33 } | 34 } |
34 | 35 |
35 void StartCallback(base::WeakPtr<gin::Runner> runner, | 36 void StartCallback(base::WeakPtr<gin::Runner> runner, |
36 MojoHandle pipe, | 37 MojoHandle pipe, |
37 v8::Handle<v8::Value> module) { | 38 v8::Handle<v8::Value> module) { |
38 v8::Isolate* isolate = runner->GetContextHolder()->isolate(); | 39 v8::Isolate* isolate = runner->GetContextHolder()->isolate(); |
39 v8::Handle<v8::Function> start; | 40 v8::Handle<v8::Function> start; |
40 CHECK(gin::ConvertFromV8(isolate, module, &start)); | 41 CHECK(gin::ConvertFromV8(isolate, module, &start)); |
41 | 42 |
42 v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, pipe) }; | 43 v8::Handle<v8::Value> args[] = { |
| 44 gin::ConvertToV8(isolate, mojo::Handle(pipe)) }; |
43 runner->Call(start, runner->global(), 1, args); | 45 runner->Call(start, runner->global(), 1, args); |
44 } | 46 } |
45 | 47 |
46 } // namespace | 48 } // namespace |
47 | 49 |
48 MojoRunnerDelegate::MojoRunnerDelegate() | 50 MojoRunnerDelegate::MojoRunnerDelegate() |
49 : ModuleRunnerDelegate(GetModuleSearchPaths()) { | 51 : ModuleRunnerDelegate(GetModuleSearchPaths()) { |
50 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule); | 52 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule); |
51 AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule); | 53 AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule); |
52 AddBuiltinModule(js::Core::kModuleName, js::Core::GetModule); | 54 AddBuiltinModule(js::Core::kModuleName, js::Core::GetModule); |
(...skipping 18 matching lines...) Expand all Loading... |
71 } | 73 } |
72 | 74 |
73 void MojoRunnerDelegate::UnhandledException(gin::ShellRunner* runner, | 75 void MojoRunnerDelegate::UnhandledException(gin::ShellRunner* runner, |
74 gin::TryCatch& try_catch) { | 76 gin::TryCatch& try_catch) { |
75 gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch); | 77 gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch); |
76 LOG(ERROR) << try_catch.GetStackTrace(); | 78 LOG(ERROR) << try_catch.GetStackTrace(); |
77 } | 79 } |
78 | 80 |
79 } // namespace apps | 81 } // namespace apps |
80 } // namespace mojo | 82 } // namespace mojo |
OLD | NEW |