OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ |
7 | 7 |
8 #include "mojo/public/cpp/system/message_pipe.h" | 8 #include "mojo/public/cpp/system/message_pipe.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 MOJO_MOVE_ONLY_TYPE(InterfaceRequest); | 60 MOJO_MOVE_ONLY_TYPE(InterfaceRequest); |
61 }; | 61 }; |
62 | 62 |
63 // Makes an InterfaceRequest bound to the specified message pipe. If |handle| | 63 // Makes an InterfaceRequest bound to the specified message pipe. If |handle| |
64 // is empty or invalid, the resulting InterfaceRequest will represent the | 64 // is empty or invalid, the resulting InterfaceRequest will represent the |
65 // absence of a request. | 65 // absence of a request. |
66 template <typename Interface> | 66 template <typename Interface> |
67 InterfaceRequest<Interface> MakeRequest(ScopedMessagePipeHandle handle) { | 67 InterfaceRequest<Interface> MakeRequest(ScopedMessagePipeHandle handle) { |
68 InterfaceRequest<Interface> request; | 68 InterfaceRequest<Interface> request; |
69 request.Bind(handle.Pass()); | 69 request.Bind(handle.Pass()); |
70 return request.Pass(); | 70 return request; |
71 } | 71 } |
72 | 72 |
73 // Creates a new message pipe over which Interface is to be served. Binds the | 73 // Creates a new message pipe over which Interface is to be served. Binds the |
74 // specified InterfacePtr to one end of the message pipe, and returns an | 74 // specified InterfacePtr to one end of the message pipe, and returns an |
75 // InterfaceRequest bound to the other. The InterfacePtr should be passed to | 75 // InterfaceRequest bound to the other. The InterfacePtr should be passed to |
76 // the client, and the InterfaceRequest should be passed to whatever will | 76 // the client, and the InterfaceRequest should be passed to whatever will |
77 // provide the implementation. The implementation should typically be bound to | 77 // provide the implementation. The implementation should typically be bound to |
78 // the InterfaceRequest using the Binding or StrongBinding classes. The client | 78 // the InterfaceRequest using the Binding or StrongBinding classes. The client |
79 // may begin to issue calls even before an implementation has been bound, since | 79 // may begin to issue calls even before an implementation has been bound, since |
80 // messages sent over the pipe will just queue up until they are consumed by | 80 // messages sent over the pipe will just queue up until they are consumed by |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 template <typename Interface> | 116 template <typename Interface> |
117 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) { | 117 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) { |
118 MessagePipe pipe; | 118 MessagePipe pipe; |
119 ptr->Bind(InterfacePtrInfo<Interface>(pipe.handle0.Pass(), 0u)); | 119 ptr->Bind(InterfacePtrInfo<Interface>(pipe.handle0.Pass(), 0u)); |
120 return MakeRequest<Interface>(pipe.handle1.Pass()); | 120 return MakeRequest<Interface>(pipe.handle1.Pass()); |
121 } | 121 } |
122 | 122 |
123 } // namespace mojo | 123 } // namespace mojo |
124 | 124 |
125 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ | 125 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ |
OLD | NEW |