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

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

Issue 2363393004: Remove usage of BalsaHeaders from QuicClient. Also move QuicDataToResend from QuicClient to QuicCli… (Closed)
Patch Set: Fix win Created 4 years, 2 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/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 bool fin, 314 bool fin,
315 QuicAckListenerInterface* delegate) { 315 QuicAckListenerInterface* delegate) {
316 if (headers) { 316 if (headers) {
317 QuicClientPushPromiseIndex::TryHandle* handle; 317 QuicClientPushPromiseIndex::TryHandle* handle;
318 QuicAsyncStatus rv = client()->push_promise_index()->Try( 318 QuicAsyncStatus rv = client()->push_promise_index()->Try(
319 SpdyBalsaUtils::RequestHeadersToSpdyHeaders(*headers), this, &handle); 319 SpdyBalsaUtils::RequestHeadersToSpdyHeaders(*headers), this, &handle);
320 if (rv == QUIC_SUCCESS) 320 if (rv == QUIC_SUCCESS)
321 return 1; 321 return 1;
322 if (rv == QUIC_PENDING) { 322 if (rv == QUIC_PENDING) {
323 // May need to retry request if asynchronous rendezvous fails. 323 // May need to retry request if asynchronous rendezvous fails.
324 auto* new_headers = new BalsaHeaders; 324 std::unique_ptr<SpdyHeaderBlock> new_headers(new SpdyHeaderBlock(
325 new_headers->CopyFrom(*headers); 325 SpdyBalsaUtils::RequestHeadersToSpdyHeaders(*headers)));
326 push_promise_data_to_resend_.reset( 326 push_promise_data_to_resend_.reset(new TestClientDataToResend(
327 new TestClientDataToResend(new_headers, body, fin, this, delegate)); 327 std::move(new_headers), body, fin, this, delegate));
328 return 1; 328 return 1;
329 } 329 }
330 } 330 }
331 331
332 // Maybe it's better just to overload this. it's just that we need 332 // Maybe it's better just to overload this. it's just that we need
333 // for the GetOrCreateStream function to call something else...which 333 // for the GetOrCreateStream function to call something else...which
334 // is icky and complicated, but maybe not worse than this. 334 // is icky and complicated, but maybe not worse than this.
335 QuicSpdyClientStream* stream = GetOrCreateStream(); 335 QuicSpdyClientStream* stream = GetOrCreateStream();
336 if (stream == nullptr) { 336 if (stream == nullptr) {
337 return 0; 337 return 0;
(...skipping 14 matching lines...) Expand all
352 // HTTP/2 requests should include the :authority pseudo hader. 352 // HTTP/2 requests should include the :authority pseudo hader.
353 spdy_headers[":authority"] = client_->server_id().host(); 353 spdy_headers[":authority"] = client_->server_id().host();
354 } 354 }
355 ret = stream->SendRequest(std::move(spdy_headers), body, fin); 355 ret = stream->SendRequest(std::move(spdy_headers), body, fin);
356 ++num_requests_; 356 ++num_requests_;
357 } else { 357 } else {
358 stream->WriteOrBufferBody(body.as_string(), fin, delegate); 358 stream->WriteOrBufferBody(body.as_string(), fin, delegate);
359 ret = body.length(); 359 ret = body.length();
360 } 360 }
361 if (FLAGS_enable_quic_stateless_reject_support) { 361 if (FLAGS_enable_quic_stateless_reject_support) {
362 BalsaHeaders* new_headers = nullptr; 362 std::unique_ptr<SpdyHeaderBlock> new_headers;
363 if (headers) { 363 if (headers) {
364 new_headers = new BalsaHeaders; 364 new_headers.reset(new SpdyHeaderBlock(
365 new_headers->CopyFrom(*headers); 365 SpdyBalsaUtils::RequestHeadersToSpdyHeaders(*headers)));
366 } 366 }
367 std::unique_ptr<QuicClient::QuicDataToResend> data_to_resend( 367 std::unique_ptr<QuicClientBase::QuicDataToResend> data_to_resend(
368 new TestClientDataToResend(new_headers, body, fin, this, delegate)); 368 new TestClientDataToResend(std::move(new_headers), body, fin, this,
369 delegate));
369 client()->MaybeAddQuicDataToResend(std::move(data_to_resend)); 370 client()->MaybeAddQuicDataToResend(std::move(data_to_resend));
370 } 371 }
371 return ret; 372 return ret;
372 } 373 }
373 374
374 ssize_t QuicTestClient::SendMessage(const HTTPMessage& message) { 375 ssize_t QuicTestClient::SendMessage(const HTTPMessage& message) {
375 stream_ = nullptr; // Always force creation of a stream for SendMessage. 376 stream_ = nullptr; // Always force creation of a stream for SendMessage.
376 // Any response we might have received for a previous request would no longer 377 // Any response we might have received for a previous request would no longer
377 // be valid. TODO(jeffpiazza): There's probably additional client state that 378 // be valid. TODO(jeffpiazza): There's probably additional client state that
378 // should be reset here, too, if we were being more careful. 379 // should be reset here, too, if we were being more careful.
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 return 0; 730 return 0;
730 } 731 }
731 732
732 void QuicTestClient::WaitForWriteToFlush() { 733 void QuicTestClient::WaitForWriteToFlush() {
733 while (connected() && client()->session()->HasDataToWrite()) { 734 while (connected() && client()->session()->HasDataToWrite()) {
734 client_->WaitForEvents(); 735 client_->WaitForEvents();
735 } 736 }
736 } 737 }
737 738
738 void QuicTestClient::TestClientDataToResend::Resend() { 739 void QuicTestClient::TestClientDataToResend::Resend() {
739 test_client_->GetOrCreateStreamAndSendRequest(headers_, body_, fin_, 740 BalsaHeaders balsa_headers;
741 SpdyBalsaUtils::SpdyHeadersToRequestHeaders(*headers_, &balsa_headers);
742 test_client_->GetOrCreateStreamAndSendRequest(&balsa_headers, body_, fin_,
740 delegate_); 743 delegate_);
741 if (headers_ != nullptr) { 744 headers_.reset();
742 delete headers_;
743 headers_ = nullptr;
744 }
745 } 745 }
746 746
747 // static 747 // static
748 void QuicTestClient::FillInRequest(const string& uri, HTTPMessage* message) { 748 void QuicTestClient::FillInRequest(const string& uri, HTTPMessage* message) {
749 CHECK(message); 749 CHECK(message);
750 message->headers()->SetRequestVersion( 750 message->headers()->SetRequestVersion(
751 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1)); 751 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1));
752 message->headers()->SetRequestMethod( 752 message->headers()->SetRequestMethod(
753 HTTPMessage::MethodToString(HttpConstants::GET)); 753 HTTPMessage::MethodToString(HttpConstants::GET));
754 message->headers()->SetRequestUri(uri); 754 message->headers()->SetRequestUri(uri);
755 } 755 }
756 756
757 } // namespace test 757 } // namespace test
758 } // namespace net 758 } // 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