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 cfdd32db8acb5b0bf01b7fa280952e70a5230739..12021729ab43d2474cf3d4d8ee5bc31b618bd67f 100644 |
--- a/content/browser/frame_host/navigation_request.cc |
+++ b/content/browser/frame_host/navigation_request.cc |
@@ -446,7 +446,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( |
@@ -466,7 +466,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); |
// Abort the request if needed. This will destroy the NavigationRequest. |
if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
@@ -478,6 +479,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; |
} |
@@ -550,7 +553,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 || |
@@ -565,7 +569,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 || |
@@ -575,6 +579,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(); |