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 "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "net/base/completion_callback.h" | 8 #include "net/base/completion_callback.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/cert/cert_verify_result.h" | 10 #include "net/cert/cert_verify_result.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 307 } |
308 | 308 |
309 bool QuicTestClient::response_complete() const { | 309 bool QuicTestClient::response_complete() const { |
310 return response_complete_; | 310 return response_complete_; |
311 } | 311 } |
312 | 312 |
313 int QuicTestClient::response_header_size() const { | 313 int QuicTestClient::response_header_size() const { |
314 return response_header_size_; | 314 return response_header_size_; |
315 } | 315 } |
316 | 316 |
317 int64 QuicTestClient::response_body_size() const { | 317 int64_t QuicTestClient::response_body_size() const { |
318 return response_body_size_; | 318 return response_body_size_; |
319 } | 319 } |
320 | 320 |
321 bool QuicTestClient::buffer_body() const { | 321 bool QuicTestClient::buffer_body() const { |
322 return buffer_body_; | 322 return buffer_body_; |
323 } | 323 } |
324 | 324 |
325 void QuicTestClient::set_buffer_body(bool buffer_body) { | 325 void QuicTestClient::set_buffer_body(bool buffer_body) { |
326 buffer_body_ = buffer_body; | 326 buffer_body_ = buffer_body; |
327 } | 327 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 response_complete_ = false; | 443 response_complete_ = false; |
444 response_headers_complete_ = false; | 444 response_headers_complete_ = false; |
445 headers_.Clear(); | 445 headers_.Clear(); |
446 bytes_read_ = 0; | 446 bytes_read_ = 0; |
447 bytes_written_ = 0; | 447 bytes_written_ = 0; |
448 response_header_size_ = 0; | 448 response_header_size_ = 0; |
449 response_body_size_ = 0; | 449 response_body_size_ = 0; |
450 } | 450 } |
451 | 451 |
452 void QuicTestClient::WaitForResponseForMs(int timeout_ms) { | 452 void QuicTestClient::WaitForResponseForMs(int timeout_ms) { |
453 int64 timeout_us = timeout_ms * base::Time::kMicrosecondsPerMillisecond; | 453 int64_t timeout_us = timeout_ms * base::Time::kMicrosecondsPerMillisecond; |
454 int64 old_timeout_us = epoll_server()->timeout_in_us(); | 454 int64_t old_timeout_us = epoll_server()->timeout_in_us(); |
455 if (timeout_us > 0) { | 455 if (timeout_us > 0) { |
456 epoll_server()->set_timeout_in_us(timeout_us); | 456 epoll_server()->set_timeout_in_us(timeout_us); |
457 } | 457 } |
458 const QuicClock* clock = | 458 const QuicClock* clock = |
459 QuicConnectionPeer::GetHelper(client()->session()->connection()) | 459 QuicConnectionPeer::GetHelper(client()->session()->connection()) |
460 ->GetClock(); | 460 ->GetClock(); |
461 QuicTime end_waiting_time = | 461 QuicTime end_waiting_time = |
462 clock->Now().Add(QuicTime::Delta::FromMicroseconds(timeout_us)); | 462 clock->Now().Add(QuicTime::Delta::FromMicroseconds(timeout_us)); |
463 while (stream_ != nullptr && | 463 while (stream_ != nullptr && |
464 !client_->session()->IsClosedStream(stream_->id()) && | 464 !client_->session()->IsClosedStream(stream_->id()) && |
465 (timeout_us < 0 || clock->Now() < end_waiting_time)) { | 465 (timeout_us < 0 || clock->Now() < end_waiting_time)) { |
466 client_->WaitForEvents(); | 466 client_->WaitForEvents(); |
467 } | 467 } |
468 if (timeout_us > 0) { | 468 if (timeout_us > 0) { |
469 epoll_server()->set_timeout_in_us(old_timeout_us); | 469 epoll_server()->set_timeout_in_us(old_timeout_us); |
470 } | 470 } |
471 } | 471 } |
472 | 472 |
473 void QuicTestClient::WaitForInitialResponseForMs(int timeout_ms) { | 473 void QuicTestClient::WaitForInitialResponseForMs(int timeout_ms) { |
474 int64 timeout_us = timeout_ms * base::Time::kMicrosecondsPerMillisecond; | 474 int64_t timeout_us = timeout_ms * base::Time::kMicrosecondsPerMillisecond; |
475 int64 old_timeout_us = epoll_server()->timeout_in_us(); | 475 int64_t old_timeout_us = epoll_server()->timeout_in_us(); |
476 if (timeout_us > 0) { | 476 if (timeout_us > 0) { |
477 epoll_server()->set_timeout_in_us(timeout_us); | 477 epoll_server()->set_timeout_in_us(timeout_us); |
478 } | 478 } |
479 const QuicClock* clock = | 479 const QuicClock* clock = |
480 QuicConnectionPeer::GetHelper(client()->session()->connection()) | 480 QuicConnectionPeer::GetHelper(client()->session()->connection()) |
481 ->GetClock(); | 481 ->GetClock(); |
482 QuicTime end_waiting_time = | 482 QuicTime end_waiting_time = |
483 clock->Now().Add(QuicTime::Delta::FromMicroseconds(timeout_us)); | 483 clock->Now().Add(QuicTime::Delta::FromMicroseconds(timeout_us)); |
484 while (stream_ != nullptr && | 484 while (stream_ != nullptr && |
485 !client_->session()->IsClosedStream(stream_->id()) && | 485 !client_->session()->IsClosedStream(stream_->id()) && |
(...skipping 23 matching lines...) Expand all Loading... |
509 return &headers_; | 509 return &headers_; |
510 } else { | 510 } else { |
511 return &headers_; | 511 return &headers_; |
512 } | 512 } |
513 } | 513 } |
514 | 514 |
515 const SpdyHeaderBlock& QuicTestClient::response_trailers() const { | 515 const SpdyHeaderBlock& QuicTestClient::response_trailers() const { |
516 return response_trailers_; | 516 return response_trailers_; |
517 } | 517 } |
518 | 518 |
519 int64 QuicTestClient::response_size() const { | 519 int64_t QuicTestClient::response_size() const { |
520 return bytes_read_; | 520 return bytes_read_; |
521 } | 521 } |
522 | 522 |
523 size_t QuicTestClient::bytes_read() const { | 523 size_t QuicTestClient::bytes_read() const { |
524 return bytes_read_; | 524 return bytes_read_; |
525 } | 525 } |
526 | 526 |
527 size_t QuicTestClient::bytes_written() const { | 527 size_t QuicTestClient::bytes_written() const { |
528 return bytes_written_; | 528 return bytes_written_; |
529 } | 529 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 message->headers()->SetRequestVersion( | 629 message->headers()->SetRequestVersion( |
630 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1)); | 630 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1)); |
631 message->headers()->SetRequestMethod( | 631 message->headers()->SetRequestMethod( |
632 HTTPMessage::MethodToString(HttpConstants::GET)); | 632 HTTPMessage::MethodToString(HttpConstants::GET)); |
633 message->headers()->SetRequestUri(uri); | 633 message->headers()->SetRequestUri(uri); |
634 } | 634 } |
635 | 635 |
636 } // namespace test | 636 } // namespace test |
637 } // namespace tools | 637 } // namespace tools |
638 } // namespace net | 638 } // namespace net |
OLD | NEW |