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

Side by Side Diff: jingle/glue/pseudotcp_adapter_unittest.cc

Issue 8885018: Removing MessageLoop::QuitTask() from jingle/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix escaping? Created 9 years 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 | « no previous file | jingle/glue/thread_wrapper_unittest.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 "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 output_buffer_->SetOffset(0); 230 output_buffer_->SetOffset(0);
231 ASSERT_EQ(kTestDataSize, output_buffer_->size()); 231 ASSERT_EQ(kTestDataSize, output_buffer_->size());
232 232
233 EXPECT_EQ(0, memcmp(output_buffer_->data(), 233 EXPECT_EQ(0, memcmp(output_buffer_->data(),
234 input_buffer_->StartOfBuffer(), kTestDataSize)); 234 input_buffer_->StartOfBuffer(), kTestDataSize));
235 } 235 }
236 236
237 protected: 237 protected:
238 void Done() { 238 void Done() {
239 done_ = true; 239 done_ = true;
240 message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 240 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
241 } 241 }
242 242
243 void DoStart() { 243 void DoStart() {
244 InitBuffers(); 244 InitBuffers();
245 DoRead(); 245 DoRead();
246 DoWrite(); 246 DoWrite();
247 } 247 }
248 248
249 void InitBuffers() { 249 void InitBuffers() {
250 output_buffer_ = new net::DrainableIOBuffer( 250 output_buffer_ = new net::DrainableIOBuffer(
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 tester->CheckResults(); 411 tester->CheckResults();
412 } 412 }
413 413
414 class DeleteOnConnected { 414 class DeleteOnConnected {
415 public: 415 public:
416 DeleteOnConnected(MessageLoop* message_loop, 416 DeleteOnConnected(MessageLoop* message_loop,
417 scoped_ptr<PseudoTcpAdapter>* adapter) 417 scoped_ptr<PseudoTcpAdapter>* adapter)
418 : message_loop_(message_loop), adapter_(adapter) {} 418 : message_loop_(message_loop), adapter_(adapter) {}
419 void OnConnected(int error) { 419 void OnConnected(int error) {
420 adapter_->reset(); 420 adapter_->reset();
421 message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 421 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
422 } 422 }
423 MessageLoop* message_loop_; 423 MessageLoop* message_loop_;
424 scoped_ptr<PseudoTcpAdapter>* adapter_; 424 scoped_ptr<PseudoTcpAdapter>* adapter_;
425 }; 425 };
426 426
427 TEST_F(PseudoTcpAdapterTest, DeleteOnConnected) { 427 TEST_F(PseudoTcpAdapterTest, DeleteOnConnected) {
428 // This test verifies that deleting the adapter mid-callback doesn't lead 428 // This test verifies that deleting the adapter mid-callback doesn't lead
429 // to deleted structures being touched as the stack unrolls, so the failure 429 // to deleted structures being touched as the stack unrolls, so the failure
430 // mode is a crash rather than a normal test failure. 430 // mode is a crash rather than a normal test failure.
431 TestOldCompletionCallback client_connect_cb; 431 TestOldCompletionCallback client_connect_cb;
432 DeleteOnConnected host_delete(&message_loop_, &host_pseudotcp_); 432 DeleteOnConnected host_delete(&message_loop_, &host_pseudotcp_);
433 net::OldCompletionCallbackImpl<DeleteOnConnected> 433 net::OldCompletionCallbackImpl<DeleteOnConnected>
434 host_connect_cb(&host_delete, &DeleteOnConnected::OnConnected); 434 host_connect_cb(&host_delete, &DeleteOnConnected::OnConnected);
435 435
436 host_pseudotcp_->Connect(&host_connect_cb); 436 host_pseudotcp_->Connect(&host_connect_cb);
437 client_pseudotcp_->Connect(&client_connect_cb); 437 client_pseudotcp_->Connect(&client_connect_cb);
438 message_loop_.Run(); 438 message_loop_.Run();
439 439
440 ASSERT_EQ(NULL, host_pseudotcp_.get()); 440 ASSERT_EQ(NULL, host_pseudotcp_.get());
441 } 441 }
442 442
443 } // namespace 443 } // namespace
444 444
445 } // namespace jingle_glue 445 } // namespace jingle_glue
OLDNEW
« no previous file with comments | « no previous file | jingle/glue/thread_wrapper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698