OLD | NEW |
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 "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.h" | 8 #include "base/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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 196 } |
197 | 197 |
198 void DatagramConnectionTester::HandleWriteResult(int result) { | 198 void DatagramConnectionTester::HandleWriteResult(int result) { |
199 if (result <= 0 && result != net::ERR_IO_PENDING) { | 199 if (result <= 0 && result != net::ERR_IO_PENDING) { |
200 LOG(ERROR) << "Received error " << result << " when trying to write"; | 200 LOG(ERROR) << "Received error " << result << " when trying to write"; |
201 write_errors_++; | 201 write_errors_++; |
202 Done(); | 202 Done(); |
203 } else if (result > 0) { | 203 } else if (result > 0) { |
204 EXPECT_EQ(message_size_, result); | 204 EXPECT_EQ(message_size_, result); |
205 packets_sent_++; | 205 packets_sent_++; |
206 message_loop_->PostDelayedTask(FROM_HERE, base::Bind( | 206 message_loop_->PostDelayedTask( |
207 &DatagramConnectionTester::DoWrite, base::Unretained(this)), delay_ms_); | 207 FROM_HERE, |
| 208 base::Bind(&DatagramConnectionTester::DoWrite, base::Unretained(this)), |
| 209 base::TimeDelta::FromMilliseconds(delay_ms_)); |
208 } | 210 } |
209 } | 211 } |
210 | 212 |
211 void DatagramConnectionTester::DoRead() { | 213 void DatagramConnectionTester::DoRead() { |
212 int result = 1; | 214 int result = 1; |
213 while (result > 0) { | 215 while (result > 0) { |
214 int kReadSize = message_size_ * 2; | 216 int kReadSize = message_size_ * 2; |
215 read_buffer_ = new net::IOBuffer(kReadSize); | 217 read_buffer_ = new net::IOBuffer(kReadSize); |
216 | 218 |
217 result = host_socket_->Read( | 219 result = host_socket_->Read( |
(...skipping 29 matching lines...) Expand all Loading... |
247 if (memcmp(read_buffer_->data(), sent_packets_[packet_id]->data(), | 249 if (memcmp(read_buffer_->data(), sent_packets_[packet_id]->data(), |
248 message_size_) != 0) | 250 message_size_) != 0) |
249 bad_packets_received_++; | 251 bad_packets_received_++; |
250 } | 252 } |
251 } | 253 } |
252 } | 254 } |
253 } | 255 } |
254 | 256 |
255 } // namespace protocol | 257 } // namespace protocol |
256 } // namespace remoting | 258 } // namespace remoting |
OLD | NEW |