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

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

Issue 1682113003: Mojo C++ bindings: Generate InterfaceHandle<> instead of InterfacePtr<>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase ontop of master, address trung's comments Created 4 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 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 <cstddef> 8 #include <cstddef>
9 9
10 #include "mojo/public/cpp/system/message_pipe.h" 10 #include "mojo/public/cpp/system/message_pipe.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // collector->RegisterSource(source.Pass()); 115 // collector->RegisterSource(source.Pass());
116 // CreateSource(source_request.Pass()); // Create implementation locally. 116 // CreateSource(source_request.Pass()); // Create implementation locally.
117 // 117 //
118 template <typename Interface> 118 template <typename Interface>
119 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) { 119 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) {
120 MessagePipe pipe; 120 MessagePipe pipe;
121 ptr->Bind(InterfaceHandle<Interface>(pipe.handle0.Pass(), 0u)); 121 ptr->Bind(InterfaceHandle<Interface>(pipe.handle0.Pass(), 0u));
122 return MakeRequest<Interface>(pipe.handle1.Pass()); 122 return MakeRequest<Interface>(pipe.handle1.Pass());
123 } 123 }
124 124
125 // This is an overload of GetProxy() that assumes that the client end of the
126 // handle is an InterfaceHandle<>. It creates a new message pipe over which the
127 // Interface is to be served. InterfaceHandle<> represents the client's end,
128 // and InterfaceRequest<> should be used to bind to an implementation.
129 template <typename Interface>
130 InterfaceRequest<Interface> GetProxy(InterfaceHandle<Interface>* ptr) {
131 MessagePipe pipe;
132 *ptr = InterfaceHandle<Interface>(pipe.handle0.Pass(), 0u);
133 return MakeRequest<Interface>(pipe.handle1.Pass());
134 }
135
125 } // namespace mojo 136 } // namespace mojo
126 137
127 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ 138 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/interface_handle.h ('k') | mojo/public/cpp/bindings/lib/array_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698