Index: content/browser/loader/resource_loader.cc |
diff --git a/content/browser/loader/resource_loader.cc b/content/browser/loader/resource_loader.cc |
index 81c77af32ecd1d5af1ab048f2ec93a127ce3600c..c90600897774aa0c69128249ab8e60b652fb723e 100644 |
--- a/content/browser/loader/resource_loader.cc |
+++ b/content/browser/loader/resource_loader.cc |
@@ -163,11 +163,6 @@ ResourceLoader::~ResourceLoader() { |
} |
void ResourceLoader::StartRequest() { |
- if (delegate_->HandleExternalProtocol(this, request_->url())) { |
- CancelAndIgnore(); |
- return; |
- } |
- |
// Give the handler a chance to delay the URLRequest from being started. |
bool defer_start = false; |
if (!handler_->OnWillStart(request_->url(), &defer_start)) { |
@@ -275,12 +270,6 @@ void ResourceLoader::OnReceivedRedirect(net::URLRequest* unused, |
delegate_->DidReceiveRedirect(this, redirect_info.new_url); |
- if (delegate_->HandleExternalProtocol(this, redirect_info.new_url)) { |
- // The request is complete so we can remove it. |
- CancelAndIgnore(); |
- return; |
- } |
- |
scoped_refptr<ResourceResponse> response = new ResourceResponse(); |
PopulateResourceResponse(info, request_.get(), cert_store_, response.get()); |
if (!handler_->OnRequestRedirected(redirect_info, response.get(), defer)) { |
@@ -457,7 +446,7 @@ void ResourceLoader::Resume() { |
request_->ResumeNetworkStart(); |
break; |
case DEFERRED_REDIRECT: |
- request_->FollowDeferredRedirect(); |
+ FollowDeferredRedirectInternal(); |
break; |
case DEFERRED_READ: |
base::ThreadTaskRunnerHandle::Get()->PostTask( |
@@ -483,8 +472,14 @@ void ResourceLoader::Cancel() { |
} |
void ResourceLoader::StartRequestInternal() { |
+ // At this point any possible deferred start is already over. |
DCHECK(!request_->is_pending()); |
+ if (delegate_->HandleExternalProtocol(this, request_->url())) { |
+ CancelAndIgnore(); |
+ return; |
+ } |
+ |
if (!request_->status().is_success()) { |
return; |
} |
@@ -541,6 +536,17 @@ void ResourceLoader::CancelRequestInternal(int error, bool from_renderer) { |
} |
} |
+void ResourceLoader::FollowDeferredRedirectInternal() { |
+ const GURL& new_url = request_->GetDeferredRedirectUrl(); |
+ if (delegate_->HandleExternalProtocol(this, new_url)) { |
+ // The request is complete so we can remove it. |
+ CancelAndIgnore(); |
+ return; |
+ } |
+ |
+ request_->FollowDeferredRedirect(); |
+} |
+ |
void ResourceLoader::CompleteResponseStarted() { |
ResourceRequestInfoImpl* info = GetRequestInfo(); |
scoped_refptr<ResourceResponse> response = new ResourceResponse(); |