| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package bindings | 5 package bindings |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" |
| 8 "mojo/public/go/system" | 9 "mojo/public/go/system" |
| 9 ) | 10 ) |
| 10 | 11 |
| 11 // MessagePipeHandleOwner owns a message pipe handle, it can only pass it | 12 // MessagePipeHandleOwner owns a message pipe handle, it can only pass it |
| 12 // invalidating itself or close it. | 13 // invalidating itself or close it. |
| 13 type MessagePipeHandleOwner struct { | 14 type MessagePipeHandleOwner struct { |
| 14 handle system.MessagePipeHandle | 15 handle system.MessagePipeHandle |
| 15 } | 16 } |
| 16 | 17 |
| 17 // PassMessagePipe passes ownership of the underlying message pipe handle to | 18 // PassMessagePipe passes ownership of the underlying message pipe handle to |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 MessagePipeHandleOwner | 54 MessagePipeHandleOwner |
| 54 } | 55 } |
| 55 | 56 |
| 56 // CreateMessagePipeForInterface creates a message pipe with interface request | 57 // CreateMessagePipeForInterface creates a message pipe with interface request |
| 57 // on one end and interface pointer on the other end. The interface request | 58 // on one end and interface pointer on the other end. The interface request |
| 58 // should be attached to appropriate mojo interface implementation and | 59 // should be attached to appropriate mojo interface implementation and |
| 59 // the interface pointer should be attached to mojo interface proxy. | 60 // the interface pointer should be attached to mojo interface proxy. |
| 60 func CreateMessagePipeForMojoInterface() (InterfaceRequest, InterfacePointer) { | 61 func CreateMessagePipeForMojoInterface() (InterfaceRequest, InterfacePointer) { |
| 61 r, h0, h1 := system.GetCore().CreateMessagePipe(nil) | 62 r, h0, h1 := system.GetCore().CreateMessagePipe(nil) |
| 62 if r != system.MOJO_RESULT_OK { | 63 if r != system.MOJO_RESULT_OK { |
| 63 » » panic("can't create a message pipe") | 64 » » panic(fmt.Sprintf("can't create a message pipe: %v", r)) |
| 64 } | 65 } |
| 65 return InterfaceRequest{MessagePipeHandleOwner{h0}}, InterfacePointer{Me
ssagePipeHandleOwner{h1}} | 66 return InterfaceRequest{MessagePipeHandleOwner{h0}}, InterfacePointer{Me
ssagePipeHandleOwner{h1}} |
| 66 } | 67 } |
| OLD | NEW |