| 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/core.h" | 5 #include "mojo/apps/js/bindings/core.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "gin/arguments.h" | 9 #include "gin/arguments.h" |
| 10 #include "gin/array_buffer.h" | 10 #include "gin/array_buffer.h" |
| 11 #include "gin/converter.h" | 11 #include "gin/converter.h" |
| 12 #include "gin/dictionary.h" | 12 #include "gin/dictionary.h" |
| 13 #include "gin/function_template.h" | 13 #include "gin/function_template.h" |
| 14 #include "gin/object_template_builder.h" | 14 #include "gin/object_template_builder.h" |
| 15 #include "gin/per_isolate_data.h" | 15 #include "gin/per_isolate_data.h" |
| 16 #include "gin/public/wrapper_info.h" | 16 #include "gin/public/wrapper_info.h" |
| 17 #include "mojo/apps/js/bindings/handle.h" | 17 #include "mojo/apps/js/bindings/handle.h" |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace mojo { |
| 20 namespace js { | 20 namespace js { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 gin::Dictionary CreateMessagePipe(const gin::Arguments& args) { | 24 gin::Dictionary CreateMessagePipe(const gin::Arguments& args) { |
| 25 MojoHandle handle_0 = MOJO_HANDLE_INVALID; | 25 MojoHandle handle0 = MOJO_HANDLE_INVALID; |
| 26 MojoHandle handle_1 = MOJO_HANDLE_INVALID; | 26 MojoHandle handle1 = MOJO_HANDLE_INVALID; |
| 27 MojoResult result = MojoCreateMessagePipe(&handle_0, &handle_1); | 27 MojoResult result = MojoCreateMessagePipe(&handle0, &handle1); |
| 28 CHECK(result == MOJO_RESULT_OK); | 28 CHECK(result == MOJO_RESULT_OK); |
| 29 | 29 |
| 30 gin::Dictionary dictionary = gin::Dictionary::CreateEmpty(args.isolate()); | 30 gin::Dictionary dictionary = gin::Dictionary::CreateEmpty(args.isolate()); |
| 31 dictionary.Set("handle0", handle_0); | 31 dictionary.Set("handle0", handle0); |
| 32 dictionary.Set("handle1", handle_1); | 32 dictionary.Set("handle1", handle1); |
| 33 return dictionary; | 33 return dictionary; |
| 34 } | 34 } |
| 35 | 35 |
| 36 MojoResult WriteMessage(MojoHandle handle, | 36 MojoResult WriteMessage(MojoHandle handle, |
| 37 const gin::ArrayBufferView& buffer, | 37 const gin::ArrayBufferView& buffer, |
| 38 const std::vector<MojoHandle>& handles, | 38 const std::vector<MojoHandle>& handles, |
| 39 MojoWriteMessageFlags flags) { | 39 MojoWriteMessageFlags flags) { |
| 40 return MojoWriteMessage(handle, | 40 return MojoWriteMessage(handle, |
| 41 buffer.bytes(), | 41 buffer.bytes(), |
| 42 static_cast<uint32_t>(buffer.num_bytes()), | 42 static_cast<uint32_t>(buffer.num_bytes()), |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 .Build(); | 141 .Build(); |
| 142 | 142 |
| 143 data->SetObjectTemplate(&g_wrapper_info, templ); | 143 data->SetObjectTemplate(&g_wrapper_info, templ); |
| 144 } | 144 } |
| 145 | 145 |
| 146 return templ->NewInstance(); | 146 return templ->NewInstance(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace js | 149 } // namespace js |
| 150 } // namespace mojo | 150 } // namespace mojo |
| OLD | NEW |