Chromium Code Reviews| 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/threading.h" | 5 #include "mojo/apps/js/threading.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "gin/function_template.h" | 9 #include "gin/function_template.h" |
| 10 #include "gin/object_template_builder.h" | |
| 10 #include "gin/per_isolate_data.h" | 11 #include "gin/per_isolate_data.h" |
| 11 #include "mojo/public/bindings/js/handle.h" | 12 #include "mojo/public/bindings/js/handle.h" |
| 12 | 13 |
| 13 namespace mojo { | 14 namespace mojo { |
| 14 namespace apps { | 15 namespace apps { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 void Quit() { | 19 void Quit() { |
| 19 base::MessageLoop::current()->QuitNow(); | 20 base::MessageLoop::current()->QuitNow(); |
| 20 } | 21 } |
| 21 | 22 |
| 22 gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin }; | 23 gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin }; |
| 23 | 24 |
| 24 } // namespace | 25 } // namespace |
| 25 | 26 |
| 26 const char Threading::kModuleName[] = "mojo/apps/js/threading"; | 27 const char Threading::kModuleName[] = "mojo/apps/js/threading"; |
| 27 | 28 |
| 28 v8::Local<v8::ObjectTemplate> Threading::GetTemplate(v8::Isolate* isolate) { | 29 v8::Local<v8::ObjectTemplate> Threading::GetTemplate(v8::Isolate* isolate) { |
| 29 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); | 30 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); |
| 30 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate( | 31 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate( |
| 31 &g_wrapper_info); | 32 &g_wrapper_info); |
| 32 | 33 |
| 33 if (templ.IsEmpty()) { | 34 if (templ.IsEmpty()) { |
| 34 templ = v8::ObjectTemplate::New(); | 35 // Don't forget to call SetInitialHandle before getting the template. |
| 35 templ->Set(gin::StringToSymbol(isolate, "quit"), | 36 DCHECK(g_initial_handle != MOJO_HANDLE_INVALID); |
|
abarth-chromium
2013/11/28 06:27:09
This is gone now. You can delete these lines.
Aaron Boodman
2013/11/28 18:25:22
Done.
| |
| 36 gin::CreateFunctionTemplate(isolate, base::Bind(Quit))); | 37 |
| 38 gin::ObjectTemplateBuilder builder(isolate); | |
| 39 templ = builder | |
| 40 .SetMethod("quit", Quit) | |
| 41 .Build(); | |
| 42 | |
| 37 data->SetObjectTemplate(&g_wrapper_info, templ); | 43 data->SetObjectTemplate(&g_wrapper_info, templ); |
| 38 } | 44 } |
| 39 | 45 |
| 40 return templ; | 46 return templ; |
| 41 } | 47 } |
| 42 | 48 |
| 43 } // namespace apps | 49 } // namespace apps |
| 44 } // namespace mojo | 50 } // namespace mojo |
| OLD | NEW |