| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 Session* client_session) | 310 Session* client_session) |
| 311 : host_session_(host_session), | 311 : host_session_(host_session), |
| 312 client_session_(client_session), | 312 client_session_(client_session), |
| 313 done_(false) { | 313 done_(false) { |
| 314 } | 314 } |
| 315 | 315 |
| 316 virtual ~ChannelTesterBase() { } | 316 virtual ~ChannelTesterBase() { } |
| 317 | 317 |
| 318 void Start() { | 318 void Start() { |
| 319 MessageLoop::current()->PostTask( | 319 MessageLoop::current()->PostTask( |
| 320 FROM_HERE, NewRunnableMethod(this, &ChannelTesterBase::DoStart)); | 320 FROM_HERE, base::Bind(&ChannelTesterBase::DoStart, this)); |
| 321 } | 321 } |
| 322 | 322 |
| 323 bool WaitFinished() { | 323 bool WaitFinished() { |
| 324 return RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms()); | 324 return RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms()); |
| 325 } | 325 } |
| 326 | 326 |
| 327 virtual void CheckResults() = 0; | 327 virtual void CheckResults() = 0; |
| 328 | 328 |
| 329 protected: | 329 protected: |
| 330 void DoStart() { | 330 void DoStart() { |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 | 600 |
| 601 void HandleWriteResult(int result) { | 601 void HandleWriteResult(int result) { |
| 602 if (result <= 0 && result != net::ERR_IO_PENDING) { | 602 if (result <= 0 && result != net::ERR_IO_PENDING) { |
| 603 LOG(ERROR) << "Received error " << result << " when trying to write"; | 603 LOG(ERROR) << "Received error " << result << " when trying to write"; |
| 604 write_errors_++; | 604 write_errors_++; |
| 605 Done(); | 605 Done(); |
| 606 } else if (result > 0) { | 606 } else if (result > 0) { |
| 607 EXPECT_EQ(kMessageSize, result); | 607 EXPECT_EQ(kMessageSize, result); |
| 608 packets_sent_++; | 608 packets_sent_++; |
| 609 MessageLoop::current()->PostDelayedTask( | 609 MessageLoop::current()->PostDelayedTask( |
| 610 FROM_HERE, NewRunnableMethod(this, &UDPChannelTester::DoWrite), | 610 FROM_HERE, base::Bind(&UDPChannelTester::DoWrite, this), |
| 611 kUdpWriteDelayMs); | 611 kUdpWriteDelayMs); |
| 612 } | 612 } |
| 613 } | 613 } |
| 614 | 614 |
| 615 virtual void DoRead() { | 615 virtual void DoRead() { |
| 616 int result = 1; | 616 int result = 1; |
| 617 while (result > 0) { | 617 while (result > 0) { |
| 618 int kReadSize = kMessageSize * 2; | 618 int kReadSize = kMessageSize * 2; |
| 619 read_buffer_ = new net::IOBuffer(kReadSize); | 619 read_buffer_ = new net::IOBuffer(kReadSize); |
| 620 | 620 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 ASSERT_TRUE(tester->WaitFinished()); | 788 ASSERT_TRUE(tester->WaitFinished()); |
| 789 LOG(INFO) << "Time for 500k bytes " | 789 LOG(INFO) << "Time for 500k bytes " |
| 790 << tester->GetElapsedTime().InMilliseconds() << " ms."; | 790 << tester->GetElapsedTime().InMilliseconds() << " ms."; |
| 791 | 791 |
| 792 // Connections must be closed while |tester| still exists. | 792 // Connections must be closed while |tester| still exists. |
| 793 CloseSessions(); | 793 CloseSessions(); |
| 794 } | 794 } |
| 795 | 795 |
| 796 } // namespace protocol | 796 } // namespace protocol |
| 797 } // namespace remoting | 797 } // namespace remoting |
| OLD | NEW |