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

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

Issue 126743002: Make the cube spin in the JS mojo app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blah 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
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/try_catch.h" 13 #include "gin/try_catch.h"
13 #include "mojo/apps/js/bindings/core.h" 14 #include "mojo/apps/js/bindings/core.h"
14 #include "mojo/apps/js/bindings/gl/module.h" 15 #include "mojo/apps/js/bindings/gl/module.h"
15 #include "mojo/apps/js/bindings/support.h" 16 #include "mojo/apps/js/bindings/support.h"
16 #include "mojo/apps/js/bindings/threading.h" 17 #include "mojo/apps/js/bindings/threading.h"
17 18
18 namespace mojo { 19 namespace mojo {
19 namespace apps { 20 namespace apps {
20 21
21 namespace { 22 namespace {
(...skipping 17 matching lines...) Expand all
39 40
40 v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, pipe) }; 41 v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, pipe) };
41 runner->Call(start, runner->global(), 1, args); 42 runner->Call(start, runner->global(), 1, args);
42 } 43 }
43 44
44 } // namespace 45 } // namespace
45 46
46 MojoRunnerDelegate::MojoRunnerDelegate() 47 MojoRunnerDelegate::MojoRunnerDelegate()
47 : ModuleRunnerDelegate(GetModuleSearchPaths()) { 48 : ModuleRunnerDelegate(GetModuleSearchPaths()) {
48 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule); 49 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule);
50 AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule);
abarth-chromium 2014/01/07 23:01:04 Should we change the other kModuleNames to kName f
Aaron Boodman 2014/01/07 23:22:38 The reason Timer is different is because there are
49 AddBuiltinModule(js::Core::kModuleName, js::Core::GetModule); 51 AddBuiltinModule(js::Core::kModuleName, js::Core::GetModule);
50 AddBuiltinModule(js::Support::kModuleName, js::Support::GetModule); 52 AddBuiltinModule(js::Support::kModuleName, js::Support::GetModule);
51 AddBuiltinModule(mojo::js::gl::kModuleName, mojo::js::gl::GetModule); 53 AddBuiltinModule(mojo::js::gl::kModuleName, mojo::js::gl::GetModule);
52 AddBuiltinModule(Threading::kModuleName, Threading::GetModule); 54 AddBuiltinModule(Threading::kModuleName, Threading::GetModule);
53 } 55 }
54 56
55 MojoRunnerDelegate::~MojoRunnerDelegate() { 57 MojoRunnerDelegate::~MojoRunnerDelegate() {
56 } 58 }
57 59
58 void MojoRunnerDelegate::Start(gin::Runner* runner, 60 void MojoRunnerDelegate::Start(gin::Runner* runner,
59 MojoHandle pipe, 61 MojoHandle pipe,
60 const std::string& module) { 62 const std::string& module) {
61 gin::Runner::Scope scope(runner); 63 gin::Runner::Scope scope(runner);
62 gin::ModuleRegistry* registry = gin::ModuleRegistry::From(runner->context()); 64 gin::ModuleRegistry* registry = gin::ModuleRegistry::From(runner->context());
63 registry->LoadModule(runner->isolate(), module, 65 registry->LoadModule(runner->isolate(), module,
64 base::Bind(StartCallback, runner->GetWeakPtr(), pipe)); 66 base::Bind(StartCallback, runner->GetWeakPtr(), pipe));
65 AttemptToLoadMoreModules(runner); 67 AttemptToLoadMoreModules(runner);
66 } 68 }
67 69
68 void MojoRunnerDelegate::UnhandledException(gin::Runner* runner, 70 void MojoRunnerDelegate::UnhandledException(gin::Runner* runner,
69 gin::TryCatch& try_catch) { 71 gin::TryCatch& try_catch) {
70 gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch); 72 gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch);
71 LOG(ERROR) << try_catch.GetStackTrace(); 73 LOG(ERROR) << try_catch.GetStackTrace();
72 } 74 }
73 75
74 } // namespace apps 76 } // namespace apps
75 } // namespace mojo 77 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698