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

Side by Side Diff: content/browser/frame_host/navigation_handle_impl.h

Issue 1616943003: Teach navigation throttles how to cancel requests in WillProcessResponse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
7 7
8 #include "content/public/browser/navigation_handle.h" 8 #include "content/public/browser/navigation_handle.h"
9 9
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // |callback| will be called when all throttles check have completed. This 153 // |callback| will be called when all throttles check have completed. This
154 // will allow the caller to cancel the navigation or let it proceed. 154 // will allow the caller to cancel the navigation or let it proceed.
155 void WillRedirectRequest( 155 void WillRedirectRequest(
156 const GURL& new_url, 156 const GURL& new_url,
157 bool new_method_is_post, 157 bool new_method_is_post,
158 const GURL& new_referrer_url, 158 const GURL& new_referrer_url,
159 bool new_is_external_protocol, 159 bool new_is_external_protocol,
160 scoped_refptr<net::HttpResponseHeaders> response_headers, 160 scoped_refptr<net::HttpResponseHeaders> response_headers,
161 const ThrottleChecksFinishedCallback& callback); 161 const ThrottleChecksFinishedCallback& callback);
162 162
163 // Called when the URLRequest has delivered response headers and metadata.
164 // |callback| will be called when all throttle checks have completed,
165 // allowing the caller to cancel the navigation or let it proceed.
166 // NavigationHandle will not call |callback| with a result of DEFER.
167 void WillProcessResponse(
168 scoped_refptr<net::HttpResponseHeaders> response_headers,
169 const ThrottleChecksFinishedCallback& callback);
170
163 // Returns the FrameTreeNode this navigation is happening in. 171 // Returns the FrameTreeNode this navigation is happening in.
164 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } 172 FrameTreeNode* frame_tree_node() { return frame_tree_node_; }
165 173
166 // Called when the navigation was redirected. This will update the |url_| and 174 // Called when the navigation was redirected. This will update the |url_| and
167 // inform the delegate. 175 // inform the delegate.
168 void DidRedirectNavigation(const GURL& new_url); 176 void DidRedirectNavigation(const GURL& new_url);
169 177
170 // Called when the navigation is ready to be committed in 178 // Called when the navigation is ready to be committed in
171 // |render_frame_host|. This will update the |state_| and inform the 179 // |render_frame_host|. This will update the |state_| and inform the
172 // delegate. 180 // delegate.
(...skipping 10 matching lines...) Expand all
183 friend class NavigationHandleImplTest; 191 friend class NavigationHandleImplTest;
184 192
185 // Used to track the state the navigation is currently in. 193 // Used to track the state the navigation is currently in.
186 enum State { 194 enum State {
187 INITIAL = 0, 195 INITIAL = 0,
188 WILL_SEND_REQUEST, 196 WILL_SEND_REQUEST,
189 DEFERRING_START, 197 DEFERRING_START,
190 WILL_REDIRECT_REQUEST, 198 WILL_REDIRECT_REQUEST,
191 DEFERRING_REDIRECT, 199 DEFERRING_REDIRECT,
192 CANCELING, 200 CANCELING,
201 WILL_PROCESS_RESPONSE,
202 DEFERRING_RESPONSE,
193 READY_TO_COMMIT, 203 READY_TO_COMMIT,
194 DID_COMMIT, 204 DID_COMMIT,
195 DID_COMMIT_ERROR_PAGE, 205 DID_COMMIT_ERROR_PAGE,
196 }; 206 };
197 207
198 NavigationHandleImpl(const GURL& url, 208 NavigationHandleImpl(const GURL& url,
199 FrameTreeNode* frame_tree_node, 209 FrameTreeNode* frame_tree_node,
200 const base::TimeTicks& navigation_start); 210 const base::TimeTicks& navigation_start);
201 211
202 NavigationThrottle::ThrottleCheckResult CheckWillStartRequest(); 212 NavigationThrottle::ThrottleCheckResult CheckWillStartRequest();
203 NavigationThrottle::ThrottleCheckResult CheckWillRedirectRequest(); 213 NavigationThrottle::ThrottleCheckResult CheckWillRedirectRequest();
214 NavigationThrottle::ThrottleCheckResult CheckWillProcessResponse();
204 215
205 // Helper function to run and reset the |complete_callback_|. This marks the 216 // Helper function to run and reset the |complete_callback_|. This marks the
206 // end of a round of NavigationThrottleChecks. 217 // end of a round of NavigationThrottleChecks.
207 void RunCompleteCallback(NavigationThrottle::ThrottleCheckResult result); 218 void RunCompleteCallback(NavigationThrottle::ThrottleCheckResult result);
208 219
209 // Used in tests. 220 // Used in tests.
210 State state() const { return state_; } 221 State state() const { return state_; }
211 222
212 // See NavigationHandle for a description of those member variables. 223 // See NavigationHandle for a description of those member variables.
213 GURL url_; 224 GURL url_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // Manages the lifetime of a pre-created ServiceWorkerProviderHost until a 258 // Manages the lifetime of a pre-created ServiceWorkerProviderHost until a
248 // corresponding ServiceWorkerNetworkProvider is created in the renderer. 259 // corresponding ServiceWorkerNetworkProvider is created in the renderer.
249 scoped_ptr<ServiceWorkerNavigationHandle> service_worker_handle_; 260 scoped_ptr<ServiceWorkerNavigationHandle> service_worker_handle_;
250 261
251 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl); 262 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl);
252 }; 263 };
253 264
254 } // namespace content 265 } // namespace content
255 266
256 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 267 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698