Index: content/browser/frame_host/navigation_request.cc |
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc |
index 3b0a2ac8a0966f060f60ef8bf799aeabdacf4852..efa835bc70856ae27a3d2192bafbde81b4d238e7 100644 |
--- a/content/browser/frame_host/navigation_request.cc |
+++ b/content/browser/frame_host/navigation_request.cc |
@@ -507,7 +507,7 @@ void NavigationRequest::OnResponseStarted( |
void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache, |
int net_error) { |
- DCHECK(state_ == STARTED); |
+ DCHECK(state_ == STARTED || state_ == RESPONSE_STARTED); |
state_ = FAILED; |
navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error)); |
frame_tree_node_->navigator()->FailedNavigation( |
@@ -527,7 +527,8 @@ void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { |
void NavigationRequest::OnStartChecksComplete( |
NavigationThrottle::ThrottleCheckResult result) { |
- CHECK(result != NavigationThrottle::DEFER); |
+ DCHECK(result != NavigationThrottle::DEFER); |
+ DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); |
if (on_start_checks_complete_closure_) |
on_start_checks_complete_closure_.Run(); |
@@ -542,6 +543,8 @@ void NavigationRequest::OnStartChecksComplete( |
if (result == NavigationThrottle::BLOCK_REQUEST) { |
OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT); |
+ // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
+ // destroyed the NavigationRequest. |
return; |
} |
@@ -620,7 +623,8 @@ void NavigationRequest::OnStartChecksComplete( |
void NavigationRequest::OnRedirectChecksComplete( |
NavigationThrottle::ThrottleCheckResult result) { |
- CHECK(result != NavigationThrottle::DEFER); |
+ DCHECK(result != NavigationThrottle::DEFER); |
+ DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); |
// Abort the request if needed. This will destroy the NavigationRequest. |
if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
@@ -635,7 +639,7 @@ void NavigationRequest::OnRedirectChecksComplete( |
void NavigationRequest::OnWillProcessResponseChecksComplete( |
NavigationThrottle::ThrottleCheckResult result) { |
- CHECK(result != NavigationThrottle::DEFER); |
+ DCHECK(result != NavigationThrottle::DEFER); |
// Abort the request if needed. This will destroy the NavigationRequest. |
if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
@@ -645,6 +649,13 @@ void NavigationRequest::OnWillProcessResponseChecksComplete( |
return; |
} |
+ if (result == NavigationThrottle::BLOCK_RESPONSE) { |
+ OnRequestFailed(false, net::ERR_BLOCKED_BY_RESPONSE); |
+ // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
+ // destroyed the NavigationRequest. |
+ return; |
+ } |
+ |
// Have the processing of the response resume in the network stack. |
loader_->ProceedWithResponse(); |