| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdint.h> | 5 #include <stdint.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 EXPECT_EQ("greetings", description); | 783 EXPECT_EQ("greetings", description); |
| 784 quit_closure.Run(); | 784 quit_closure.Run(); |
| 785 }, | 785 }, |
| 786 run_loop.QuitClosure())); | 786 run_loop.QuitClosure())); |
| 787 | 787 |
| 788 request.ResetWithReason(88u, "greetings"); | 788 request.ResetWithReason(88u, "greetings"); |
| 789 | 789 |
| 790 run_loop.Run(); | 790 run_loop.Run(); |
| 791 } | 791 } |
| 792 | 792 |
| 793 TEST_F(InterfacePtrTest, CallbackOwnsInterfacePtr) { |
| 794 sample::PingTestPtr ptr; |
| 795 sample::PingTestRequest request = GetProxy(&ptr); |
| 796 |
| 797 base::RunLoop run_loop; |
| 798 |
| 799 // Make a call with the proxy's lifetime bound to the response callback. |
| 800 sample::PingTest* raw_proxy = ptr.get(); |
| 801 ptr.set_connection_error_handler(run_loop.QuitClosure()); |
| 802 raw_proxy->Ping( |
| 803 base::Bind([](sample::PingTestPtr ptr) {}, base::Passed(&ptr))); |
| 804 |
| 805 // Trigger an error on |ptr|. This will ultimately lead to the proxy's |
| 806 // response callbacks being destroyed, which will in turn lead to the proxy |
| 807 // being destroyed. This should not crash. |
| 808 request.PassMessagePipe(); |
| 809 run_loop.Run(); |
| 810 } |
| 811 |
| 793 } // namespace | 812 } // namespace |
| 794 } // namespace test | 813 } // namespace test |
| 795 } // namespace mojo | 814 } // namespace mojo |
| OLD | NEW |