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

Unified Diff: net/http/http_stream_parser.cc

Issue 2298823002: Resetting the HttpRequestInfo pointers in HttpNetworkTransaction and streams (Closed)
Patch Set: Initial patch Created 4 years, 4 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/http/http_stream_parser.cc
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index b543af5c68b6bb9b513d82fbe7ba621251865bfd..2a58b40413e73edf1bea7f337d14750c515c8e24 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -380,6 +380,12 @@ int HttpStreamParser::ReadResponseBody(IOBuffer* buf, int buf_len,
user_read_buf_len_ = buf_len;
io_state_ = STATE_READ_BODY;
+ // 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.
Randy Smith (Not in Mondays) 2016/09/01 20:18:31 As noted elsewhere, I'm really uncomfortable with
shivanisha 2016/09/08 20:43:54 done.
+ if (request_)
+ ResetRequestInfo();
+
int result = DoLoop(OK);
if (result == ERR_IO_PENDING)
callback_ = callback;
@@ -1090,6 +1096,9 @@ void HttpStreamParser::CalculateResponseBodySize() {
}
UploadProgress HttpStreamParser::GetUploadProgress() const {
+ if (!request_)
+ return upload_progress_;
+
if (!request_->upload_data_stream)
return UploadProgress();
@@ -1223,4 +1232,14 @@ bool HttpStreamParser::SendRequestBuffersEmpty() {
request_body_send_buf_ == nullptr;
}
+void HttpStreamParser::ResetRequestInfo() {
+ // Only allowed when Read state machine starts. It is safe to reset it at this
+ // point since request_->upload_data_stream is also not needed anymore.
+ DCHECK_EQ(STATE_READ_BODY, io_state_);
+
+ // save upload progress if any.
+ upload_progress_ = GetUploadProgress();
+ request_ = nullptr;
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698