Chromium Code Reviews| Index: net/spdy/spdy_stream.cc |
| =================================================================== |
| --- net/spdy/spdy_stream.cc (revision 144839) |
| +++ net/spdy/spdy_stream.cc (working copy) |
| @@ -151,7 +151,10 @@ |
| void SpdyStream::PossiblyResumeIfStalled() { |
| if (send_window_size_ > 0 && stalled_by_flow_control_) { |
| stalled_by_flow_control_ = false; |
| - io_state_ = STATE_SEND_BODY; |
| + if (delegate_->IsRequestBodyChunked()) |
| + io_state_ = STATE_SEND_CHUNKED_BODY; |
| + else |
| + io_state_ = STATE_SEND_BODY; |
| DoLoop(OK); |
| } |
| } |
| @@ -170,8 +173,11 @@ |
| // We should ignore WINDOW_UPDATEs received before or after this state, |
| // since before means we've not written SYN_STREAM yet (i.e. it's too |
| // early) and after means we've written a DATA frame with FIN bit. |
| - if (io_state_ != STATE_SEND_BODY_COMPLETE) |
| + if (io_state_ != STATE_SEND_BODY_COMPLETE && |
| + io_state_ != STATE_SEND_CHUNKED_BODY && |
| + io_state_ != STATE_SEND_CHUNKED_BODY_COMPLETE) { |
| return; |
|
Ryan Hamilton
2012/07/02 22:34:32
This still feels totally wrong to me. I do not th
ramant (doing other things)
2012/07/04 21:04:33
Done.
|
| + } |
| // it's valid for send_window_size_ to become negative (via an incoming |
| // SETTINGS), in which case incoming WINDOW_UPDATEs will eventually make |
| @@ -435,9 +441,10 @@ |
| } |
| void SpdyStream::OnChunkAvailable() { |
| - DCHECK(io_state_ == STATE_SEND_HEADERS || io_state_ == STATE_SEND_BODY || |
| - io_state_ == STATE_SEND_BODY_COMPLETE); |
| - if (io_state_ == STATE_SEND_BODY) |
| + DCHECK(io_state_ == STATE_SEND_HEADERS || |
| + io_state_ == STATE_SEND_CHUNKED_BODY || |
| + io_state_ == STATE_SEND_CHUNKED_BODY_COMPLETE); |
| + if (io_state_ == STATE_SEND_CHUNKED_BODY) |
| OnWriteComplete(0); |
| } |
| @@ -562,6 +569,12 @@ |
| CHECK_EQ(OK, result); |
| result = DoSendBody(); |
| break; |
| + case STATE_SEND_CHUNKED_BODY: |
| + result = DoSendChunkedBody(); |
| + break; |
| + case STATE_SEND_CHUNKED_BODY_COMPLETE: |
| + result = DoSendChunkedBodyComplete(result); |
| + break; |
| case STATE_SEND_BODY_COMPLETE: |
| result = DoSendBodyComplete(result); |
| break; |
| @@ -695,7 +708,10 @@ |
| return OK; |
| } |
| - io_state_ = STATE_SEND_BODY; |
| + if (delegate_->IsRequestBodyChunked()) |
| + io_state_ = STATE_SEND_CHUNKED_BODY; |
| + else |
| + io_state_ = STATE_SEND_BODY; |
| return OK; |
| } |
| @@ -730,6 +746,30 @@ |
| return result; |
| } |
| +int SpdyStream::DoSendChunkedBody() { |
| + io_state_ = STATE_SEND_CHUNKED_BODY_COMPLETE; |
| + if (!delegate_) |
| + return ERR_UNEXPECTED; |
| + return delegate_->OnSendChunkedBody(); |
| +} |
| + |
| +int SpdyStream::DoSendChunkedBodyComplete(int result) { |
| + if (result < 0) |
| + return result; |
| + |
| + if (!delegate_) |
| + return ERR_UNEXPECTED; |
| + |
| + bool eof = false; |
| + result = delegate_->OnSendChunkedBodyComplete(result, &eof); |
| + if (!eof) |
| + io_state_ = STATE_SEND_CHUNKED_BODY; |
| + else |
| + io_state_ = STATE_WAITING_FOR_RESPONSE; |
| + |
| + return result; |
| +} |
| + |
| int SpdyStream::DoOpen(int result) { |
| if (delegate_) |
| delegate_->OnDataSent(result); |