Chromium Code Reviews| 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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/interface_ptr.h" | 10 #include "mojo/public/cpp/bindings/interface_ptr.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 // collector->RegisterSource(std::move(source)); | 110 // collector->RegisterSource(std::move(source)); |
| 111 // CreateSource(std::move(source_request)); // Create implementation locally. | 111 // CreateSource(std::move(source_request)); // Create implementation locally. |
| 112 // | 112 // |
| 113 template <typename Interface> | 113 template <typename Interface> |
| 114 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) { | 114 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) { |
| 115 MessagePipe pipe; | 115 MessagePipe pipe; |
| 116 ptr->Bind(InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u)); | 116 ptr->Bind(InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u)); |
| 117 return MakeRequest<Interface>(std::move(pipe.handle1)); | 117 return MakeRequest<Interface>(std::move(pipe.handle1)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Fuses an InterfaceRequest<T> endpoint with an InterfacePtr<T> endpoint. | |
|
yzshen1
2016/03/11 17:17:20
Nit: InterfacePtrInfo
| |
| 121 // Returns |true| on success or |false| on failure. | |
| 122 template <typename Interface> | |
| 123 bool FuseInterface(InterfaceRequest<Interface> request, | |
| 124 InterfacePtrInfo<Interface> proxy_info) { | |
| 125 MojoResult result = FuseMessagePipes(request.PassMessagePipe(), | |
| 126 proxy_info.PassHandle()); | |
| 127 return result == MOJO_RESULT_OK; | |
| 128 } | |
| 129 | |
| 120 } // namespace mojo | 130 } // namespace mojo |
| 121 | 131 |
| 122 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ | 132 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ |
| OLD | NEW |