Chromium Code Reviews| 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 3bdb319548a379f134ec95e76ec7c6d3d3a0b076..786b695eb3c5ccca8f81f74ebe5e556702f23181 100644 |
| --- a/mojo/public/cpp/bindings/associated_interface_ptr.h |
| +++ b/mojo/public/cpp/bindings/associated_interface_ptr.h |
| @@ -226,6 +226,35 @@ AssociatedInterfaceRequest<Interface> GetProxy( |
| return request; |
| } |
| +// Creates an associated interface proxy in its own AssociatedGroup. |
| +template <typename Interface> |
| +AssociatedInterfaceRequest<Interface> GetProxyForTesting( |
| + AssociatedInterfacePtr<Interface>* ptr, |
| + scoped_refptr<base::SingleThreadTaskRunner> runner = |
| + base::ThreadTaskRunnerHandle::Get()) { |
| + MessagePipe pipe; |
| + using internal::MultiplexRouter; |
| + scoped_refptr<MultiplexRouter> router0 = new MultiplexRouter( |
| + std::move(pipe.handle0), MultiplexRouter::MULTI_INTERFACE, true, runner); |
| + scoped_refptr<MultiplexRouter> router1 = new MultiplexRouter( |
| + std::move(pipe.handle1), MultiplexRouter::MULTI_INTERFACE, false, runner); |
| + |
| + AssociatedInterfacePtrInfo<Interface> ptr_info; |
| + AssociatedInterfaceRequest<Interface> request; |
| + router1->CreateAssociatedGroup()->CreateAssociatedInterface( |
| + AssociatedGroup::WILL_PASS_PTR, &ptr_info, &request); |
| + |
| + // Emulate passing |ptr_info| across a pipe. |
| + ScopedInterfaceEndpointHandle handle = ptr_info.PassHandle(); |
| + CHECK(!handle.is_local()); |
|
dcheng
2016/11/21 10:31:57
Nit: why CHECK? If this is something that should "
Reilly Grant (use Gerrit)
2016/11/21 19:02:22
Changed to DCHECK. This is testing code anyways.
|
| + ptr->Bind(AssociatedInterfacePtrInfo<Interface>( |
| + router0->CreateLocalEndpointHandle(handle.release()), |
| + ptr_info.version()), |
| + std::move(runner)); |
| + |
| + return request; |
| +} |
| + |
| // Creates an associated interface proxy which casts its messages into the void. |
| template <typename Interface> |
| void GetDummyProxyForTesting(AssociatedInterfacePtr<Interface>* proxy) { |