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

Unified Diff: third_party/mojo/src/mojo/public/go/bindings/interface.go

Issue 954643002: Update mojo sdk to rev 3d23dae011859a2aae49f1d1adde705c8e85d819 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use run_renderer_in_process() Created 5 years, 10 months 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: third_party/mojo/src/mojo/public/go/bindings/interface.go
diff --git a/third_party/mojo/src/mojo/public/go/bindings/interface.go b/third_party/mojo/src/mojo/public/go/bindings/interface.go
new file mode 100644
index 0000000000000000000000000000000000000000..03ab791d844989eb8adbac0844f8d19f9397297f
--- /dev/null
+++ b/third_party/mojo/src/mojo/public/go/bindings/interface.go
@@ -0,0 +1,60 @@
+// Copyright 2015 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.
+
+package bindings
+
+import (
+ "mojo/public/go/system"
+)
+
+// messagePipeHandleOwner owns a message pipe handle, it can only pass it
+// invalidating itself or close it.
+type messagePipeHandleOwner struct {
+ handle system.MessagePipeHandle
+}
+
+// PassMessagePipe passes ownership of the underlying message pipe handle to
+// the newly created handle object, invalidating the underlying handle object
+// in the process.
+func (o *messagePipeHandleOwner) PassMessagePipe() system.MessagePipeHandle {
+ if o.handle == nil {
+ return &InvalidHandle{}
+ }
+ return o.handle.ToUntypedHandle().ToMessagePipeHandle()
+}
+
+// Close closes the underlying handle.
+func (o *messagePipeHandleOwner) Close() {
+ if o.handle != nil {
+ o.handle.Close()
+ }
+}
+
+// InterfaceRequest represents a request from a remote client for an
+// implementation of mojo interface over a specified message pipe. The
+// implementor of the interface should remove the message pipe by calling
+// PassMessagePipe() and attach it to the implementation.
+type InterfaceRequest struct {
+ messagePipeHandleOwner
+}
+
+// InterfacePointer owns a message pipe handle with an implementation of mojo
+// interface attached to the other end of the message pipe. The client of the
+// interface should remove the message pipe by calling PassMessagePipe() and
+// attach it to the proxy.
+type InterfacePointer struct {
+ messagePipeHandleOwner
+}
+
+// CreateMessagePipeForInterface creates a message pipe with interface request
+// on one end and interface pointer on the other end. The interface request
+// should be attached to appropriate mojo interface implementation and
+// the interface pointer should be attached to mojo interface proxy.
+func CreateMessagePipeForMojoInterface() (InterfaceRequest, InterfacePointer) {
+ r, h0, h1 := system.GetCore().CreateMessagePipe(nil)
+ if r != system.MOJO_RESULT_OK {
+ panic("can't create a message pipe")
+ }
+ return InterfaceRequest{messagePipeHandleOwner{h0}}, InterfacePointer{messagePipeHandleOwner{h1}}
+}
« no previous file with comments | « third_party/mojo/src/mojo/public/go/bindings/encoder.go ('k') | third_party/mojo/src/mojo/public/go/bindings/message.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698