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

Unified Diff: net/url_request/url_request.cc

Issue 2480203002: ui: Cleanup class/struct forward declarations (Closed)
Patch Set: Sync CL to position 430550 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..368b91ae3eff103afdb77ae5bb48c5e20bc9eeb9 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
@@ -468,8 +469,10 @@ void URLRequest::set_first_party_url_policy(
first_party_url_policy_ = first_party_url_policy;
}
-void URLRequest::set_initiator(const url::Origin& initiator) {
+void URLRequest::set_initiator(const base::Optional<url::Origin>& initiator) {
DCHECK(!is_pending_);
+ DCHECK(!initiator.has_value() || initiator.value().unique() ||
+ initiator.value().GetURL().is_valid());
initiator_ = initiator;
}
@@ -895,7 +898,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 +912,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