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

Side by Side Diff: remoting/protocol/connection_tester.cc

Issue 1394803004: Don't use base::MessageLoop::{Quit,QuitClosure} in remoting/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/protocol/connection_tester.h" 5 #include "remoting/protocol/connection_tester.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 output_buffer_->SetOffset(0); 47 output_buffer_->SetOffset(0);
48 ASSERT_EQ(test_data_size_, output_buffer_->size()); 48 ASSERT_EQ(test_data_size_, output_buffer_->size());
49 49
50 EXPECT_EQ(0, memcmp(output_buffer_->data(), 50 EXPECT_EQ(0, memcmp(output_buffer_->data(),
51 input_buffer_->StartOfBuffer(), test_data_size_)); 51 input_buffer_->StartOfBuffer(), test_data_size_));
52 } 52 }
53 53
54 void StreamConnectionTester::Done() { 54 void StreamConnectionTester::Done() {
55 done_ = true; 55 done_ = true;
56 message_loop_->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); 56 message_loop_->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
57 } 57 }
58 58
59 void StreamConnectionTester::InitBuffers() { 59 void StreamConnectionTester::InitBuffers() {
60 output_buffer_ = new net::DrainableIOBuffer( 60 output_buffer_ = new net::DrainableIOBuffer(
61 new net::IOBuffer(test_data_size_), test_data_size_); 61 new net::IOBuffer(test_data_size_), test_data_size_);
62 for (int i = 0; i < test_data_size_; ++i) { 62 for (int i = 0; i < test_data_size_; ++i) {
63 output_buffer_->data()[i] = static_cast<char>(i); 63 output_buffer_->data()[i] = static_cast<char>(i);
64 } 64 }
65 65
66 input_buffer_ = new net::GrowableIOBuffer(); 66 input_buffer_ = new net::GrowableIOBuffer();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 EXPECT_EQ(0, bad_packets_received_); 164 EXPECT_EQ(0, bad_packets_received_);
165 165
166 // Verify that we've received at least one packet. 166 // Verify that we've received at least one packet.
167 EXPECT_GT(packets_received_, 0); 167 EXPECT_GT(packets_received_, 0);
168 VLOG(0) << "Received " << packets_received_ << " packets out of " 168 VLOG(0) << "Received " << packets_received_ << " packets out of "
169 << message_count_; 169 << message_count_;
170 } 170 }
171 171
172 void DatagramConnectionTester::Done() { 172 void DatagramConnectionTester::Done() {
173 done_ = true; 173 done_ = true;
174 message_loop_->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); 174 message_loop_->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
175 } 175 }
176 176
177 void DatagramConnectionTester::DoWrite() { 177 void DatagramConnectionTester::DoWrite() {
178 if (packets_sent_ >= message_count_) { 178 if (packets_sent_ >= message_count_) {
179 Done(); 179 Done();
180 return; 180 return;
181 } 181 }
182 182
183 scoped_refptr<net::IOBuffer> packet(new net::IOBuffer(message_size_)); 183 scoped_refptr<net::IOBuffer> packet(new net::IOBuffer(message_size_));
184 for (int i = 0; i < message_size_; ++i) { 184 for (int i = 0; i < message_size_; ++i) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (memcmp(read_buffer_->data(), sent_packets_[packet_id]->data(), 252 if (memcmp(read_buffer_->data(), sent_packets_[packet_id]->data(),
253 message_size_) != 0) 253 message_size_) != 0)
254 bad_packets_received_++; 254 bad_packets_received_++;
255 } 255 }
256 } 256 }
257 } 257 }
258 } 258 }
259 259
260 } // namespace protocol 260 } // namespace protocol
261 } // namespace remoting 261 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/channel_multiplexer_unittest.cc ('k') | remoting/protocol/jingle_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698