| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 return NULL; | 121 return NULL; |
| 122 | 122 |
| 123 InterceptorList::const_iterator i; | 123 InterceptorList::const_iterator i; |
| 124 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { | 124 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { |
| 125 URLRequestJob* job = (*i)->MaybeInterceptRedirect(request, | 125 URLRequestJob* job = (*i)->MaybeInterceptRedirect(request, |
| 126 network_delegate, | 126 network_delegate, |
| 127 location); | 127 location); |
| 128 if (job) | 128 if (job) |
| 129 return job; | 129 return job; |
| 130 } | 130 } |
| 131 |
| 132 URLRequestJob* job = |
| 133 request->context()->job_factory()->MaybeInterceptRedirect( |
| 134 request, network_delegate, location); |
| 135 if (job) |
| 136 return job; |
| 137 |
| 131 return NULL; | 138 return NULL; |
| 132 } | 139 } |
| 133 | 140 |
| 134 URLRequestJob* URLRequestJobManager::MaybeInterceptResponse( | 141 URLRequestJob* URLRequestJobManager::MaybeInterceptResponse( |
| 135 URLRequest* request, NetworkDelegate* network_delegate) const { | 142 URLRequest* request, NetworkDelegate* network_delegate) const { |
| 136 DCHECK(IsAllowedThread()); | 143 DCHECK(IsAllowedThread()); |
| 137 if (!request->url().is_valid() || | 144 if (!request->url().is_valid() || |
| 138 request->load_flags() & LOAD_DISABLE_INTERCEPT || | 145 request->load_flags() & LOAD_DISABLE_INTERCEPT || |
| 139 request->status().status() == URLRequestStatus::CANCELED) { | 146 request->status().status() == URLRequestStatus::CANCELED) { |
| 140 return NULL; | 147 return NULL; |
| 141 } | 148 } |
| 142 | 149 |
| 143 const URLRequestJobFactory* job_factory = NULL; | 150 const URLRequestJobFactory* job_factory = NULL; |
| 144 job_factory = request->context()->job_factory(); | 151 job_factory = request->context()->job_factory(); |
| 145 | 152 |
| 146 const std::string& scheme = request->url().scheme(); // already lowercase | 153 const std::string& scheme = request->url().scheme(); // already lowercase |
| 147 if (!job_factory->IsHandledProtocol(scheme)) | 154 if (!job_factory->IsHandledProtocol(scheme)) |
| 148 return NULL; | 155 return NULL; |
| 149 | 156 |
| 150 InterceptorList::const_iterator i; | 157 InterceptorList::const_iterator i; |
| 151 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { | 158 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { |
| 152 URLRequestJob* job = (*i)->MaybeInterceptResponse(request, | 159 URLRequestJob* job = (*i)->MaybeInterceptResponse(request, |
| 153 network_delegate); | 160 network_delegate); |
| 154 if (job) | 161 if (job) |
| 155 return job; | 162 return job; |
| 156 } | 163 } |
| 164 |
| 165 URLRequestJob* job = |
| 166 request->context()->job_factory()->MaybeInterceptResponse( |
| 167 request, network_delegate); |
| 168 if (job) |
| 169 return job; |
| 170 |
| 157 return NULL; | 171 return NULL; |
| 158 } | 172 } |
| 159 | 173 |
| 160 // static | 174 // static |
| 161 bool URLRequestJobManager::SupportsScheme(const std::string& scheme) { | 175 bool URLRequestJobManager::SupportsScheme(const std::string& scheme) { |
| 162 for (size_t i = 0; i < arraysize(kBuiltinFactories); ++i) { | 176 for (size_t i = 0; i < arraysize(kBuiltinFactories); ++i) { |
| 163 if (LowerCaseEqualsASCII(scheme, kBuiltinFactories[i].scheme)) | 177 if (LowerCaseEqualsASCII(scheme, kBuiltinFactories[i].scheme)) |
| 164 return true; | 178 return true; |
| 165 } | 179 } |
| 166 | 180 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 191 } | 205 } |
| 192 | 206 |
| 193 URLRequestJobManager::URLRequestJobManager() | 207 URLRequestJobManager::URLRequestJobManager() |
| 194 : allowed_thread_(0), | 208 : allowed_thread_(0), |
| 195 allowed_thread_initialized_(false) { | 209 allowed_thread_initialized_(false) { |
| 196 } | 210 } |
| 197 | 211 |
| 198 URLRequestJobManager::~URLRequestJobManager() {} | 212 URLRequestJobManager::~URLRequestJobManager() {} |
| 199 | 213 |
| 200 } // namespace net | 214 } // namespace net |
| OLD | NEW |