| 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 c47d383e042eccac337c7b46e5c1d48876d6d05a..1ff02707fffb151d16c3e118dd67041db4c1c35e 100644
|
| --- a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
|
| +++ b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
|
| @@ -790,6 +790,25 @@ TEST_F(InterfacePtrTest, InterfaceRequestResetWithReason) {
|
| run_loop.Run();
|
| }
|
|
|
| +TEST_F(InterfacePtrTest, CallbackOwnsInterfacePtr) {
|
| + sample::PingTestPtr ptr;
|
| + sample::PingTestRequest request = GetProxy(&ptr);
|
| +
|
| + base::RunLoop run_loop;
|
| +
|
| + // Make a call with the proxy's lifetime bound to the response callback.
|
| + sample::PingTest* raw_proxy = ptr.get();
|
| + ptr.set_connection_error_handler(run_loop.QuitClosure());
|
| + raw_proxy->Ping(
|
| + base::Bind([](sample::PingTestPtr ptr) {}, base::Passed(&ptr)));
|
| +
|
| + // Trigger an error on |ptr|. This will ultimately lead to the proxy's
|
| + // response callbacks being destroyed, which will in turn lead to the proxy
|
| + // being destroyed. This should not crash.
|
| + request.PassMessagePipe();
|
| + run_loop.Run();
|
| +}
|
| +
|
| } // namespace
|
| } // namespace test
|
| } // namespace mojo
|
|
|