diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-16 21:05:47 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-16 21:05:47 +0000 |
commit | a5c713fdc8d0bf21f65ebdae95827e423d14b07c (patch) | |
tree | 82e553e97f38aa159978805e415fa683189201e0 /net/url_request/url_request_job_manager.cc | |
parent | 2cb1ecb7aa5b6bf5c17cfaa75293121c8bd73130 (diff) | |
download | chromium_src-a5c713fdc8d0bf21f65ebdae95827e423d14b07c.zip chromium_src-a5c713fdc8d0bf21f65ebdae95827e423d14b07c.tar.gz chromium_src-a5c713fdc8d0bf21f65ebdae95827e423d14b07c.tar.bz2 |
URLRequest::Interceptor enhancements1) Allow an interceptor to change its mind and not intercept after all. This allows the decision to start or not to start to be made asynchronously.2) Allow an interceptor to intercept on error conditions if the original job fails. This is to support the FALLBACK semantics in the appcache.Info about where this is going can be found in the appcache design doc at https://docs.google.com/a/google.com/Doc?docid=agv6ghfsqr_15f749cgt3&hl=enI still have to put together test cases, so I'm not ready to submit this yet, but wanted to get some feedback at this point.
Review URL: http://codereview.chromium.org/67019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13877 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/url_request_job_manager.cc')
-rw-r--r-- | net/url_request/url_request_job_manager.cc | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/net/url_request/url_request_job_manager.cc b/net/url_request/url_request_job_manager.cc index 9b550d1..bbc40e1 100644 --- a/net/url_request/url_request_job_manager.cc +++ b/net/url_request/url_request_job_manager.cc @@ -59,9 +59,8 @@ URLRequestJob* URLRequestJobManager::CreateJob(URLRequest* request) const { if (!request->url().is_valid()) return new URLRequestErrorJob(request, net::ERR_INVALID_URL); - const std::string& scheme = request->url().scheme(); // already lowercase - // We do this here to avoid asking interceptors about unsupported schemes. + const std::string& scheme = request->url().scheme(); // already lowercase if (!SupportsScheme(scheme)) return new URLRequestErrorJob(request, net::ERR_UNKNOWN_URL_SCHEME); @@ -104,6 +103,47 @@ URLRequestJob* URLRequestJobManager::CreateJob(URLRequest* request) const { return new URLRequestErrorJob(request, net::ERR_FAILED); } +URLRequestJob* URLRequestJobManager::MaybeInterceptRedirect( + URLRequest* request, + const GURL& location) const { +#ifndef NDEBUG + DCHECK(IsAllowedThread()); +#endif + if ((request->load_flags() & net::LOAD_DISABLE_INTERCEPT) || + (request->status().status() == URLRequestStatus::CANCELED) || + !request->url().is_valid() || + !SupportsScheme(request->url().scheme())) + return NULL; + + InterceptorList::const_iterator i; + for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { + URLRequestJob* job = (*i)->MaybeInterceptRedirect(request, location); + if (job) + return job; + } + return NULL; +} + +URLRequestJob* URLRequestJobManager::MaybeInterceptResponse( + URLRequest* request) const { +#ifndef NDEBUG + DCHECK(IsAllowedThread()); +#endif + if ((request->load_flags() & net::LOAD_DISABLE_INTERCEPT) || + (request->status().status() == URLRequestStatus::CANCELED) || + !request->url().is_valid() || + !SupportsScheme(request->url().scheme())) + return NULL; + + InterceptorList::const_iterator i; + for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { + URLRequestJob* job = (*i)->MaybeInterceptResponse(request); + if (job) + return job; + } + return NULL; +} + bool URLRequestJobManager::SupportsScheme(const std::string& scheme) const { // The set of registered factories may change on another thread. { |