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

Unified Diff: jingle/glue/pseudotcp_adapter_unittest.cc

Issue 7040021: Fix crash condition if caller deletes PseudoTcpAdaptor from within a callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change the flag we supply to Close(). Created 9 years, 7 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
« no previous file with comments | « jingle/glue/pseudotcp_adapter.cc ('k') | remoting/protocol/jingle_session.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: jingle/glue/pseudotcp_adapter_unittest.cc
diff --git a/jingle/glue/pseudotcp_adapter_unittest.cc b/jingle/glue/pseudotcp_adapter_unittest.cc
index 977c0ac61d6602ecc4777334fd8a96d6298b24f9..14bc0d2f68b9de87312d46b5b832689d75856714 100644
--- a/jingle/glue/pseudotcp_adapter_unittest.cc
+++ b/jingle/glue/pseudotcp_adapter_unittest.cc
@@ -307,6 +307,35 @@ TEST_F(P2PTransportImplTest, TestLossyChannel) {
tester->CheckResults();
}
+class DeleteOnConnected {
+ public:
+ DeleteOnConnected(MessageLoop* message_loop,
+ scoped_ptr<PseudoTcpAdapter>* adapter)
+ : message_loop_(message_loop), adapter_(adapter) {}
+ void OnConnected(int error) {
+ adapter_->reset();
+ message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask());
+ }
+ MessageLoop* message_loop_;
+ scoped_ptr<PseudoTcpAdapter>* adapter_;
+};
+
+TEST_F(P2PTransportImplTest, TestDeleteOnConnected) {
+ // This test verifies that deleting the adapter mid-callback doesn't lead
+ // to deleted structures being touched as the stack unrolls, so the failure
+ // mode is a crash rather than a normal test failure.
+ TestCompletionCallback client_connect_cb;
+ DeleteOnConnected host_delete(&message_loop_, &host_pseudotcp_);
+ net::CompletionCallbackImpl<DeleteOnConnected>
+ host_connect_cb(&host_delete, &DeleteOnConnected::OnConnected);
+
+ host_pseudotcp_->Connect(&host_connect_cb);
+ client_pseudotcp_->Connect(&client_connect_cb);
+ message_loop_.Run();
+
+ ASSERT_EQ(NULL, host_pseudotcp_.get());
+}
+
} // namespace
} // namespace jingle_glue
« no previous file with comments | « jingle/glue/pseudotcp_adapter.cc ('k') | remoting/protocol/jingle_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698