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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 std::vector<base::FilePath> search_paths(2); | 28 std::vector<base::FilePath> search_paths(2); |
29 PathService::Get(base::DIR_SOURCE_ROOT, &search_paths[0]); | 29 PathService::Get(base::DIR_SOURCE_ROOT, &search_paths[0]); |
30 PathService::Get(base::DIR_EXE, &search_paths[1]); | 30 PathService::Get(base::DIR_EXE, &search_paths[1]); |
31 search_paths[1] = search_paths[1].AppendASCII("gen"); | 31 search_paths[1] = search_paths[1].AppendASCII("gen"); |
32 return search_paths; | 32 return search_paths; |
33 } | 33 } |
34 | 34 |
35 void StartCallback(base::WeakPtr<gin::Runner> runner, | 35 void StartCallback(base::WeakPtr<gin::Runner> runner, |
36 MojoHandle pipe, | 36 MojoHandle pipe, |
37 v8::Handle<v8::Value> module) { | 37 v8::Handle<v8::Value> module) { |
38 v8::Isolate* isolate = runner->isolate(); | 38 v8::Isolate* isolate = runner->GetContextHolder()->isolate(); |
39 v8::Handle<v8::Function> start; | 39 v8::Handle<v8::Function> start; |
40 CHECK(gin::ConvertFromV8(isolate, module, &start)); | 40 CHECK(gin::ConvertFromV8(isolate, module, &start)); |
41 | 41 |
42 v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, pipe) }; | 42 v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, pipe) }; |
43 runner->Call(start, runner->global(), 1, args); | 43 runner->Call(start, runner->global(), 1, args); |
44 } | 44 } |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 MojoRunnerDelegate::MojoRunnerDelegate() | 48 MojoRunnerDelegate::MojoRunnerDelegate() |
49 : ModuleRunnerDelegate(GetModuleSearchPaths()) { | 49 : ModuleRunnerDelegate(GetModuleSearchPaths()) { |
50 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule); | 50 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule); |
51 AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule); | 51 AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule); |
52 AddBuiltinModule(js::Core::kModuleName, js::Core::GetModule); | 52 AddBuiltinModule(js::Core::kModuleName, js::Core::GetModule); |
53 AddBuiltinModule(js::Support::kModuleName, js::Support::GetModule); | 53 AddBuiltinModule(js::Support::kModuleName, js::Support::GetModule); |
54 AddBuiltinModule(mojo::js::gl::kModuleName, mojo::js::gl::GetModule); | 54 AddBuiltinModule(mojo::js::gl::kModuleName, mojo::js::gl::GetModule); |
55 AddBuiltinModule(MonotonicClock::kModuleName, MonotonicClock::GetModule); | 55 AddBuiltinModule(MonotonicClock::kModuleName, MonotonicClock::GetModule); |
56 AddBuiltinModule(Threading::kModuleName, Threading::GetModule); | 56 AddBuiltinModule(Threading::kModuleName, Threading::GetModule); |
57 } | 57 } |
58 | 58 |
59 MojoRunnerDelegate::~MojoRunnerDelegate() { | 59 MojoRunnerDelegate::~MojoRunnerDelegate() { |
60 } | 60 } |
61 | 61 |
62 void MojoRunnerDelegate::Start(gin::Runner* runner, | 62 void MojoRunnerDelegate::Start(gin::Runner* runner, |
63 MojoHandle pipe, | 63 MojoHandle pipe, |
64 const std::string& module) { | 64 const std::string& module) { |
65 gin::Runner::Scope scope(runner); | 65 gin::Runner::Scope scope(runner); |
66 gin::ModuleRegistry* registry = gin::ModuleRegistry::From(runner->context()); | 66 gin::ModuleRegistry* registry = |
67 registry->LoadModule(runner->isolate(), module, | 67 gin::ModuleRegistry::From(runner->GetContextHolder()->context()); |
| 68 registry->LoadModule(runner->GetContextHolder()->isolate(), module, |
68 base::Bind(StartCallback, runner->GetWeakPtr(), pipe)); | 69 base::Bind(StartCallback, runner->GetWeakPtr(), pipe)); |
69 AttemptToLoadMoreModules(runner); | 70 AttemptToLoadMoreModules(runner); |
70 } | 71 } |
71 | 72 |
72 void MojoRunnerDelegate::UnhandledException(gin::Runner* runner, | 73 void MojoRunnerDelegate::UnhandledException(gin::ShellRunner* runner, |
73 gin::TryCatch& try_catch) { | 74 gin::TryCatch& try_catch) { |
74 gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch); | 75 gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch); |
75 LOG(ERROR) << try_catch.GetStackTrace(); | 76 LOG(ERROR) << try_catch.GetStackTrace(); |
76 } | 77 } |
77 | 78 |
78 } // namespace apps | 79 } // namespace apps |
79 } // namespace mojo | 80 } // namespace mojo |
OLD | NEW |