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

Unified Diff: net/url_request/url_request.cc

Issue 2480563002: Remove URLRequest::OrphanJob(). (Closed)
Patch Set: Response to comments Created 4 years, 1 month 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 | « net/url_request/url_request.h ('k') | net/url_request/url_request_http_job.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request.cc
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index 61308faafa8d04818411d808fa30329cb73ec569..61168b4128a52e434a31835bf704d3f20a685dd2 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -182,11 +182,12 @@ URLRequest::~URLRequest() {
job_->NotifyURLRequestDestroyed();
}
- if (job_.get())
- OrphanJob();
+ // Delete job before |this|, since subclasses may do weird things, like depend
+ // on UserData associated with |this| and poke at it during teardown.
+ job_.reset();
- int deleted = context_->url_requests()->erase(this);
- CHECK_EQ(1, deleted);
+ DCHECK_EQ(1u, context_->url_requests()->count(this));
+ context_->url_requests()->erase(this);
int net_error = OK;
// Log error only on failure, not cancellation, as even successful requests
@@ -895,7 +896,7 @@ void URLRequest::PrepareToRestart() {
// one.
net_log_.EndEvent(NetLogEventType::URL_REQUEST_START_JOB);
- OrphanJob();
+ job_.reset();
response_info_ = HttpResponseInfo();
response_info_.request_time = base::Time::Now();
@@ -909,19 +910,6 @@ void URLRequest::PrepareToRestart() {
proxy_server_ = ProxyServer();
}
-void URLRequest::OrphanJob() {
- // When calling this function, please check that URLRequestHttpJob is
- // not in between calling NetworkDelegate::NotifyHeadersReceived receiving
- // the call back. This is currently guaranteed by the following strategies:
- // - OrphanJob is called on JobRestart, in this case the URLRequestJob cannot
- // be receiving any headers at that time.
- // - OrphanJob is called in ~URLRequest, in this case
- // NetworkDelegate::NotifyURLRequestDestroyed notifies the NetworkDelegate
- // that the callback becomes invalid.
- job_->Kill();
- job_ = NULL;
-}
-
int URLRequest::Redirect(const RedirectInfo& redirect_info) {
// Matches call in NotifyReceivedRedirect.
OnCallToDelegateComplete();
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_http_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698