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

Unified Diff: net/quic/bidirectional_stream_quic_impl.cc

Issue 1992953004: [Cronet] Make delaying sending request headers explicit in bidirectional stream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: correct a typo Created 4 years, 7 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/quic/bidirectional_stream_quic_impl.h ('k') | net/quic/bidirectional_stream_quic_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/bidirectional_stream_quic_impl.cc
diff --git a/net/quic/bidirectional_stream_quic_impl.cc b/net/quic/bidirectional_stream_quic_impl.cc
index b85997b67f2cd479e66dcf7191657bfd439fea2c..d34221050ca481d15ff41c5a0aeb7a1ce47d639b 100644
--- a/net/quic/bidirectional_stream_quic_impl.cc
+++ b/net/quic/bidirectional_stream_quic_impl.cc
@@ -32,7 +32,7 @@ BidirectionalStreamQuicImpl::BidirectionalStreamQuicImpl(
closed_stream_sent_bytes_(0),
has_sent_headers_(false),
has_received_headers_(false),
- disable_auto_flush_(false),
+ send_request_headers_automatically_(true),
weak_factory_(this) {
DCHECK(session_);
session_->AddObserver(this);
@@ -47,12 +47,12 @@ BidirectionalStreamQuicImpl::~BidirectionalStreamQuicImpl() {
void BidirectionalStreamQuicImpl::Start(
const BidirectionalStreamRequestInfo* request_info,
const BoundNetLog& net_log,
- bool disable_auto_flush,
+ bool send_request_headers_automatically,
BidirectionalStreamImpl::Delegate* delegate,
std::unique_ptr<base::Timer> /* timer */) {
DCHECK(!stream_);
- disable_auto_flush_ = disable_auto_flush;
+ send_request_headers_automatically_ = send_request_headers_automatically;
if (!session_) {
NotifyError(was_handshake_confirmed_ ? ERR_QUIC_PROTOCOL_ERROR
: ERR_QUIC_HANDSHAKE_FAILED);
@@ -73,6 +73,25 @@ void BidirectionalStreamQuicImpl::Start(
}
}
+void BidirectionalStreamQuicImpl::SendRequestHeaders() {
+ DCHECK(!has_sent_headers_);
+ DCHECK(stream_);
+
+ SpdyHeaderBlock headers;
+ HttpRequestInfo http_request_info;
+ http_request_info.url = request_info_->url;
+ http_request_info.method = request_info_->method;
+ http_request_info.extra_headers = request_info_->extra_headers;
+
+ CreateSpdyHeadersFromHttpRequest(http_request_info,
+ http_request_info.extra_headers, HTTP2, true,
+ &headers);
+ size_t headers_bytes_sent = stream_->WriteHeaders(
+ headers, request_info_->end_stream_on_headers, nullptr);
+ headers_bytes_sent_ += headers_bytes_sent;
+ has_sent_headers_ = true;
+}
+
int BidirectionalStreamQuicImpl::ReadData(IOBuffer* buffer, int buffer_len) {
DCHECK(buffer);
DCHECK(buffer_len);
@@ -103,6 +122,16 @@ void BidirectionalStreamQuicImpl::SendData(const scoped_refptr<IOBuffer>& data,
DCHECK(stream_);
DCHECK(length > 0 || (length == 0 && end_stream));
+ std::unique_ptr<QuicConnection::ScopedPacketBundler> bundler;
+ if (!has_sent_headers_) {
+ DCHECK(!send_request_headers_automatically_);
+ // Creates a bundler only if there are headers to be sent along with the
+ // single data buffer.
+ bundler.reset(new QuicConnection::ScopedPacketBundler(
+ session_->connection(), QuicConnection::SEND_ACK_IF_PENDING));
+ SendRequestHeaders();
+ }
+
base::StringPiece string_data(data->data(), length);
int rv = stream_->WriteStreamData(
string_data, end_stream,
@@ -126,6 +155,7 @@ void BidirectionalStreamQuicImpl::SendvData(
QuicConnection::ScopedPacketBundler bundler(
session_->connection(), QuicConnection::SEND_ACK_IF_PENDING);
if (!has_sent_headers_) {
+ DCHECK(!send_request_headers_automatically_);
SendRequestHeaders();
}
@@ -238,10 +268,10 @@ void BidirectionalStreamQuicImpl::OnStreamReady(int rv) {
DCHECK(rv == OK || !stream_);
if (rv == OK) {
stream_->SetDelegate(this);
- if (!disable_auto_flush_) {
+ if (send_request_headers_automatically_) {
SendRequestHeaders();
}
- delegate_->OnStreamReady();
+ delegate_->OnStreamReady(has_sent_headers_);
} else {
NotifyError(rv);
}
@@ -256,25 +286,6 @@ void BidirectionalStreamQuicImpl::OnSendDataComplete(int rv) {
}
}
-void BidirectionalStreamQuicImpl::SendRequestHeaders() {
- DCHECK(!has_sent_headers_);
- DCHECK(stream_);
-
- SpdyHeaderBlock headers;
- HttpRequestInfo http_request_info;
- http_request_info.url = request_info_->url;
- http_request_info.method = request_info_->method;
- http_request_info.extra_headers = request_info_->extra_headers;
-
- CreateSpdyHeadersFromHttpRequest(http_request_info,
- http_request_info.extra_headers, HTTP2, true,
- &headers);
- size_t frame_len = stream_->WriteHeaders(
- headers, request_info_->end_stream_on_headers, nullptr);
- headers_bytes_sent_ += frame_len;
- has_sent_headers_ = true;
-}
-
void BidirectionalStreamQuicImpl::NotifyError(int error) {
DCHECK_NE(OK, error);
DCHECK_NE(ERR_IO_PENDING, error);
« no previous file with comments | « net/quic/bidirectional_stream_quic_impl.h ('k') | net/quic/bidirectional_stream_quic_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698