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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « jingle/glue/pseudotcp_adapter.cc ('k') | remoting/protocol/jingle_session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "jingle/glue/pseudotcp_adapter.h" 5 #include "jingle/glue/pseudotcp_adapter.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 300
301 scoped_refptr<TCPChannelTester> tester = 301 scoped_refptr<TCPChannelTester> tester =
302 new TCPChannelTester(&message_loop_, host_pseudotcp_.get(), 302 new TCPChannelTester(&message_loop_, host_pseudotcp_.get(),
303 client_pseudotcp_.get()); 303 client_pseudotcp_.get());
304 304
305 tester->Start(); 305 tester->Start();
306 message_loop_.Run(); 306 message_loop_.Run();
307 tester->CheckResults(); 307 tester->CheckResults();
308 } 308 }
309 309
310 class DeleteOnConnected {
311 public:
312 DeleteOnConnected(MessageLoop* message_loop,
313 scoped_ptr<PseudoTcpAdapter>* adapter)
314 : message_loop_(message_loop), adapter_(adapter) {}
315 void OnConnected(int error) {
316 adapter_->reset();
317 message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask());
318 }
319 MessageLoop* message_loop_;
320 scoped_ptr<PseudoTcpAdapter>* adapter_;
321 };
322
323 TEST_F(P2PTransportImplTest, TestDeleteOnConnected) {
324 // This test verifies that deleting the adapter mid-callback doesn't lead
325 // to deleted structures being touched as the stack unrolls, so the failure
326 // mode is a crash rather than a normal test failure.
327 TestCompletionCallback client_connect_cb;
328 DeleteOnConnected host_delete(&message_loop_, &host_pseudotcp_);
329 net::CompletionCallbackImpl<DeleteOnConnected>
330 host_connect_cb(&host_delete, &DeleteOnConnected::OnConnected);
331
332 host_pseudotcp_->Connect(&host_connect_cb);
333 client_pseudotcp_->Connect(&client_connect_cb);
334 message_loop_.Run();
335
336 ASSERT_EQ(NULL, host_pseudotcp_.get());
337 }
338
310 } // namespace 339 } // namespace
311 340
312 } // namespace jingle_glue 341 } // namespace jingle_glue
OLDNEW
« 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