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

Side by Side Diff: content/public/browser/navigation_throttle.h

Issue 1414723008: Add a way to cancel deferred navigations in NavigationHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 1 month 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
« no previous file with comments | « content/public/browser/navigation_handle.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_PUBLIC_BROWSER_NAVIGATION_THROTTLE_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_NAVIGATION_THROTTLE_H_
6 #define CONTENT_PUBLIC_BROWSER_NAVIGATION_THROTTLE_H_ 6 #define CONTENT_PUBLIC_BROWSER_NAVIGATION_THROTTLE_H_
7 7
8 #include "content/common/content_export.h" 8 #include "content/common/content_export.h"
9 9
10 namespace content { 10 namespace content {
11 class NavigationHandle; 11 class NavigationHandle;
12 12
13 // A NavigationThrottle tracks and allows interaction with a navigation on the 13 // A NavigationThrottle tracks and allows interaction with a navigation on the
14 // UI thread. 14 // UI thread.
15 class CONTENT_EXPORT NavigationThrottle { 15 class CONTENT_EXPORT NavigationThrottle {
16 public: 16 public:
17 // This is returned to the NavigationHandle to allow the navigation to 17 // This is returned to the NavigationHandle to allow the navigation to
18 // proceed, or to cancel it. 18 // proceed, or to cancel it.
19 enum ThrottleCheckResult { 19 enum ThrottleCheckResult {
20 // The navigation proceeds uninterrupted.
20 PROCEED, 21 PROCEED,
22
23 // Defers the navigation until the NavigationThrottle calls
24 // NavigationHandle::Resume or NavigationHandle::CancelDeferredRequest.
25 // If the NavigationHandle is destroyed while the navigation is deferred,
26 // the navigation will be canceled in the network stack.
21 DEFER, 27 DEFER,
28
29 // Cancels the navigation.
30 CANCEL,
31
32 // Cancels the navigation and makes the requester of the navigation acts
33 // like the request was never made.
22 CANCEL_AND_IGNORE, 34 CANCEL_AND_IGNORE,
23 }; 35 };
24 36
25 NavigationThrottle(NavigationHandle* navigation_handle); 37 NavigationThrottle(NavigationHandle* navigation_handle);
26 virtual ~NavigationThrottle(); 38 virtual ~NavigationThrottle();
27 39
28 // Called when a network request is about to be made for this navigation. 40 // Called when a network request is about to be made for this navigation.
41 //
42 // The implementer is responsible for ensuring that the WebContents this
43 // throttle is associated with remain alive during the duration of this
44 // method. Failing to do so will result in use-after-free bugs. Should the
45 // implementer need to destroy the WebContents, it should return CANCEL,
46 // CANCEL_AND_IGNORE or DEFER and perform the destruction asynchronously.
29 virtual ThrottleCheckResult WillStartRequest(); 47 virtual ThrottleCheckResult WillStartRequest();
30 48
31 // Called when a server redirect is received by the navigation. 49 // Called when a server redirect is received by the navigation.
50 //
51 // The implementer is responsible for ensuring that the WebContents this
52 // throttle is associated with remain alive during the duration of this
53 // method. Failing to do so will result in use-after-free bugs. Should the
54 // implementer need to destroy the WebContents, it should return CANCEL,
55 // CANCEL_AND_IGNORE or DEFER and perform the destruction asynchronously.
32 virtual ThrottleCheckResult WillRedirectRequest(); 56 virtual ThrottleCheckResult WillRedirectRequest();
33 57
34 // The NavigationHandle that is tracking the information related to this 58 // The NavigationHandle that is tracking the information related to this
35 // navigation. 59 // navigation.
36 NavigationHandle* navigation_handle() const { return navigation_handle_; } 60 NavigationHandle* navigation_handle() const { return navigation_handle_; }
37 61
38 private: 62 private:
39 NavigationHandle* navigation_handle_; 63 NavigationHandle* navigation_handle_;
40 }; 64 };
41 65
42 } // namespace content 66 } // namespace content
43 67
44 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_THROTTLE_H_ 68 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_THROTTLE_H_
OLDNEW
« no previous file with comments | « content/public/browser/navigation_handle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698