OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/http/http_cache.h" | 5 #include "net/http/http_cache.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 | 10 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 194 } |
195 | 195 |
196 //----------------------------------------------------------------------------- | 196 //----------------------------------------------------------------------------- |
197 | 197 |
198 HttpCache::HttpCache(NetworkChangeNotifier* network_change_notifier, | 198 HttpCache::HttpCache(NetworkChangeNotifier* network_change_notifier, |
199 HostResolver* host_resolver, | 199 HostResolver* host_resolver, |
200 ProxyService* proxy_service, | 200 ProxyService* proxy_service, |
201 SSLConfigService* ssl_config_service, | 201 SSLConfigService* ssl_config_service, |
202 HttpAuthHandlerFactory* http_auth_handler_factory, | 202 HttpAuthHandlerFactory* http_auth_handler_factory, |
203 const FilePath& cache_dir, | 203 const FilePath& cache_dir, |
| 204 MessageLoop* cache_thread, |
204 int cache_size) | 205 int cache_size) |
205 : disk_cache_dir_(cache_dir), | 206 : disk_cache_dir_(cache_dir), |
| 207 cache_thread_(cache_thread), |
206 mode_(NORMAL), | 208 mode_(NORMAL), |
207 type_(DISK_CACHE), | 209 type_(DISK_CACHE), |
208 network_layer_(HttpNetworkLayer::CreateFactory( | 210 network_layer_(HttpNetworkLayer::CreateFactory( |
209 network_change_notifier, host_resolver, proxy_service, | 211 network_change_notifier, host_resolver, proxy_service, |
210 ssl_config_service, http_auth_handler_factory)), | 212 ssl_config_service, http_auth_handler_factory)), |
211 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), | 213 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), |
212 enable_range_support_(true), | 214 enable_range_support_(true), |
213 cache_size_(cache_size) { | 215 cache_size_(cache_size) { |
214 } | 216 } |
215 | 217 |
216 HttpCache::HttpCache(HttpNetworkSession* session, | 218 HttpCache::HttpCache(HttpNetworkSession* session, |
217 const FilePath& cache_dir, | 219 const FilePath& cache_dir, |
| 220 MessageLoop* cache_thread, |
218 int cache_size) | 221 int cache_size) |
219 : disk_cache_dir_(cache_dir), | 222 : disk_cache_dir_(cache_dir), |
| 223 cache_thread_(cache_thread), |
220 mode_(NORMAL), | 224 mode_(NORMAL), |
221 type_(DISK_CACHE), | 225 type_(DISK_CACHE), |
222 network_layer_(HttpNetworkLayer::CreateFactory(session)), | 226 network_layer_(HttpNetworkLayer::CreateFactory(session)), |
223 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), | 227 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), |
224 enable_range_support_(true), | 228 enable_range_support_(true), |
225 cache_size_(cache_size) { | 229 cache_size_(cache_size) { |
226 } | 230 } |
227 | 231 |
228 HttpCache::HttpCache(NetworkChangeNotifier* network_change_notifier, | 232 HttpCache::HttpCache(NetworkChangeNotifier* network_change_notifier, |
229 HostResolver* host_resolver, | 233 HostResolver* host_resolver, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // was an in-memory cache. | 286 // was an in-memory cache. |
283 disk_cache_.reset(disk_cache::CreateInMemoryCacheBackend(cache_size_)); | 287 disk_cache_.reset(disk_cache::CreateInMemoryCacheBackend(cache_size_)); |
284 } else if (!disk_cache_dir_.empty()) { | 288 } else if (!disk_cache_dir_.empty()) { |
285 disk_cache_.reset(disk_cache::CreateCacheBackend(disk_cache_dir_, true, | 289 disk_cache_.reset(disk_cache::CreateCacheBackend(disk_cache_dir_, true, |
286 cache_size_, type_)); | 290 cache_size_, type_)); |
287 disk_cache_dir_ = FilePath(); // Reclaim memory. | 291 disk_cache_dir_ = FilePath(); // Reclaim memory. |
288 } | 292 } |
289 return disk_cache_.get(); | 293 return disk_cache_.get(); |
290 } | 294 } |
291 | 295 |
| 296 int HttpCache::GetBackend(disk_cache::Backend** backend, |
| 297 CompletionCallback* callback) { |
| 298 DCHECK(callback != NULL); |
| 299 *backend = GetBackend(); |
| 300 return OK; |
| 301 } |
| 302 |
292 int HttpCache::CreateTransaction(scoped_ptr<HttpTransaction>* trans) { | 303 int HttpCache::CreateTransaction(scoped_ptr<HttpTransaction>* trans) { |
293 // Do lazy initialization of disk cache if needed. | 304 // Do lazy initialization of disk cache if needed. |
294 GetBackend(); | 305 GetBackend(); |
295 trans->reset(new HttpCache::Transaction(this, enable_range_support_)); | 306 trans->reset(new HttpCache::Transaction(this, enable_range_support_)); |
296 return OK; | 307 return OK; |
297 } | 308 } |
298 | 309 |
299 HttpCache* HttpCache::GetCache() { | 310 HttpCache* HttpCache::GetCache() { |
300 return this; | 311 return this; |
301 } | 312 } |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 item->NotifyTransaction(ERR_CACHE_RACE, NULL); | 913 item->NotifyTransaction(ERR_CACHE_RACE, NULL); |
903 fail_requests = true; | 914 fail_requests = true; |
904 } else { | 915 } else { |
905 item->NotifyTransaction(result, entry); | 916 item->NotifyTransaction(result, entry); |
906 } | 917 } |
907 } | 918 } |
908 } | 919 } |
909 } | 920 } |
910 | 921 |
911 } // namespace net | 922 } // namespace net |
OLD | NEW |