| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "net/url_request/url_request_job_manager.h" | 5 #include "net/url_request/url_request_job_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 | 53 |
| 54 net::URLRequestJob* URLRequestJobManager::CreateJob( | 54 net::URLRequestJob* URLRequestJobManager::CreateJob( |
| 55 net::URLRequest* request) const { | 55 net::URLRequest* request) const { |
| 56 #ifndef NDEBUG | 56 #ifndef NDEBUG |
| 57 DCHECK(IsAllowedThread()); | 57 DCHECK(IsAllowedThread()); |
| 58 #endif | 58 #endif |
| 59 | 59 |
| 60 // If we are given an invalid URL, then don't even try to inspect the scheme. | 60 // If we are given an invalid URL, then don't even try to inspect the scheme. |
| 61 if (!request->url().is_valid()) | 61 if (!request->url().is_valid()) |
| 62 return new URLRequestErrorJob(request, net::ERR_INVALID_URL); | 62 return new net::URLRequestErrorJob(request, net::ERR_INVALID_URL); |
| 63 | 63 |
| 64 // We do this here to avoid asking interceptors about unsupported schemes. | 64 // We do this here to avoid asking interceptors about unsupported schemes. |
| 65 const std::string& scheme = request->url().scheme(); // already lowercase | 65 const std::string& scheme = request->url().scheme(); // already lowercase |
| 66 if (!SupportsScheme(scheme)) | 66 if (!SupportsScheme(scheme)) |
| 67 return new URLRequestErrorJob(request, net::ERR_UNKNOWN_URL_SCHEME); | 67 return new net::URLRequestErrorJob(request, net::ERR_UNKNOWN_URL_SCHEME); |
| 68 | 68 |
| 69 // THREAD-SAFETY NOTICE: | 69 // THREAD-SAFETY NOTICE: |
| 70 // We do not need to acquire the lock here since we are only reading our | 70 // We do not need to acquire the lock here since we are only reading our |
| 71 // data structures. They should only be modified on the current thread. | 71 // data structures. They should only be modified on the current thread. |
| 72 | 72 |
| 73 // See if the request should be intercepted. | 73 // See if the request should be intercepted. |
| 74 if (!(request->load_flags() & net::LOAD_DISABLE_INTERCEPT)) { | 74 if (!(request->load_flags() & net::LOAD_DISABLE_INTERCEPT)) { |
| 75 InterceptorList::const_iterator i; | 75 InterceptorList::const_iterator i; |
| 76 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { | 76 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { |
| 77 net::URLRequestJob* job = (*i)->MaybeIntercept(request); | 77 net::URLRequestJob* job = (*i)->MaybeIntercept(request); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 96 net::URLRequestJob* job = (kBuiltinFactories[i].factory)(request, scheme); | 96 net::URLRequestJob* job = (kBuiltinFactories[i].factory)(request, scheme); |
| 97 DCHECK(job); // The built-in factories are not expected to fail! | 97 DCHECK(job); // The built-in factories are not expected to fail! |
| 98 return job; | 98 return job; |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 // If we reached here, then it means that a registered protocol factory | 102 // If we reached here, then it means that a registered protocol factory |
| 103 // wasn't interested in handling the URL. That is fairly unexpected, and we | 103 // wasn't interested in handling the URL. That is fairly unexpected, and we |
| 104 // don't know have a specific error to report here :-( | 104 // don't know have a specific error to report here :-( |
| 105 LOG(WARNING) << "Failed to map: " << request->url().spec(); | 105 LOG(WARNING) << "Failed to map: " << request->url().spec(); |
| 106 return new URLRequestErrorJob(request, net::ERR_FAILED); | 106 return new net::URLRequestErrorJob(request, net::ERR_FAILED); |
| 107 } | 107 } |
| 108 | 108 |
| 109 net::URLRequestJob* URLRequestJobManager::MaybeInterceptRedirect( | 109 net::URLRequestJob* URLRequestJobManager::MaybeInterceptRedirect( |
| 110 net::URLRequest* request, | 110 net::URLRequest* request, |
| 111 const GURL& location) const { | 111 const GURL& location) const { |
| 112 #ifndef NDEBUG | 112 #ifndef NDEBUG |
| 113 DCHECK(IsAllowedThread()); | 113 DCHECK(IsAllowedThread()); |
| 114 #endif | 114 #endif |
| 115 if ((request->load_flags() & net::LOAD_DISABLE_INTERCEPT) || | 115 if ((request->load_flags() & net::LOAD_DISABLE_INTERCEPT) || |
| 116 (request->status().status() == URLRequestStatus::CANCELED) || | 116 (request->status().status() == URLRequestStatus::CANCELED) || |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 DCHECK(IsAllowedThread()); | 205 DCHECK(IsAllowedThread()); |
| 206 #endif | 206 #endif |
| 207 | 207 |
| 208 AutoLock locked(lock_); | 208 AutoLock locked(lock_); |
| 209 | 209 |
| 210 InterceptorList::iterator i = | 210 InterceptorList::iterator i = |
| 211 std::find(interceptors_.begin(), interceptors_.end(), interceptor); | 211 std::find(interceptors_.begin(), interceptors_.end(), interceptor); |
| 212 DCHECK(i != interceptors_.end()); | 212 DCHECK(i != interceptors_.end()); |
| 213 interceptors_.erase(i); | 213 interceptors_.erase(i); |
| 214 } | 214 } |
| OLD | NEW |