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

Unified Diff: mojo/public/cpp/bindings/interface_request.h

Issue 2592623002: mojo:: Introduce InterfaceRequest ctor that takes in InterfacePtr* (Closed)
Patch Set: Rebase + response to review Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/remoting/remoting_cdm_factory.cc ('k') | mojo/public/cpp/bindings/tests/handle_passing_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/interface_request.h
diff --git a/mojo/public/cpp/bindings/interface_request.h b/mojo/public/cpp/bindings/interface_request.h
index 773e05dbd7f222b8227f529e5d2c6d09bbd7b465..ab237656cfb6d34885a4f8ef2a5793a58bafdcf5 100644
--- a/mojo/public/cpp/bindings/interface_request.h
+++ b/mojo/public/cpp/bindings/interface_request.h
@@ -31,6 +31,19 @@ class InterfaceRequest {
InterfaceRequest() {}
InterfaceRequest(decltype(nullptr)) {}
+ // Creates a new message pipe over which Interface is to be served, binding
+ // the specified InterfacePtr to one end of the message pipe and this
+ // InterfaceRequest to the other. For example usage, see comments on
+ // MakeRequest(InterfacePtr*) below.
+ explicit InterfaceRequest(InterfacePtr<Interface>* ptr,
+ scoped_refptr<base::SingleThreadTaskRunner> runner =
+ base::ThreadTaskRunnerHandle::Get()) {
+ MessagePipe pipe;
+ ptr->Bind(InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u),
+ std::move(runner));
+ Bind(std::move(pipe.handle1));
+ }
+
// Takes the message pipe from another InterfaceRequest.
InterfaceRequest(InterfaceRequest&& other) {
handle_ = std::move(other.handle_);
@@ -136,7 +149,7 @@ InterfaceRequest<Interface> MakeRequest(ScopedMessagePipeHandle handle) {
//
// CollectorPtr collector = ...; // Connect to Collector.
// SourcePtr source;
-// InterfaceRequest<Source> source_request = MakeRequest(&source);
+// InterfaceRequest<Source> source_request(&source);
// collector->RegisterSource(std::move(source));
// CreateSource(std::move(source_request)); // Create implementation locally.
//
@@ -145,10 +158,7 @@ InterfaceRequest<Interface> MakeRequest(
InterfacePtr<Interface>* ptr,
scoped_refptr<base::SingleThreadTaskRunner> runner =
base::ThreadTaskRunnerHandle::Get()) {
- MessagePipe pipe;
- ptr->Bind(InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u),
- std::move(runner));
- return MakeRequest<Interface>(std::move(pipe.handle1));
+ return InterfaceRequest<Interface>(ptr, runner);
}
// Fuses an InterfaceRequest<T> endpoint with an InterfacePtrInfo<T> endpoint.
« no previous file with comments | « media/remoting/remoting_cdm_factory.cc ('k') | mojo/public/cpp/bindings/tests/handle_passing_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698