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

Unified Diff: mojo/public/bindings/js/v8_mojo.cc

Issue 59153005: Begin implementing V8 bindings for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix style nits Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/bindings/js/v8_mojo.cc
diff --git a/mojo/public/bindings/js/v8_mojo.cc b/mojo/public/bindings/js/v8_mojo.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bf05e15fdabd0d439a5d5287dd169a79b1518745
--- /dev/null
+++ b/mojo/public/bindings/js/v8_mojo.cc
@@ -0,0 +1,49 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/public/bindings/js/v8_mojo.h"
+
+#include "mojo/public/bindings/js/v8_core.h"
+
+namespace mojo {
+namespace js {
+
+namespace {
+
+void CreateMessagePipeCallback(
+ const v8::FunctionCallbackInfo<v8::Value>& info) {
+ v8::Isolate* isolate = info.GetIsolate();
+
+ mojo::Handle handle_0;
+ mojo::Handle handle_1;
+ MojoResult result = mojo::CreateMessagePipe(&handle_0, &handle_1);
+
+ v8::Handle<v8::Object> object = v8::Object::New();
+ object->Set(v8::String::NewSymbol("result"),
+ Wrapper<MojoResult>::ToObject(isolate, result));
+ object->Set(v8::String::NewSymbol("handle0"),
+ Wrapper<mojo::Handle>::ToObject(isolate, handle_0));
+ object->Set(v8::String::NewSymbol("handle1"),
+ Wrapper<mojo::Handle>::ToObject(isolate, handle_0));
+ info.GetReturnValue().Set(object);
+}
+
+// TODO(abarth): Implement this functions:
+//
+// MojoResult WaitMany(const Handle* handles,
+// const MojoWaitFlags* flags,
+// uint32_t num_handles,
+// MojoDeadline deadline);
+
+}
+
+v8::Local<v8::ObjectTemplate> CreateMojoTemplate() {
+ v8::Local<v8::ObjectTemplate> mojo_template = v8::ObjectTemplate::New();
+ mojo_template->Set(v8::String::NewSymbol("createMessagePipe"),
+ v8::FunctionTemplate::New(CreateMessagePipeCallback));
+ return mojo_template;
+}
+
+} // namespace js
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698