Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1291)

Side by Side Diff: mojo/apps/js/mojo_runner_delegate.cc

Issue 294123008: Mojo: Reimplement unicode.js in JavaScript, remove native implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/web_ui_runner.cc ('k') | mojo/apps/js/test/run_apps_js_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/handle.h"
19 #include "mojo/bindings/js/support.h" 19 #include "mojo/bindings/js/support.h"
20 #include "mojo/bindings/js/unicode.h"
21 20
22 namespace mojo { 21 namespace mojo {
23 namespace apps { 22 namespace apps {
24 23
25 namespace { 24 namespace {
26 25
27 // 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
28 // should load them from the network via Mojo IPC. 27 // should load them from the network via Mojo IPC.
29 std::vector<base::FilePath> GetModuleSearchPaths() { 28 std::vector<base::FilePath> GetModuleSearchPaths() {
30 std::vector<base::FilePath> search_paths(2); 29 std::vector<base::FilePath> search_paths(2);
(...skipping 16 matching lines...) Expand all
47 } 46 }
48 47
49 } // namespace 48 } // namespace
50 49
51 MojoRunnerDelegate::MojoRunnerDelegate() 50 MojoRunnerDelegate::MojoRunnerDelegate()
52 : ModuleRunnerDelegate(GetModuleSearchPaths()) { 51 : ModuleRunnerDelegate(GetModuleSearchPaths()) {
53 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule); 52 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule);
54 AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule); 53 AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule);
55 AddBuiltinModule(js::Core::kModuleName, js::Core::GetModule); 54 AddBuiltinModule(js::Core::kModuleName, js::Core::GetModule);
56 AddBuiltinModule(js::Support::kModuleName, js::Support::GetModule); 55 AddBuiltinModule(js::Support::kModuleName, js::Support::GetModule);
57 AddBuiltinModule(js::Unicode::kModuleName, js::Unicode::GetModule);
58 AddBuiltinModule(js::gl::kModuleName, js::gl::GetModule); 56 AddBuiltinModule(js::gl::kModuleName, js::gl::GetModule);
59 AddBuiltinModule(MonotonicClock::kModuleName, MonotonicClock::GetModule); 57 AddBuiltinModule(MonotonicClock::kModuleName, MonotonicClock::GetModule);
60 AddBuiltinModule(Threading::kModuleName, Threading::GetModule); 58 AddBuiltinModule(Threading::kModuleName, Threading::GetModule);
61 } 59 }
62 60
63 MojoRunnerDelegate::~MojoRunnerDelegate() { 61 MojoRunnerDelegate::~MojoRunnerDelegate() {
64 } 62 }
65 63
66 void MojoRunnerDelegate::Start(gin::Runner* runner, 64 void MojoRunnerDelegate::Start(gin::Runner* runner,
67 MojoHandle pipe, 65 MojoHandle pipe,
68 const std::string& module) { 66 const std::string& module) {
69 gin::Runner::Scope scope(runner); 67 gin::Runner::Scope scope(runner);
70 gin::ModuleRegistry* registry = 68 gin::ModuleRegistry* registry =
71 gin::ModuleRegistry::From(runner->GetContextHolder()->context()); 69 gin::ModuleRegistry::From(runner->GetContextHolder()->context());
72 registry->LoadModule(runner->GetContextHolder()->isolate(), module, 70 registry->LoadModule(runner->GetContextHolder()->isolate(), module,
73 base::Bind(StartCallback, runner->GetWeakPtr(), pipe)); 71 base::Bind(StartCallback, runner->GetWeakPtr(), pipe));
74 AttemptToLoadMoreModules(runner); 72 AttemptToLoadMoreModules(runner);
75 } 73 }
76 74
77 void MojoRunnerDelegate::UnhandledException(gin::ShellRunner* runner, 75 void MojoRunnerDelegate::UnhandledException(gin::ShellRunner* runner,
78 gin::TryCatch& try_catch) { 76 gin::TryCatch& try_catch) {
79 gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch); 77 gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch);
80 LOG(ERROR) << try_catch.GetStackTrace(); 78 LOG(ERROR) << try_catch.GetStackTrace();
81 } 79 }
82 80
83 } // namespace apps 81 } // namespace apps
84 } // namespace mojo 82 } // namespace mojo
OLDNEW
« no previous file with comments | « content/renderer/web_ui_runner.cc ('k') | mojo/apps/js/test/run_apps_js_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698