OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "mojo/public/bindings/js/v8_mojo.h" |
| 6 |
| 7 #include "mojo/public/bindings/js/v8_core.h" |
| 8 |
| 9 namespace mojo { |
| 10 namespace js { |
| 11 |
| 12 namespace { |
| 13 |
| 14 void CreateMessagePipeCallback( |
| 15 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 16 v8::Isolate* isolate = info.GetIsolate(); |
| 17 |
| 18 mojo::Handle handle_0; |
| 19 mojo::Handle handle_1; |
| 20 MojoResult result = mojo::CreateMessagePipe(&handle_0, &handle_1); |
| 21 |
| 22 v8::Handle<v8::Object> object = v8::Object::New(); |
| 23 object->Set(v8::String::NewSymbol("result"), |
| 24 Wrapper<MojoResult>::ToObject(isolate, result)); |
| 25 object->Set(v8::String::NewSymbol("handle0"), |
| 26 Wrapper<mojo::Handle>::ToObject(isolate, handle_0)); |
| 27 object->Set(v8::String::NewSymbol("handle1"), |
| 28 Wrapper<mojo::Handle>::ToObject(isolate, handle_0)); |
| 29 info.GetReturnValue().Set(object); |
| 30 } |
| 31 |
| 32 // TODO(abarth): Implement this functions: |
| 33 // |
| 34 // MojoResult WaitMany(const Handle* handles, |
| 35 // const MojoWaitFlags* flags, |
| 36 // uint32_t num_handles, |
| 37 // MojoDeadline deadline); |
| 38 |
| 39 } |
| 40 |
| 41 v8::Local<v8::ObjectTemplate> CreateMojoTemplate() { |
| 42 v8::Local<v8::ObjectTemplate> mojo_template = v8::ObjectTemplate::New(); |
| 43 mojo_template->Set(v8::String::NewSymbol("createMessagePipe"), |
| 44 v8::FunctionTemplate::New(CreateMessagePipeCallback)); |
| 45 return mojo_template; |
| 46 } |
| 47 |
| 48 } // namespace js |
| 49 } // namespace mojo |
OLD | NEW |