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

Side by Side Diff: net/tools/quic/test_tools/quic_test_client.cc

Issue 2132623002: Landing Recent QUIC changes until 2016-07-02 02:45 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing comment about RPCs Created 4 years, 5 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
« no previous file with comments | « net/tools/quic/test_tools/quic_test_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 27 matching lines...) Expand all
38 38
39 namespace net { 39 namespace net {
40 namespace test { 40 namespace test {
41 namespace { 41 namespace {
42 42
43 // RecordingProofVerifier accepts any certificate chain and records the common 43 // RecordingProofVerifier accepts any certificate chain and records the common
44 // name of the leaf. 44 // name of the leaf.
45 class RecordingProofVerifier : public ProofVerifier { 45 class RecordingProofVerifier : public ProofVerifier {
46 public: 46 public:
47 // ProofVerifier interface. 47 // ProofVerifier interface.
48 QuicAsyncStatus VerifyProof(const string& hostname, 48 QuicAsyncStatus VerifyProof(
49 const uint16_t port, 49 const string& hostname,
50 const string& server_config, 50 const uint16_t port,
51 QuicVersion quic_version, 51 const string& server_config,
52 StringPiece chlo_hash, 52 QuicVersion quic_version,
53 const vector<string>& certs, 53 StringPiece chlo_hash,
54 const string& cert_sct, 54 const vector<string>& certs,
55 const string& signature, 55 const string& cert_sct,
56 const ProofVerifyContext* context, 56 const string& signature,
57 string* error_details, 57 const ProofVerifyContext* context,
58 std::unique_ptr<ProofVerifyDetails>* details, 58 string* error_details,
59 ProofVerifierCallback* callback) override { 59 std::unique_ptr<ProofVerifyDetails>* details,
60 std::unique_ptr<ProofVerifierCallback> callback) override {
60 common_name_.clear(); 61 common_name_.clear();
61 if (certs.empty()) { 62 if (certs.empty()) {
62 return QUIC_FAILURE; 63 return QUIC_FAILURE;
63 } 64 }
64 65
65 // Convert certs to X509Certificate. 66 // Convert certs to X509Certificate.
66 vector<StringPiece> cert_pieces(certs.size()); 67 vector<StringPiece> cert_pieces(certs.size());
67 for (unsigned i = 0; i < certs.size(); i++) { 68 for (unsigned i = 0; i < certs.size(); i++) {
68 cert_pieces[i] = StringPiece(certs[i]); 69 cert_pieces[i] = StringPiece(certs[i]);
69 } 70 }
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 void QuicTestClient::WaitForResponseForMs(int timeout_ms) { 489 void QuicTestClient::WaitForResponseForMs(int timeout_ms) {
489 int64_t timeout_us = timeout_ms * base::Time::kMicrosecondsPerMillisecond; 490 int64_t timeout_us = timeout_ms * base::Time::kMicrosecondsPerMillisecond;
490 int64_t old_timeout_us = epoll_server()->timeout_in_us(); 491 int64_t old_timeout_us = epoll_server()->timeout_in_us();
491 if (timeout_us > 0) { 492 if (timeout_us > 0) {
492 epoll_server()->set_timeout_in_us(timeout_us); 493 epoll_server()->set_timeout_in_us(timeout_us);
493 } 494 }
494 const QuicClock* clock = 495 const QuicClock* clock =
495 QuicConnectionPeer::GetHelper(client()->session()->connection()) 496 QuicConnectionPeer::GetHelper(client()->session()->connection())
496 ->GetClock(); 497 ->GetClock();
497 QuicTime end_waiting_time = 498 QuicTime end_waiting_time =
498 clock->Now().Add(QuicTime::Delta::FromMicroseconds(timeout_us)); 499 clock->Now() + QuicTime::Delta::FromMicroseconds(timeout_us);
499 while (HaveActiveStream() && 500 while (HaveActiveStream() &&
500 (timeout_us < 0 || clock->Now() < end_waiting_time)) { 501 (timeout_us < 0 || clock->Now() < end_waiting_time)) {
501 client_->WaitForEvents(); 502 client_->WaitForEvents();
502 } 503 }
503 if (timeout_us > 0) { 504 if (timeout_us > 0) {
504 epoll_server()->set_timeout_in_us(old_timeout_us); 505 epoll_server()->set_timeout_in_us(old_timeout_us);
505 } 506 }
506 } 507 }
507 508
508 void QuicTestClient::WaitForInitialResponseForMs(int timeout_ms) { 509 void QuicTestClient::WaitForInitialResponseForMs(int timeout_ms) {
509 int64_t timeout_us = timeout_ms * base::Time::kMicrosecondsPerMillisecond; 510 int64_t timeout_us = timeout_ms * base::Time::kMicrosecondsPerMillisecond;
510 int64_t old_timeout_us = epoll_server()->timeout_in_us(); 511 int64_t old_timeout_us = epoll_server()->timeout_in_us();
511 if (timeout_us > 0) { 512 if (timeout_us > 0) {
512 epoll_server()->set_timeout_in_us(timeout_us); 513 epoll_server()->set_timeout_in_us(timeout_us);
513 } 514 }
514 const QuicClock* clock = 515 const QuicClock* clock =
515 QuicConnectionPeer::GetHelper(client()->session()->connection()) 516 QuicConnectionPeer::GetHelper(client()->session()->connection())
516 ->GetClock(); 517 ->GetClock();
517 QuicTime end_waiting_time = 518 QuicTime end_waiting_time =
518 clock->Now().Add(QuicTime::Delta::FromMicroseconds(timeout_us)); 519 clock->Now() + QuicTime::Delta::FromMicroseconds(timeout_us);
519 while (stream_ != nullptr && 520 while (stream_ != nullptr &&
520 !client_->session()->IsClosedStream(stream_->id()) && 521 !client_->session()->IsClosedStream(stream_->id()) &&
521 stream_->stream_bytes_read() == 0 && 522 stream_->stream_bytes_read() == 0 &&
522 (timeout_us < 0 || clock->Now() < end_waiting_time)) { 523 (timeout_us < 0 || clock->Now() < end_waiting_time)) {
523 client_->WaitForEvents(); 524 client_->WaitForEvents();
524 } 525 }
525 if (timeout_us > 0) { 526 if (timeout_us > 0) {
526 epoll_server()->set_timeout_in_us(old_timeout_us); 527 epoll_server()->set_timeout_in_us(old_timeout_us);
527 } 528 }
528 } 529 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 CHECK(message); 676 CHECK(message);
676 message->headers()->SetRequestVersion( 677 message->headers()->SetRequestVersion(
677 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1)); 678 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1));
678 message->headers()->SetRequestMethod( 679 message->headers()->SetRequestMethod(
679 HTTPMessage::MethodToString(HttpConstants::GET)); 680 HTTPMessage::MethodToString(HttpConstants::GET));
680 message->headers()->SetRequestUri(uri); 681 message->headers()->SetRequestUri(uri);
681 } 682 }
682 683
683 } // namespace test 684 } // namespace test
684 } // namespace net 685 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/quic_test_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698