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

Unified Diff: net/url_request/url_request_job_manager.cc

Issue 7019030: Remove ProtocolFactory/Interceptor uses in GViewRequestInterceptor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix release. Created 9 years, 7 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') | no next file » | 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
diff --git a/net/url_request/url_request_job_manager.cc b/net/url_request/url_request_job_manager.cc
index dc6af79e909a1ab9055685dc13fc44481c4eb02f..71e9e55158232f9f83a98886433a72f75c7d462e 100644
--- a/net/url_request/url_request_job_manager.cc
+++ b/net/url_request/url_request_job_manager.cc
@@ -49,9 +49,7 @@ URLRequestJobManager* URLRequestJobManager::GetInstance() {
URLRequestJob* URLRequestJobManager::CreateJob(
URLRequest* request) const {
-#ifndef NDEBUG
DCHECK(IsAllowedThread());
-#endif
// If we are given an invalid URL, then don't even try to inspect the scheme.
if (!request->url().is_valid())
@@ -132,18 +130,35 @@ URLRequestJob* URLRequestJobManager::CreateJob(
URLRequestJob* URLRequestJobManager::MaybeInterceptRedirect(
URLRequest* request,
const GURL& location) const {
-#ifndef NDEBUG
DCHECK(IsAllowedThread());
-#endif
- if ((request->load_flags() & LOAD_DISABLE_INTERCEPT) ||
- (request->status().status() == URLRequestStatus::CANCELED) ||
- !request->url().is_valid() ||
- !SupportsScheme(request->url().scheme()))
+ if (!request->url().is_valid() ||
+ request->load_flags() & LOAD_DISABLE_INTERCEPT ||
+ request->status().status() == URLRequestStatus::CANCELED) {
+ return NULL;
+ }
+
+ const URLRequestJobFactory* job_factory = NULL;
+ if (request->context())
+ job_factory = request->context()->job_factory();
+
+ const std::string& scheme = request->url().scheme(); // already lowercase
+ if (job_factory) {
+ if (!job_factory->IsHandledProtocol(scheme)) {
+ return NULL;
+ }
+ } else if (!SupportsScheme(scheme)) {
return NULL;
+ }
+
+ URLRequestJob* job = NULL;
+ if (job_factory)
+ job = job_factory->MaybeInterceptRedirect(location, request);
+ if (job)
+ return job;
InterceptorList::const_iterator i;
for (i = interceptors_.begin(); i != interceptors_.end(); ++i) {
- URLRequestJob* job = (*i)->MaybeInterceptRedirect(request, location);
+ job = (*i)->MaybeInterceptRedirect(request, location);
if (job)
return job;
}
@@ -152,18 +167,35 @@ URLRequestJob* URLRequestJobManager::MaybeInterceptRedirect(
URLRequestJob* URLRequestJobManager::MaybeInterceptResponse(
URLRequest* request) const {
-#ifndef NDEBUG
DCHECK(IsAllowedThread());
-#endif
- if ((request->load_flags() & LOAD_DISABLE_INTERCEPT) ||
- (request->status().status() == URLRequestStatus::CANCELED) ||
- !request->url().is_valid() ||
- !SupportsScheme(request->url().scheme()))
+ if (!request->url().is_valid() ||
+ request->load_flags() & LOAD_DISABLE_INTERCEPT ||
+ request->status().status() == URLRequestStatus::CANCELED) {
return NULL;
+ }
+
+ const URLRequestJobFactory* job_factory = NULL;
+ if (request->context())
+ job_factory = request->context()->job_factory();
+
+ const std::string& scheme = request->url().scheme(); // already lowercase
+ if (job_factory) {
+ if (!job_factory->IsHandledProtocol(scheme)) {
+ return NULL;
+ }
+ } else if (!SupportsScheme(scheme)) {
+ return NULL;
+ }
+
+ URLRequestJob* job = NULL;
+ if (job_factory)
+ job = job_factory->MaybeInterceptResponse(request);
+ if (job)
+ return job;
InterceptorList::const_iterator i;
for (i = interceptors_.begin(); i != interceptors_.end(); ++i) {
- URLRequestJob* job = (*i)->MaybeInterceptResponse(request);
+ job = (*i)->MaybeInterceptResponse(request);
if (job)
return job;
}
@@ -188,9 +220,7 @@ bool URLRequestJobManager::SupportsScheme(const std::string& scheme) const {
URLRequest::ProtocolFactory* URLRequestJobManager::RegisterProtocolFactory(
const std::string& scheme,
URLRequest::ProtocolFactory* factory) {
-#ifndef NDEBUG
DCHECK(IsAllowedThread());
-#endif
base::AutoLock locked(lock_);
@@ -211,9 +241,7 @@ URLRequest::ProtocolFactory* URLRequestJobManager::RegisterProtocolFactory(
void URLRequestJobManager::RegisterRequestInterceptor(
URLRequest::Interceptor* interceptor) {
-#ifndef NDEBUG
DCHECK(IsAllowedThread());
-#endif
base::AutoLock locked(lock_);
@@ -224,9 +252,7 @@ void URLRequestJobManager::RegisterRequestInterceptor(
void URLRequestJobManager::UnregisterRequestInterceptor(
URLRequest::Interceptor* interceptor) {
-#ifndef NDEBUG
DCHECK(IsAllowedThread());
-#endif
base::AutoLock locked(lock_);
« no previous file with comments | « net/url_request/url_request_job_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698