| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 URLRequestJob* URLRequestJobManager::CreateJob( | 48 URLRequestJob* URLRequestJobManager::CreateJob( |
| 49 URLRequest* request, NetworkDelegate* network_delegate) const { | 49 URLRequest* request, NetworkDelegate* network_delegate) const { |
| 50 DCHECK(IsAllowedThread()); | 50 DCHECK(IsAllowedThread()); |
| 51 | 51 |
| 52 // If we are given an invalid URL, then don't even try to inspect the scheme. | 52 // If we are given an invalid URL, then don't even try to inspect the scheme. |
| 53 if (!request->url().is_valid()) | 53 if (!request->url().is_valid()) |
| 54 return new URLRequestErrorJob(request, network_delegate, ERR_INVALID_URL); | 54 return new URLRequestErrorJob(request, network_delegate, ERR_INVALID_URL); |
| 55 | 55 |
| 56 // We do this here to avoid asking interceptors about unsupported schemes. | 56 // We do this here to avoid asking interceptors about unsupported schemes. |
| 57 const URLRequestJobFactory* job_factory = NULL; | 57 const URLRequestJobFactory* job_factory = NULL; |
| 58 job_factory = request->context()->job_factory(); | 58 const std::string& scheme = request->url().scheme(); // already lowercase |
| 59 | 59 |
| 60 const std::string& scheme = request->url().scheme(); // already lowercase | 60 // Use request-specific job factory if it is given. |
| 61 job_factory = request->job_factory(); |
| 62 if (!job_factory || !job_factory->IsHandledProtocol(scheme)) { |
| 63 // Otherwise use the request context's factory. |
| 64 job_factory = request->context()->job_factory(); |
| 65 } |
| 66 |
| 61 if (job_factory) { | 67 if (job_factory) { |
| 62 if (!job_factory->IsHandledProtocol(scheme)) { | 68 if (!job_factory->IsHandledProtocol(scheme)) { |
| 63 return new URLRequestErrorJob( | 69 return new URLRequestErrorJob( |
| 64 request, network_delegate, ERR_UNKNOWN_URL_SCHEME); | 70 request, network_delegate, ERR_UNKNOWN_URL_SCHEME); |
| 65 } | 71 } |
| 66 } else if (!SupportsScheme(scheme)) { | 72 } else if (!SupportsScheme(scheme)) { |
| 67 return new URLRequestErrorJob( | 73 return new URLRequestErrorJob( |
| 68 request, network_delegate, ERR_UNKNOWN_URL_SCHEME); | 74 request, network_delegate, ERR_UNKNOWN_URL_SCHEME); |
| 69 } | 75 } |
| 70 | 76 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 254 } |
| 249 | 255 |
| 250 URLRequestJobManager::URLRequestJobManager() | 256 URLRequestJobManager::URLRequestJobManager() |
| 251 : allowed_thread_(0), | 257 : allowed_thread_(0), |
| 252 allowed_thread_initialized_(false) { | 258 allowed_thread_initialized_(false) { |
| 253 } | 259 } |
| 254 | 260 |
| 255 URLRequestJobManager::~URLRequestJobManager() {} | 261 URLRequestJobManager::~URLRequestJobManager() {} |
| 256 | 262 |
| 257 } // namespace net | 263 } // namespace net |
| OLD | NEW |