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

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

Issue 129633005: Introduce a monotonic_clock module for Mojo.js. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blech Created 6 years, 11 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 | « mojo/apps/js/main.js ('k') | mojo/apps/js/test/run_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/core.h" 14 #include "mojo/apps/js/bindings/core.h"
15 #include "mojo/apps/js/bindings/gl/module.h" 15 #include "mojo/apps/js/bindings/gl/module.h"
16 #include "mojo/apps/js/bindings/monotonic_clock.h"
16 #include "mojo/apps/js/bindings/support.h" 17 #include "mojo/apps/js/bindings/support.h"
17 #include "mojo/apps/js/bindings/threading.h" 18 #include "mojo/apps/js/bindings/threading.h"
18 19
19 namespace mojo { 20 namespace mojo {
20 namespace apps { 21 namespace apps {
21 22
22 namespace { 23 namespace {
23 24
24 // TODO(abarth): Rather than loading these modules from the file system, we 25 // TODO(abarth): Rather than loading these modules from the file system, we
25 // should load them from the network via Mojo IPC. 26 // should load them from the network via Mojo IPC.
(...skipping 18 matching lines...) Expand all
44 45
45 } // namespace 46 } // namespace
46 47
47 MojoRunnerDelegate::MojoRunnerDelegate() 48 MojoRunnerDelegate::MojoRunnerDelegate()
48 : ModuleRunnerDelegate(GetModuleSearchPaths()) { 49 : ModuleRunnerDelegate(GetModuleSearchPaths()) {
49 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule); 50 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule);
50 AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule); 51 AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule);
51 AddBuiltinModule(js::Core::kModuleName, js::Core::GetModule); 52 AddBuiltinModule(js::Core::kModuleName, js::Core::GetModule);
52 AddBuiltinModule(js::Support::kModuleName, js::Support::GetModule); 53 AddBuiltinModule(js::Support::kModuleName, js::Support::GetModule);
53 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);
54 AddBuiltinModule(Threading::kModuleName, Threading::GetModule); 56 AddBuiltinModule(Threading::kModuleName, Threading::GetModule);
55 } 57 }
56 58
57 MojoRunnerDelegate::~MojoRunnerDelegate() { 59 MojoRunnerDelegate::~MojoRunnerDelegate() {
58 } 60 }
59 61
60 void MojoRunnerDelegate::Start(gin::Runner* runner, 62 void MojoRunnerDelegate::Start(gin::Runner* runner,
61 MojoHandle pipe, 63 MojoHandle pipe,
62 const std::string& module) { 64 const std::string& module) {
63 gin::Runner::Scope scope(runner); 65 gin::Runner::Scope scope(runner);
64 gin::ModuleRegistry* registry = gin::ModuleRegistry::From(runner->context()); 66 gin::ModuleRegistry* registry = gin::ModuleRegistry::From(runner->context());
65 registry->LoadModule(runner->isolate(), module, 67 registry->LoadModule(runner->isolate(), module,
66 base::Bind(StartCallback, runner->GetWeakPtr(), pipe)); 68 base::Bind(StartCallback, runner->GetWeakPtr(), pipe));
67 AttemptToLoadMoreModules(runner); 69 AttemptToLoadMoreModules(runner);
68 } 70 }
69 71
70 void MojoRunnerDelegate::UnhandledException(gin::Runner* runner, 72 void MojoRunnerDelegate::UnhandledException(gin::Runner* runner,
71 gin::TryCatch& try_catch) { 73 gin::TryCatch& try_catch) {
72 gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch); 74 gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch);
73 LOG(ERROR) << try_catch.GetStackTrace(); 75 LOG(ERROR) << try_catch.GetStackTrace();
74 } 76 }
75 77
76 } // namespace apps 78 } // namespace apps
77 } // namespace mojo 79 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/apps/js/main.js ('k') | mojo/apps/js/test/run_js_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698