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

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

Issue 1645363002: Revert of Teach navigation throttles how to cancel requests in WillProcessResponse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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_handle_impl.cc
diff --git a/content/browser/frame_host/navigation_handle_impl.cc b/content/browser/frame_host/navigation_handle_impl.cc
index 27168939594e2e1689911cee6d08097b1507fe4e..a8d32e911e2311019cb8131cbb571d7f6da39a4e 100644
--- a/content/browser/frame_host/navigation_handle_impl.cc
+++ b/content/browser/frame_host/navigation_handle_impl.cc
@@ -147,23 +147,14 @@
}
void NavigationHandleImpl::Resume() {
- if (state_ != DEFERRING_START && state_ != DEFERRING_REDIRECT &&
- state_ != DEFERRING_RESPONSE) {
+ if (state_ != DEFERRING_START && state_ != DEFERRING_REDIRECT)
return;
- }
NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER;
if (state_ == DEFERRING_START) {
result = CheckWillStartRequest();
- } else if (state_ == DEFERRING_REDIRECT) {
+ } else {
result = CheckWillRedirectRequest();
- } else {
- result = CheckWillProcessResponse();
-
- // If the navigation is about to proceed after processing the response, then
- // it's ready to commit.
- if (result == NavigationThrottle::PROCEED)
- ReadyToCommitNavigation(render_frame_host_, response_headers_);
}
if (result != NavigationThrottle::DEFER)
@@ -288,28 +279,6 @@
RunCompleteCallback(result);
}
-void NavigationHandleImpl::WillProcessResponse(
- RenderFrameHostImpl* render_frame_host,
- scoped_refptr<net::HttpResponseHeaders> response_headers,
- const ThrottleChecksFinishedCallback& callback) {
- DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host);
- render_frame_host_ = render_frame_host;
- response_headers_ = response_headers;
- state_ = WILL_PROCESS_RESPONSE;
- complete_callback_ = callback;
-
- // Notify each throttle of the response.
- NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse();
-
- // If the navigation is about to proceed, then it's ready to commit.
- if (result == NavigationThrottle::PROCEED)
- ReadyToCommitNavigation(render_frame_host, response_headers);
-
- // If the navigation is not deferred, run the callback.
- if (result != NavigationThrottle::DEFER)
- RunCompleteCallback(result);
-}
-
void NavigationHandleImpl::DidRedirectNavigation(const GURL& new_url) {
url_ = new_url;
GetDelegate()->DidRedirectNavigation(this);
@@ -400,46 +369,13 @@
return NavigationThrottle::PROCEED;
}
-NavigationThrottle::ThrottleCheckResult
-NavigationHandleImpl::CheckWillProcessResponse() {
- DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE);
- DCHECK(state_ != WILL_PROCESS_RESPONSE || next_index_ == 0);
- DCHECK(state_ != DEFERRING_RESPONSE || next_index_ != 0);
- for (size_t i = next_index_; i < throttles_.size(); ++i) {
- NavigationThrottle::ThrottleCheckResult result =
- throttles_[i]->WillProcessResponse();
- switch (result) {
- case NavigationThrottle::PROCEED:
- continue;
-
- case NavigationThrottle::CANCEL:
- case NavigationThrottle::CANCEL_AND_IGNORE:
- state_ = CANCELING;
- return result;
-
- case NavigationThrottle::DEFER:
- state_ = DEFERRING_RESPONSE;
- next_index_ = i + 1;
- return result;
- }
- }
- next_index_ = 0;
- state_ = WILL_PROCESS_RESPONSE;
- return NavigationThrottle::PROCEED;
-}
-
void NavigationHandleImpl::RunCompleteCallback(
NavigationThrottle::ThrottleCheckResult result) {
DCHECK(result != NavigationThrottle::DEFER);
-
- ThrottleChecksFinishedCallback callback = complete_callback_;
+ if (!complete_callback_.is_null())
+ complete_callback_.Run(result);
+
complete_callback_.Reset();
-
- if (!callback.is_null())
- callback.Run(result);
-
- // No code after running the callback, as it might have resulted in our
- // destruction.
}
} // namespace content
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl.h ('k') | content/browser/frame_host/navigation_handle_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698