| 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/bindings/support.h" | 5 #include "mojo/bindings/js/support.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "gin/arguments.h" | 8 #include "gin/arguments.h" |
| 9 #include "gin/converter.h" | 9 #include "gin/converter.h" |
| 10 #include "gin/function_template.h" | 10 #include "gin/function_template.h" |
| 11 #include "gin/object_template_builder.h" | 11 #include "gin/object_template_builder.h" |
| 12 #include "gin/per_isolate_data.h" | 12 #include "gin/per_isolate_data.h" |
| 13 #include "gin/public/wrapper_info.h" | 13 #include "gin/public/wrapper_info.h" |
| 14 #include "gin/wrappable.h" | 14 #include "gin/wrappable.h" |
| 15 #include "mojo/apps/js/bindings/handle.h" | 15 #include "mojo/bindings/js/handle.h" |
| 16 #include "mojo/apps/js/bindings/waiting_callback.h" | 16 #include "mojo/bindings/js/waiting_callback.h" |
| 17 #include "mojo/public/environment/default_async_waiter.h" | 17 #include "mojo/public/environment/default_async_waiter.h" |
| 18 #include "mojo/public/system/core_cpp.h" | 18 #include "mojo/public/system/core_cpp.h" |
| 19 | 19 |
| 20 namespace mojo { | 20 namespace mojo { |
| 21 namespace js { | 21 namespace js { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 WaitingCallback* AsyncWait(const gin::Arguments& args, mojo::Handle handle, | 25 WaitingCallback* AsyncWait(const gin::Arguments& args, mojo::Handle handle, |
| 26 MojoWaitFlags flags, | 26 MojoWaitFlags flags, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 | 48 |
| 49 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter(); | 49 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter(); |
| 50 waiter->CancelWait(waiter, waiting_callback->wait_id()); | 50 waiter->CancelWait(waiter, waiting_callback->wait_id()); |
| 51 waiting_callback->set_wait_id(0); | 51 waiting_callback->set_wait_id(0); |
| 52 } | 52 } |
| 53 | 53 |
| 54 gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin }; | 54 gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin }; |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| 57 | 57 |
| 58 const char Support::kModuleName[] = "mojo/apps/js/bindings/support"; | 58 const char Support::kModuleName[] = "mojo/bindings/js/support"; |
| 59 | 59 |
| 60 v8::Local<v8::Value> Support::GetModule(v8::Isolate* isolate) { | 60 v8::Local<v8::Value> Support::GetModule(v8::Isolate* isolate) { |
| 61 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); | 61 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); |
| 62 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate( | 62 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate( |
| 63 &g_wrapper_info); | 63 &g_wrapper_info); |
| 64 | 64 |
| 65 if (templ.IsEmpty()) { | 65 if (templ.IsEmpty()) { |
| 66 templ = gin::ObjectTemplateBuilder(isolate) | 66 templ = gin::ObjectTemplateBuilder(isolate) |
| 67 .SetMethod("asyncWait", AsyncWait) | 67 .SetMethod("asyncWait", AsyncWait) |
| 68 .SetMethod("cancelWait", CancelWait) | 68 .SetMethod("cancelWait", CancelWait) |
| 69 .Build(); | 69 .Build(); |
| 70 | 70 |
| 71 data->SetObjectTemplate(&g_wrapper_info, templ); | 71 data->SetObjectTemplate(&g_wrapper_info, templ); |
| 72 } | 72 } |
| 73 | 73 |
| 74 return templ->NewInstance(); | 74 return templ->NewInstance(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace js | 77 } // namespace js |
| 78 } // namespace mojo | 78 } // namespace mojo |
| OLD | NEW |