Chromium Code Reviews| 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 a8d32e911e2311019cb8131cbb571d7f6da39a4e..020005d22b256d77caecc15e19f630659103f238 100644 |
| --- a/content/browser/frame_host/navigation_handle_impl.cc |
| +++ b/content/browser/frame_host/navigation_handle_impl.cc |
| @@ -279,6 +279,20 @@ void NavigationHandleImpl::WillRedirectRequest( |
| RunCompleteCallback(result); |
| } |
| +void NavigationHandleImpl::WillProcessResponse( |
| + scoped_refptr<net::HttpResponseHeaders> response_headers, |
| + const ThrottleChecksFinishedCallback& callback) { |
| + response_headers_ = response_headers; |
| + state_ = WILL_PROCESS_RESPONSE; |
| + complete_callback_ = callback; |
| + |
| + // Notify each throttle of the response. |
| + NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); |
| + |
| + DCHECK(result != NavigationThrottle::DEFER); |
|
clamy
2016/01/25 16:36:21
This should match the other checks:
// If the navi
Mike West
2016/01/26 09:41:41
Done.
|
| + RunCompleteCallback(result); |
| +} |
| + |
| void NavigationHandleImpl::DidRedirectNavigation(const GURL& new_url) { |
| url_ = new_url; |
| GetDelegate()->DidRedirectNavigation(this); |
| @@ -369,13 +383,40 @@ NavigationHandleImpl::CheckWillRedirectRequest() { |
| return NavigationThrottle::PROCEED; |
| } |
| +NavigationThrottle::ThrottleCheckResult |
| +NavigationHandleImpl::CheckWillProcessResponse() { |
| + DCHECK(state_ == WILL_PROCESS_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: |
|
clamy
2016/01/25 16:36:21
Since we're introducing it in the public API, we n
Mike West
2016/01/26 09:41:41
Done.
|
| + NOTREACHED(); |
| + } |
| + } |
| + state_ = WILL_PROCESS_RESPONSE; |
| + return NavigationThrottle::PROCEED; |
| +} |
| + |
| void NavigationHandleImpl::RunCompleteCallback( |
| NavigationThrottle::ThrottleCheckResult result) { |
| DCHECK(result != NavigationThrottle::DEFER); |
| - if (!complete_callback_.is_null()) |
| - complete_callback_.Run(result); |
| + ThrottleChecksFinishedCallback callback = complete_callback_; |
| complete_callback_.Reset(); |
| + |
| + if (!callback.is_null()) |
| + callback.Run(result); |
| + |
| + // No code after running the calback, as it might result in our destruction. |
| } |
| } // namespace content |