| Index: mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
|
| diff --git a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
|
| index fb602f596f45c0538f072d6365236a0906a80cee..431a84425076dbd97dfb612a3501ee41b937e11e 100644
|
| --- a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
|
| +++ b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
|
| @@ -795,7 +795,7 @@ TEST_F(InterfacePtrTest, InterfaceRequestResetWithReason) {
|
| run_loop.Run();
|
| }
|
|
|
| -TEST_F(InterfacePtrTest, CallbackOwnsInterfacePtr) {
|
| +TEST_F(InterfacePtrTest, CallbackIsPassedInterfacePtr) {
|
| sample::PingTestPtr ptr;
|
| sample::PingTestRequest request(&ptr);
|
|
|
| @@ -814,6 +814,28 @@ TEST_F(InterfacePtrTest, CallbackOwnsInterfacePtr) {
|
| run_loop.Run();
|
| }
|
|
|
| +TEST_F(InterfacePtrTest, ConnectionErrorHandlerOwnsInterfacePtr) {
|
| + sample::PingTestPtr* ptr = new sample::PingTestPtr;
|
| + sample::PingTestRequest request(ptr);
|
| +
|
| + base::RunLoop run_loop;
|
| +
|
| + // Make a call with |ptr|'s lifetime bound to the connection error handler
|
| + // callback.
|
| + ptr->set_connection_error_handler(base::Bind(
|
| + [](const base::Closure& quit, sample::PingTestPtr* ptr) {
|
| + ptr->reset();
|
| + quit.Run();
|
| + },
|
| + run_loop.QuitClosure(), base::Owned(ptr)));
|
| +
|
| + // Trigger an error on |ptr|. In the error handler |ptr| is reset. This
|
| + // shouldn't immediately destroy the callback (and |ptr| that it owns), before
|
| + // the callback is completed.
|
| + request.PassMessagePipe();
|
| + run_loop.Run();
|
| +}
|
| +
|
| TEST_F(InterfacePtrTest, ThreadSafeInterfacePointer) {
|
| math::CalculatorPtr ptr;
|
| MathCalculatorImpl calc_impl(MakeRequest(&ptr));
|
|
|