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

Unified Diff: net/tools/quic/quic_simple_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, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/quic_simple_client.h ('k') | net/tools/quic/quic_simple_client_bin.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_simple_client.cc
diff --git a/net/tools/quic/quic_simple_client.cc b/net/tools/quic/quic_simple_client.cc
index 41cca71144c6d5d6871521194abec7cfe1d93df8..22d5380bd671780ae2dbcb60b9daf198d0c7d5b0 100644
--- a/net/tools/quic/quic_simple_client.cc
+++ b/net/tools/quic/quic_simple_client.cc
@@ -28,12 +28,12 @@
using std::string;
using std::vector;
+using base::StringPiece;
namespace net {
void QuicSimpleClient::ClientQuicDataToResend::Resend() {
client_->SendRequest(*headers_, body_, fin_);
- delete headers_;
headers_ = nullptr;
}
@@ -93,17 +93,6 @@ bool QuicSimpleClient::Initialize() {
return true;
}
-QuicSimpleClient::QuicDataToResend::QuicDataToResend(HttpRequestInfo* headers,
- base::StringPiece body,
- bool fin)
- : headers_(headers), body_(body), fin_(fin) {}
-
-QuicSimpleClient::QuicDataToResend::~QuicDataToResend() {
- if (headers_) {
- delete headers_;
- }
-}
-
bool QuicSimpleClient::CreateUDPSocket() {
std::unique_ptr<UDPClientSocket> socket(
new UDPClientSocket(DatagramSocket::DEFAULT_BIND, RandIntCallback(),
@@ -244,25 +233,22 @@ void QuicSimpleClient::Disconnect() {
initialized_ = false;
}
-void QuicSimpleClient::SendRequest(const HttpRequestInfo& headers,
- base::StringPiece body,
+void QuicSimpleClient::SendRequest(const SpdyHeaderBlock& headers,
+ StringPiece body,
bool fin) {
QuicSpdyClientStream* stream = CreateReliableClientStream();
if (stream == nullptr) {
LOG(DFATAL) << "stream creation failed!";
return;
}
- SpdyHeaderBlock header_block;
- CreateSpdyHeadersFromHttpRequest(headers, headers.extra_headers, true,
- &header_block);
stream->set_visitor(this);
- stream->SendRequest(std::move(header_block), body, fin);
+ stream->SendRequest(headers.Clone(), body, fin);
if (FLAGS_enable_quic_stateless_reject_support) {
// Record this in case we need to resend.
- auto* new_headers = new HttpRequestInfo;
- *new_headers = headers;
- auto* data_to_resend =
- new ClientQuicDataToResend(new_headers, body, fin, this);
+ std::unique_ptr<SpdyHeaderBlock> new_headers(
+ new SpdyHeaderBlock(headers.Clone()));
+ auto data_to_resend =
+ new ClientQuicDataToResend(std::move(new_headers), body, fin, this);
MaybeAddQuicDataToResend(std::unique_ptr<QuicDataToResend>(data_to_resend));
}
}
@@ -283,10 +269,10 @@ void QuicSimpleClient::MaybeAddQuicDataToResend(
}
void QuicSimpleClient::SendRequestAndWaitForResponse(
- const HttpRequestInfo& request,
+ const SpdyHeaderBlock& headers,
base::StringPiece body,
bool fin) {
- SendRequest(request, body, fin);
+ SendRequest(headers, body, fin);
while (WaitForEvents()) {
}
}
@@ -294,10 +280,13 @@ void QuicSimpleClient::SendRequestAndWaitForResponse(
void QuicSimpleClient::SendRequestsAndWaitForResponse(
const base::CommandLine::StringVector& url_list) {
for (size_t i = 0; i < url_list.size(); ++i) {
- HttpRequestInfo request;
- request.method = "GET";
- request.url = GURL(url_list[i]);
- SendRequest(request, "", true);
+ string url = GURL(url_list[i]).spec();
+ SpdyHeaderBlock headers;
+ if (!SpdyUtils::PopulateHeaderBlockFromUrl(url, &headers)) {
+ QUIC_BUG << "Unable to create request";
+ continue;
+ }
+ SendRequest(headers, "", true);
}
while (WaitForEvents()) {
« no previous file with comments | « net/tools/quic/quic_simple_client.h ('k') | net/tools/quic/quic_simple_client_bin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698