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

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: Fiddling. 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 callwed when all throttle checks have completed,
clamy 2016/01/25 16:36:21 nit: s/callwed/called
Mike West 2016/01/26 09:41:41 Thanks! :)
165 // allowing the caller to cancel the navigation or let it proceed. |callback|
166 // MUST NOT be called with a result of DEFER.
clamy 2016/01/25 16:36:21 s/MUST NOT/will not -> NavigationHandle makes a gu
Mike West 2016/01/26 09:41:41 Done.
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,
clamy 2016/01/25 16:36:21 Can you add a DEFFERRING_PROCESS_RESPONSE state as
Mike West 2016/01/26 09:41:41 Done.
193 READY_TO_COMMIT, 202 READY_TO_COMMIT,
194 DID_COMMIT, 203 DID_COMMIT,
195 DID_COMMIT_ERROR_PAGE, 204 DID_COMMIT_ERROR_PAGE,
196 }; 205 };
197 206
198 NavigationHandleImpl(const GURL& url, 207 NavigationHandleImpl(const GURL& url,
199 FrameTreeNode* frame_tree_node, 208 FrameTreeNode* frame_tree_node,
200 const base::TimeTicks& navigation_start); 209 const base::TimeTicks& navigation_start);
201 210
202 NavigationThrottle::ThrottleCheckResult CheckWillStartRequest(); 211 NavigationThrottle::ThrottleCheckResult CheckWillStartRequest();
203 NavigationThrottle::ThrottleCheckResult CheckWillRedirectRequest(); 212 NavigationThrottle::ThrottleCheckResult CheckWillRedirectRequest();
213 NavigationThrottle::ThrottleCheckResult CheckWillProcessResponse();
204 214
205 // Helper function to run and reset the |complete_callback_|. This marks the 215 // Helper function to run and reset the |complete_callback_|. This marks the
206 // end of a round of NavigationThrottleChecks. 216 // end of a round of NavigationThrottleChecks.
207 void RunCompleteCallback(NavigationThrottle::ThrottleCheckResult result); 217 void RunCompleteCallback(NavigationThrottle::ThrottleCheckResult result);
208 218
209 // Used in tests. 219 // Used in tests.
210 State state() const { return state_; } 220 State state() const { return state_; }
211 221
212 // See NavigationHandle for a description of those member variables. 222 // See NavigationHandle for a description of those member variables.
213 GURL url_; 223 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 257 // Manages the lifetime of a pre-created ServiceWorkerProviderHost until a
248 // corresponding ServiceWorkerNetworkProvider is created in the renderer. 258 // corresponding ServiceWorkerNetworkProvider is created in the renderer.
249 scoped_ptr<ServiceWorkerNavigationHandle> service_worker_handle_; 259 scoped_ptr<ServiceWorkerNavigationHandle> service_worker_handle_;
250 260
251 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl); 261 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl);
252 }; 262 };
253 263
254 } // namespace content 264 } // namespace content
255 265
256 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 266 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698