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

Unified Diff: content/browser/frame_host/navigation_request.cc

Issue 2867833002: NavigationThrottle: allow customization of net::Error when blocking
Patch Set: Rebase Created 3 years, 7 months 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
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 786a0b5907588c28d7899ab7b9f2c232913f340e..499851d61c9b680a56f24ec89927a8576e25d27e 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -685,16 +685,17 @@ void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) {
void NavigationRequest::OnStartChecksComplete(
NavigationThrottle::ThrottleCheckResult result) {
- DCHECK(result != NavigationThrottle::DEFER);
- DCHECK(result != NavigationThrottle::BLOCK_RESPONSE);
+ DCHECK(result.action() != NavigationThrottle::DEFER);
+ DCHECK(result.action() != NavigationThrottle::BLOCK_RESPONSE);
if (on_start_checks_complete_closure_)
on_start_checks_complete_closure_.Run();
// Abort the request if needed. This will destroy the NavigationRequest.
- if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
- result == NavigationThrottle::CANCEL) {
+ if (result.action() == NavigationThrottle::CANCEL_AND_IGNORE ||
+ result.action() == NavigationThrottle::CANCEL) {
// TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
+ DCHECK_EQ(net::ERR_ABORTED, result.net_error_code());
OnRequestFailed(false, net::ERR_ABORTED);
// DO NOT ADD CODE after this. The previous call to OnRequestFailed has
@@ -702,8 +703,9 @@ void NavigationRequest::OnStartChecksComplete(
return;
}
- if (result == NavigationThrottle::BLOCK_REQUEST) {
- OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT);
+ if (result.action() == NavigationThrottle::BLOCK_REQUEST) {
+ DCHECK_NE(net::OK, result.net_error_code());
+ OnRequestFailed(false, result.net_error_code());
// DO NOT ADD CODE after this. The previous call to OnRequestFailed has
// destroyed the NavigationRequest.
@@ -789,12 +791,13 @@ void NavigationRequest::OnStartChecksComplete(
void NavigationRequest::OnRedirectChecksComplete(
NavigationThrottle::ThrottleCheckResult result) {
- DCHECK(result != NavigationThrottle::DEFER);
- DCHECK(result != NavigationThrottle::BLOCK_RESPONSE);
+ DCHECK(result.action() != NavigationThrottle::DEFER);
+ DCHECK(result.action() != NavigationThrottle::BLOCK_RESPONSE);
// Abort the request if needed. This will destroy the NavigationRequest.
- if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
- result == NavigationThrottle::CANCEL) {
+ if (result.action() == NavigationThrottle::CANCEL_AND_IGNORE ||
+ result.action() == NavigationThrottle::CANCEL) {
+ DCHECK_EQ(net::ERR_ABORTED, result.net_error_code());
// TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
OnRequestFailed(false, net::ERR_ABORTED);
@@ -803,8 +806,9 @@ void NavigationRequest::OnRedirectChecksComplete(
return;
}
- if (result == NavigationThrottle::BLOCK_REQUEST) {
- OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT);
+ if (result.action() == NavigationThrottle::BLOCK_REQUEST) {
+ DCHECK_NE(net::OK, result.net_error_code());
+ OnRequestFailed(false, result.net_error_code());
// DO NOT ADD CODE after this. The previous call to OnRequestFailed has
// destroyed the NavigationRequest.
@@ -816,11 +820,12 @@ void NavigationRequest::OnRedirectChecksComplete(
void NavigationRequest::OnWillProcessResponseChecksComplete(
NavigationThrottle::ThrottleCheckResult result) {
- DCHECK(result != NavigationThrottle::DEFER);
+ DCHECK(result.action() != NavigationThrottle::DEFER);
// If the NavigationThrottles allowed the navigation to continue, have the
// processing of the response resume in the network stack.
- if (result == NavigationThrottle::PROCEED)
+
+ if (result.action() == NavigationThrottle::PROCEED)
loader_->ProceedWithResponse();
// Abort the request if needed. This includes requests that were blocked by
@@ -829,6 +834,8 @@ void NavigationRequest::OnWillProcessResponseChecksComplete(
if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
result == NavigationThrottle::CANCEL || !response_should_be_rendered_) {
// TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
+ if (response_should_be_rendered_)
+ DCHECK_EQ(net::ERR_ABORTED, result.net_error_code());
OnRequestFailed(false, net::ERR_ABORTED);
// DO NOT ADD CODE after this. The previous call to OnRequestFailed has
@@ -836,8 +843,9 @@ void NavigationRequest::OnWillProcessResponseChecksComplete(
return;
}
- if (result == NavigationThrottle::BLOCK_RESPONSE) {
- OnRequestFailed(false, net::ERR_BLOCKED_BY_RESPONSE);
+ if (result.action() == NavigationThrottle::BLOCK_RESPONSE) {
+ DCHECK_NE(net::OK, result.net_error_code());
+ OnRequestFailed(false, result.net_error_code());
// DO NOT ADD CODE after this. The previous call to OnRequestFailed has
// destroyed the NavigationRequest.
return;
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl_unittest.cc ('k') | content/browser/loader/navigation_resource_throttle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698