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

Unified Diff: net/url_request/url_request_job_manager.cc

Issue 67019: URLRequest::Interceptor enhancements... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_job_manager.h ('k') | net/url_request/url_request_test_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_job_manager.cc
===================================================================
--- net/url_request/url_request_job_manager.cc (revision 13871)
+++ net/url_request/url_request_job_manager.cc (working copy)
@@ -59,9 +59,8 @@
if (!request->url().is_valid())
return new URLRequestErrorJob(request, net::ERR_INVALID_URL);
+ // We do this here to avoid asking interceptors about unsupported schemes.
const std::string& scheme = request->url().scheme(); // already lowercase
-
- // We do this here to avoid asking interceptors about unsupported schemes.
if (!SupportsScheme(scheme))
return new URLRequestErrorJob(request, net::ERR_UNKNOWN_URL_SCHEME);
@@ -104,6 +103,47 @@
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.
{
« no previous file with comments | « net/url_request/url_request_job_manager.h ('k') | net/url_request/url_request_test_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698