diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 19:10:23 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 19:10:23 +0000 |
commit | 195e77d6f2d2f615c2a5138750db124853c0a093 (patch) | |
tree | e1ea14d75832faa10ca8951e82c44a1e4b1a03ab /net/url_request/url_request.h | |
parent | 35350e871b173b3daa1e6e9921e1930ecc9331c4 (diff) | |
download | chromium_src-195e77d6f2d2f615c2a5138750db124853c0a093.zip chromium_src-195e77d6f2d2f615c2a5138750db124853c0a093.tar.gz chromium_src-195e77d6f2d2f615c2a5138750db124853c0a093.tar.bz2 |
Add support to URLRequest for deferring redirects.
I chose to add an out parameter to OnReceivedRedirect because it allows for the
default behavior to remain the same.
I considered adding a ContinueAfterRedirect method that all OnReceivedRedirect
implementations would need to call, but this caused one annoying problem: In
the case of a ChromePlugin, it is possible for the URLRequest to get deleted
inside the handler for the redirect. This would make it hard to subsequently
call a method on the URLRequest since I would need to have a way to determine
if the URLRequest had been deleted.
TEST=covered by unit tests
BUG=16413,6442
R=eroman,wtc
Review URL: http://codereview.chromium.org/155897
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21417 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/url_request.h')
-rw-r--r-- | net/url_request/url_request.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h index 5ffec08..84da0cc 100644 --- a/net/url_request/url_request.h +++ b/net/url_request/url_request.h @@ -135,10 +135,19 @@ class URLRequest { // // When this function is called, the request will still contain the // original URL, the destination of the redirect is provided in 'new_url'. - // If the request is not canceled the redirect will be followed and the - // request's URL will be changed to the new URL. + // If the delegate does not cancel the request and |*defer_redirect| is + // false, then the redirect will be followed, and the request's URL will be + // changed to the new URL. Otherwise if the delegate does not cancel the + // request and |*defer_redirect| is true, then the redirect will be + // followed once FollowDeferredRedirect is called on the URLRequest. + // + // The caller must set |*defer_redirect| to false, so that delegates do not + // need to set it if they are happy with the default behavior of not + // deferring redirect. virtual void OnReceivedRedirect(URLRequest* request, - const GURL& new_url) = 0; + const GURL& new_url, + bool* defer_redirect) { + } // Called when we receive an authentication failure. The delegate should // call request->SetAuth() with the user's credentials once it obtains them, @@ -436,6 +445,10 @@ class URLRequest { // will be set to an error. bool Read(net::IOBuffer* buf, int max_bytes, int *bytes_read); + // This method may be called to follow a redirect that was deferred in + // response to an OnReceivedRedirect call. + void FollowDeferredRedirect(); + // One of the following two methods should be called in response to an // OnAuthRequired() callback (and only then). // SetAuth will reissue the request with the given credentials. @@ -494,7 +507,7 @@ class URLRequest { int Redirect(const GURL& location, int http_status_code); // Called by URLRequestJob to allow interception when a redirect occurs. - void ReceivedRedirect(const GURL& location); + void ReceivedRedirect(const GURL& location, bool* defer_redirect); // Called by URLRequestJob to allow interception when the final response // occurs. |