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

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

Issue 2086223002: Convert instant search messages to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/associated_interface_ptr.h
diff --git a/mojo/public/cpp/bindings/associated_interface_ptr.h b/mojo/public/cpp/bindings/associated_interface_ptr.h
index e760c7d34a053bf9ec57d9386dd15ecab1f12f63..5d83e48103c70227349c12c55900e684a63df9fd 100644
--- a/mojo/public/cpp/bindings/associated_interface_ptr.h
+++ b/mojo/public/cpp/bindings/associated_interface_ptr.h
@@ -204,7 +204,7 @@ class AssociatedInterfacePtr {
// Creates an associated interface. The output |ptr| should be used locally
// while the returned request should be passed through the message pipe endpoint
-// referred to by |associated_group| to setup the corresponding asssociated
+// referred to by |associated_group| to setup the corresponding associated
// interface implementation at the remote side.
//
// NOTE: |ptr| should NOT be used to make calls before the request is sent.
@@ -255,16 +255,41 @@ AssociatedInterfaceRequest<Interface> MakeRequestForTesting(
return request;
}
-// Creates an associated interface proxy which casts its messages into the void.
+// Like |GetProxy|, but the interface is never associated with any other
+// interface. The returned request can be bound directly to the corresponding
+// associated interface implementation, without first passing it through a
+// message pipe endpoint.
+//
+// This function has two main uses:
+//
+// * In testing, where the returned request is bound to e.g. a mock and there
+// are no other interfaces involved.
+//
+// * When discarding messages sent on an interface, which can be done by
+// discarding the returned request.
template <typename Interface>
-void GetDummyProxyForTesting(AssociatedInterfacePtr<Interface>* proxy) {
+AssociatedInterfaceRequest<Interface> GetIsolatedProxy(
+ AssociatedInterfacePtr<Interface>* ptr) {
MessagePipe pipe;
- scoped_refptr<internal::MultiplexRouter> router =
+ scoped_refptr<internal::MultiplexRouter> router0 =
new internal::MultiplexRouter(std::move(pipe.handle0),
internal::MultiplexRouter::MULTI_INTERFACE,
false, base::ThreadTaskRunnerHandle::Get());
- std::unique_ptr<AssociatedGroup> group = router->CreateAssociatedGroup();
- MakeRequest(proxy, group.get());
+ scoped_refptr<internal::MultiplexRouter> router1 =
+ new internal::MultiplexRouter(std::move(pipe.handle1),
+ internal::MultiplexRouter::MULTI_INTERFACE,
+ true, base::ThreadTaskRunnerHandle::Get());
+
+ ScopedInterfaceEndpointHandle endpoint0, endpoint1;
+ router0->CreateEndpointHandlePair(&endpoint0, &endpoint1);
+ endpoint1 = router1->CreateLocalEndpointHandle(endpoint1.release());
+
+ ptr->Bind(AssociatedInterfacePtrInfo<Interface>(std::move(endpoint0),
+ Interface::Version_));
+
+ AssociatedInterfaceRequest<Interface> request;
+ request.Bind(std::move(endpoint1));
+ return request;
}
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698