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

Side by Side Diff: mojo/public/cpp/bindings/interface_request.h

Issue 1785843002: [mojo] Implement pipe fusion API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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
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.
121 // Returns |true| on success or |false| on failure. Note that both arguments
122 // are invalidated regardless of the result.
123 template <typename Interface>
124 bool FuseProxy(InterfaceRequest<Interface> *request,
yzshen1 2016/03/10 23:49:03 How about the following signature: bool FuseInter
Ken Rockot(use gerrit already) 2016/03/11 00:32:46 Done
125 InterfacePtr<Interface>* proxy) {
126 ScopedMessagePipeHandle handle0 = request->PassMessagePipe();
127 ScopedMessagePipeHandle handle1 = proxy->PassInterface().PassHandle();
128 MojoResult result = FuseMessagePipes(&handle0, &handle1);
129 return result == MOJO_RESULT_OK;
130 }
131
120 } // namespace mojo 132 } // namespace mojo
121 133
122 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ 134 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698