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

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

Issue 2867833002: NavigationThrottle: allow customization of net::Error when blocking
Patch Set: Add unit tests. 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 55eb1ee156e9d58516b5d4eafbb640d93c2d3119..47b8702e2b40fb3938e481c51e0c01a5bfa5d103 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -680,16 +680,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
@@ -697,8 +698,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.
@@ -784,12 +786,12 @@ 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) {
// TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
OnRequestFailed(false, net::ERR_ABORTED);
@@ -798,7 +800,7 @@ void NavigationRequest::OnRedirectChecksComplete(
return;
}
- if (result == NavigationThrottle::BLOCK_REQUEST) {
+ if (result.action() == NavigationThrottle::BLOCK_REQUEST) {
OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT);
nasko 2017/05/11 00:09:54 Shouldn't we pass results.net_error_code() here? T
// DO NOT ADD CODE after this. The previous call to OnRequestFailed has
@@ -811,11 +813,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
@@ -824,6 +827,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
@@ -831,8 +836,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;

Powered by Google App Engine
This is Rietveld 408576698