Chromium Code Reviews| Index: net/spdy/spdy_http_stream.cc |
| diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc |
| index 31b033aea06f0c30fbf0baaee878fd7732b11c13..4877408c2697d734d3bd89c06b8d0c6b22282214 100644 |
| --- a/net/spdy/spdy_http_stream.cc |
| +++ b/net/spdy/spdy_http_stream.cc |
| @@ -99,7 +99,10 @@ int SpdyHttpStream::InitializeStream(const HttpRequestInfo* request_info, |
| } |
| UploadProgress SpdyHttpStream::GetUploadProgress() const { |
| - if (!request_info_ || !HasUploadData()) |
| + if (!request_info_) |
| + return upload_progress_; |
|
mmenke
2016/08/31 21:57:59
Hrm...I wonder about all this UploadProgress plumb
shivanisha
2016/09/01 20:30:59
Why do we even need to go to the URLRequestJob, Ht
shivanisha
2016/09/01 20:32:12
Ah ok, I see your concerns about rewinding the str
shivanisha
2016/09/08 20:43:54
Removed all the plumbing for getting upload progre
|
| + |
| + if (!HasUploadData()) |
| return UploadProgress(); |
| return UploadProgress(request_info_->upload_data_stream->position(), |
| @@ -127,6 +130,12 @@ int SpdyHttpStream::ReadResponseHeaders(const CompletionCallback& callback) { |
| int SpdyHttpStream::ReadResponseBody( |
| IOBuffer* buf, int buf_len, const CompletionCallback& callback) { |
| + // Invalidate HttpRequestInfo pointer. This is to allow the stream to be |
| + // shared across multiple HttpCache::Transactions which might require this |
| + // stream to outlive the request_'s owner URLRequestHttpJob. |
| + if (request_info_) |
| + ResetRequestInfo(); |
| + |
| if (stream_.get()) |
| CHECK(!stream_->IsIdle()); |
| @@ -374,7 +383,7 @@ void SpdyHttpStream::OnTrailers(const SpdyHeaderBlock& trailers) {} |
| void SpdyHttpStream::OnClose(int status) { |
| // Cancel any pending reads from the upload data stream. |
| - if (request_info_->upload_data_stream) |
| + if (request_info_ && request_info_->upload_data_stream) |
| request_info_->upload_data_stream->Reset(); |
| if (stream_.get()) { |
| @@ -619,4 +628,15 @@ void SpdyHttpStream::SetPriority(RequestPriority priority) { |
| // |stream_|. |
| } |
| +void SpdyHttpStream::ResetRequestInfo() { |
| + // Only allowed when Reading of response body starts. It is safe to reset it |
| + // at this point since request_->upload_data_stream is also not needed |
| + // anymore. |
| + |
| + // Save upload progress if any. |
| + upload_progress_ = GetUploadProgress(); |
| + |
| + request_info_ = nullptr; |
| +} |
| + |
| } // namespace net |