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

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

Issue 637373002: Mojo JS bindings: simplify mojo.connectToService() usage - Part 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_module.h" 5 #include "mojo/apps/js/mojo_internals_module.h"
6 6
7 #include "gin/arguments.h" 7 #include "gin/arguments.h"
8 #include "gin/converter.h" 8 #include "gin/converter.h"
9 #include "gin/object_template_builder.h" 9 #include "gin/object_template_builder.h"
10 #include "gin/per_isolate_data.h" 10 #include "gin/per_isolate_data.h"
11 #include "mojo/apps/js/js_app.h" 11 #include "mojo/apps/js/js_app.h"
12 #include "mojo/apps/js/mojo_module.h"
13 #include "mojo/bindings/js/handle.h" 12 #include "mojo/bindings/js/handle.h"
14 #include "mojo/common/data_pipe_utils.h"
15 13
16 namespace mojo { 14 namespace mojo {
17 namespace apps { 15 namespace apps {
18 16
19 namespace { 17 namespace {
20 18
21 gin::WrapperInfo g_wrapper_info = {gin::kEmbedderNativeGin}; 19 gin::WrapperInfo g_wrapper_info = {gin::kEmbedderNativeGin};
22 20
23 } // namespace 21 } // namespace
24 22
25 const char Mojo::kModuleName[] = "mojo"; 23 const char MojoInternals::kModuleName[] = "mojo_internals";
abarth-chromium 2014/10/10 17:45:07 mojo/apps/js/bridge
hansmuller 2014/10/10 20:53:48 Done.
26 24
27 v8::Local<v8::Value> Mojo::GetModule(JSApp* js_app, v8::Isolate* isolate) { 25 v8::Local<v8::Value> MojoInternals::GetModule(JSApp* js_app,
26 v8::Isolate* isolate) {
28 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); 27 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate);
29 v8::Local<v8::ObjectTemplate> templ = 28 v8::Local<v8::ObjectTemplate> templ =
30 data->GetObjectTemplate(&g_wrapper_info); 29 data->GetObjectTemplate(&g_wrapper_info);
31 30
32 if (templ.IsEmpty()) { 31 if (templ.IsEmpty()) {
33 templ = gin::ObjectTemplateBuilder(isolate) 32 templ = gin::ObjectTemplateBuilder(isolate)
34 .SetMethod("connectToService", 33 .SetMethod("connectToService",
35 base::Bind(&JSApp::ConnectToService, 34 base::Bind(&JSApp::ConnectToService,
36 base::Unretained(js_app))) 35 base::Unretained(js_app)))
37 .SetMethod("quit", 36 .SetMethod("quit",
38 base::Bind(&JSApp::Quit, base::Unretained(js_app))) 37 base::Bind(&JSApp::Quit, base::Unretained(js_app)))
39 .Build(); 38 .Build();
40 data->SetObjectTemplate(&g_wrapper_info, templ); 39 data->SetObjectTemplate(&g_wrapper_info, templ);
41 } 40 }
42 41
43 return templ->NewInstance(); 42 return templ->NewInstance();
44 } 43 }
45 44
46 } // namespace apps 45 } // namespace apps
47 } // namespace mojo 46 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698