OLD | NEW |
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 "net/tools/quic/test_tools/quic_test_client.h" | 5 #include "net/tools/quic/test_tools/quic_test_client.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 void QuicTestClient::WaitForResponseForMs(int timeout_ms) { | 489 void QuicTestClient::WaitForResponseForMs(int timeout_ms) { |
490 int64_t timeout_us = timeout_ms * base::Time::kMicrosecondsPerMillisecond; | 490 int64_t timeout_us = timeout_ms * base::Time::kMicrosecondsPerMillisecond; |
491 int64_t old_timeout_us = epoll_server()->timeout_in_us(); | 491 int64_t old_timeout_us = epoll_server()->timeout_in_us(); |
492 if (timeout_us > 0) { | 492 if (timeout_us > 0) { |
493 epoll_server()->set_timeout_in_us(timeout_us); | 493 epoll_server()->set_timeout_in_us(timeout_us); |
494 } | 494 } |
495 const QuicClock* clock = | 495 const QuicClock* clock = |
496 QuicConnectionPeer::GetHelper(client()->session()->connection()) | 496 QuicConnectionPeer::GetHelper(client()->session()->connection()) |
497 ->GetClock(); | 497 ->GetClock(); |
498 QuicTime end_waiting_time = | 498 QuicTime end_waiting_time = |
499 clock->Now().Add(QuicTime::Delta::FromMicroseconds(timeout_us)); | 499 clock->Now() + QuicTime::Delta::FromMicroseconds(timeout_us); |
500 while (HaveActiveStream() && | 500 while (HaveActiveStream() && |
501 (timeout_us < 0 || clock->Now() < end_waiting_time)) { | 501 (timeout_us < 0 || clock->Now() < end_waiting_time)) { |
502 client_->WaitForEvents(); | 502 client_->WaitForEvents(); |
503 } | 503 } |
504 if (timeout_us > 0) { | 504 if (timeout_us > 0) { |
505 epoll_server()->set_timeout_in_us(old_timeout_us); | 505 epoll_server()->set_timeout_in_us(old_timeout_us); |
506 } | 506 } |
507 } | 507 } |
508 | 508 |
509 void QuicTestClient::WaitForInitialResponseForMs(int timeout_ms) { | 509 void QuicTestClient::WaitForInitialResponseForMs(int timeout_ms) { |
510 int64_t timeout_us = timeout_ms * base::Time::kMicrosecondsPerMillisecond; | 510 int64_t timeout_us = timeout_ms * base::Time::kMicrosecondsPerMillisecond; |
511 int64_t old_timeout_us = epoll_server()->timeout_in_us(); | 511 int64_t old_timeout_us = epoll_server()->timeout_in_us(); |
512 if (timeout_us > 0) { | 512 if (timeout_us > 0) { |
513 epoll_server()->set_timeout_in_us(timeout_us); | 513 epoll_server()->set_timeout_in_us(timeout_us); |
514 } | 514 } |
515 const QuicClock* clock = | 515 const QuicClock* clock = |
516 QuicConnectionPeer::GetHelper(client()->session()->connection()) | 516 QuicConnectionPeer::GetHelper(client()->session()->connection()) |
517 ->GetClock(); | 517 ->GetClock(); |
518 QuicTime end_waiting_time = | 518 QuicTime end_waiting_time = |
519 clock->Now().Add(QuicTime::Delta::FromMicroseconds(timeout_us)); | 519 clock->Now() + QuicTime::Delta::FromMicroseconds(timeout_us); |
520 while (stream_ != nullptr && | 520 while (stream_ != nullptr && |
521 !client_->session()->IsClosedStream(stream_->id()) && | 521 !client_->session()->IsClosedStream(stream_->id()) && |
522 stream_->stream_bytes_read() == 0 && | 522 stream_->stream_bytes_read() == 0 && |
523 (timeout_us < 0 || clock->Now() < end_waiting_time)) { | 523 (timeout_us < 0 || clock->Now() < end_waiting_time)) { |
524 client_->WaitForEvents(); | 524 client_->WaitForEvents(); |
525 } | 525 } |
526 if (timeout_us > 0) { | 526 if (timeout_us > 0) { |
527 epoll_server()->set_timeout_in_us(old_timeout_us); | 527 epoll_server()->set_timeout_in_us(old_timeout_us); |
528 } | 528 } |
529 } | 529 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 CHECK(message); | 676 CHECK(message); |
677 message->headers()->SetRequestVersion( | 677 message->headers()->SetRequestVersion( |
678 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1)); | 678 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1)); |
679 message->headers()->SetRequestMethod( | 679 message->headers()->SetRequestMethod( |
680 HTTPMessage::MethodToString(HttpConstants::GET)); | 680 HTTPMessage::MethodToString(HttpConstants::GET)); |
681 message->headers()->SetRequestUri(uri); | 681 message->headers()->SetRequestUri(uri); |
682 } | 682 } |
683 | 683 |
684 } // namespace test | 684 } // namespace test |
685 } // namespace net | 685 } // namespace net |
OLD | NEW |