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

Unified Diff: net/url_request/url_fetcher_core.cc

Issue 2653183006: Make URLFetcherCore::ReleaseRequest() release |buffer_|. (Closed)
Patch Set: address comment Created 3 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_fetcher_core.cc
diff --git a/net/url_request/url_fetcher_core.cc b/net/url_request/url_fetcher_core.cc
index 2a7a4d2899830a41287eab8107b5f2f462ece75d..25b60086d8f2732a2b84d47987720dd6d7ceced5 100644
--- a/net/url_request/url_fetcher_core.cc
+++ b/net/url_request/url_fetcher_core.cc
@@ -82,7 +82,6 @@ URLFetcherCore::URLFetcherCore(URLFetcher* fetcher,
delegate_task_runner_(base::SequencedTaskRunnerHandle::Get()),
load_flags_(LOAD_NORMAL),
response_code_(URLFetcher::RESPONSE_CODE_INVALID),
- buffer_(new IOBuffer(kBufferSize)),
url_request_data_key_(NULL),
was_fetched_via_proxy_(false),
was_cached_(false),
@@ -457,6 +456,7 @@ void URLFetcherCore::OnReadCompleted(URLRequest* request,
url_throttler_entry_ = throttler_manager->RegisterRequestUrl(url_);
while (bytes_read > 0) {
+ DCHECK(buffer_);
current_response_bytes_ += bytes_read;
InformDelegateDownloadProgress();
@@ -816,6 +816,7 @@ void URLFetcherCore::ReleaseRequest() {
request_context_getter_->RemoveObserver(this);
upload_progress_checker_timer_.reset();
request_.reset();
+ buffer_ = nullptr;
g_registry.Get().RemoveURLFetcherCore(this);
}
@@ -888,8 +889,11 @@ void URLFetcherCore::ReadResponse() {
// completed immediately, without trying to read any data back (all we care
// about is the response code and headers, which we already have).
int bytes_read = 0;
- if (request_type_ != URLFetcher::HEAD)
+ if (request_type_ != URLFetcher::HEAD) {
+ if (!buffer_)
+ buffer_ = new IOBuffer(kBufferSize);
mmenke 2017/01/25 16:32:16 Just do this unconditionally in OnResponseStarted,
xunjieli 2017/01/25 16:41:53 Done.
bytes_read = request_->Read(buffer_.get(), kBufferSize);
+ }
OnReadCompleted(request_.get(), bytes_read);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698