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

Unified Diff: net/spdy/spdy_http_stream.cc

Issue 6292013: Add chunked uploads support to SPDY (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 10 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
Index: net/spdy/spdy_http_stream.cc
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc
index e07578ec95d89db635939bc5e56fad44458a7390..a32a51eaf7c474ce6ebcd467a795f45684bbb42a 100644
--- a/net/spdy/spdy_http_stream.cc
+++ b/net/spdy/spdy_http_stream.cc
@@ -35,7 +35,8 @@ SpdyHttpStream::SpdyHttpStream(SpdySession* spdy_session,
user_buffer_len_(0),
buffered_read_callback_pending_(false),
more_read_data_pending_(false),
- direct_(direct) { }
+ direct_(direct),
+ send_last_chunk_(false) { }
void SpdyHttpStream::InitializeWithExistingStream(SpdyStream* spdy_stream) {
stream_ = spdy_stream;
@@ -177,6 +178,11 @@ void SpdyHttpStream::SetConnectionReused() {
// SPDY doesn't need an indicator here.
}
+void SpdyHttpStream::set_chunk_callback(ChunkCallback* callback) {
+ if (request_body_stream_ != NULL)
+ request_body_stream_->set_chunk_callback(callback);
+}
+
int SpdyHttpStream::SendRequest(const HttpRequestHeaders& request_headers,
UploadDataStream* request_body,
HttpResponseInfo* response,
@@ -200,7 +206,7 @@ int SpdyHttpStream::SendRequest(const HttpRequestHeaders& request_headers,
CHECK(!request_body_stream_.get());
if (request_body) {
- if (request_body->size())
+ if (request_body->size() || request_body->is_chunked())
request_body_stream_.reset(request_body);
else
delete request_body;
@@ -264,17 +270,46 @@ bool SpdyHttpStream::OnSendHeadersComplete(int status) {
int SpdyHttpStream::OnSendBody() {
CHECK(request_body_stream_.get());
+ if (send_last_chunk_) {
+ return stream_->WriteStreamData(request_body_stream_->buf(), 0,
+ spdy::DATA_FLAG_FIN);
+ }
+
int buf_len = static_cast<int>(request_body_stream_->buf_len());
if (!buf_len)
return OK;
- return stream_->WriteStreamData(request_body_stream_->buf(), buf_len,
- spdy::DATA_FLAG_FIN);
+ bool is_chunked = request_body_stream_->is_chunked();
+ return stream_->WriteStreamData(
+ request_body_stream_->buf(), buf_len,
+ is_chunked ? spdy::DATA_FLAG_NONE : spdy::DATA_FLAG_FIN);
}
-bool SpdyHttpStream::OnSendBodyComplete(int status) {
+int SpdyHttpStream::OnSendBodyComplete(int status, bool* eof) {
CHECK(request_body_stream_.get());
+
+ if (send_last_chunk_) { // Indicates that the last chunk was SENT here.
+ if (status != 0) {
+ NOTREACHED();
+ return ERR_UNEXPECTED;
+ }
+ *eof = true;
+ return OK;
+ }
+
request_body_stream_->MarkConsumedAndFillBuffer(status);
- return request_body_stream_->eof();
+ if (request_body_stream_->is_chunked()) {
+ *eof = false;
+ if (request_body_stream_->eof()) {
+ send_last_chunk_ = true;
+ } else {
+ if (!request_body_stream_->buf_len())
+ return ERR_IO_PENDING;
+ }
+ } else {
+ *eof = request_body_stream_->eof();
+ }
+
+ return OK;
}
int SpdyHttpStream::OnResponseReceived(const spdy::SpdyHeaderBlock& response,

Powered by Google App Engine
This is Rietveld 408576698