| 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 // This file declares a HttpTransactionFactory implementation that can be | 5 // This file declares a HttpTransactionFactory implementation that can be |
| 6 // layered on top of another HttpTransactionFactory to add HTTP caching. The | 6 // layered on top of another HttpTransactionFactory to add HTTP caching. The |
| 7 // caching logic follows RFC 2616 (any exceptions are called out in the code). | 7 // caching logic follows RFC 2616 (any exceptions are called out in the code). |
| 8 // | 8 // |
| 9 // The HttpCache takes a disk_cache::Backend as a parameter, and uses that for | 9 // The HttpCache takes a disk_cache::Backend as a parameter, and uses that for |
| 10 // the cache storage. | 10 // the cache storage. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 CompletionCallback* callback); | 109 CompletionCallback* callback); |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 CacheType type_; | 112 CacheType type_; |
| 113 const FilePath path_; | 113 const FilePath path_; |
| 114 int max_bytes_; | 114 int max_bytes_; |
| 115 scoped_refptr<base::MessageLoopProxy> thread_; | 115 scoped_refptr<base::MessageLoopProxy> thread_; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 // The disk cache is initialized lazily (by CreateTransaction) in this case. | 118 // The disk cache is initialized lazily (by CreateTransaction) in this case. |
| 119 // The HttpCache takes ownership of the |backend_factory|. | 119 // The HttpCache takes ownership of the |backend_factory|. |
| 120 HttpCache(HostResolver* host_resolver, | 120 HttpCache(HostResolver* host_resolver, |
| 121 DnsRRResolver* dnsrr_resolver, | 121 DnsRRResolver* dnsrr_resolver, |
| 122 ProxyService* proxy_service, | 122 ProxyService* proxy_service, |
| 123 SSLConfigService* ssl_config_service, | 123 SSLConfigService* ssl_config_service, |
| 124 HttpAuthHandlerFactory* http_auth_handler_factory, | 124 HttpAuthHandlerFactory* http_auth_handler_factory, |
| 125 HttpNetworkDelegate* network_delegate, | 125 HttpNetworkDelegate* network_delegate, |
| 126 NetLog* net_log, | 126 NetLog* net_log, |
| 127 BackendFactory* backend_factory); | 127 BackendFactory* backend_factory); |
| 128 | 128 |
| 129 // The disk cache is initialized lazily (by CreateTransaction) in this case. | 129 // The disk cache is initialized lazily (by CreateTransaction) in this case. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // Must remain at the end of the enum. | 193 // Must remain at the end of the enum. |
| 194 kNumCacheEntryDataIndices | 194 kNumCacheEntryDataIndices |
| 195 }; | 195 }; |
| 196 friend class ViewCacheHelper; | 196 friend class ViewCacheHelper; |
| 197 | 197 |
| 198 private: | 198 private: |
| 199 // Types -------------------------------------------------------------------- | 199 // Types -------------------------------------------------------------------- |
| 200 | 200 |
| 201 class BackendCallback; | 201 class BackendCallback; |
| 202 class MetadataWriter; | 202 class MetadataWriter; |
| 203 class SSLHostInfoFactoryAdaptor; |
| 203 class Transaction; | 204 class Transaction; |
| 204 class WorkItem; | 205 class WorkItem; |
| 205 friend class Transaction; | 206 friend class Transaction; |
| 206 struct PendingOp; // Info for an entry under construction. | 207 struct PendingOp; // Info for an entry under construction. |
| 207 | 208 |
| 208 typedef std::list<Transaction*> TransactionList; | 209 typedef std::list<Transaction*> TransactionList; |
| 209 typedef std::list<WorkItem*> WorkItemList; | 210 typedef std::list<WorkItem*> WorkItemList; |
| 210 | 211 |
| 211 struct ActiveEntry { | 212 struct ActiveEntry { |
| 212 disk_cache::Entry* disk_entry; | 213 disk_cache::Entry* disk_entry; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 347 |
| 347 | 348 |
| 348 // Variables ---------------------------------------------------------------- | 349 // Variables ---------------------------------------------------------------- |
| 349 | 350 |
| 350 // Used when lazily constructing the disk_cache_. | 351 // Used when lazily constructing the disk_cache_. |
| 351 scoped_ptr<BackendFactory> backend_factory_; | 352 scoped_ptr<BackendFactory> backend_factory_; |
| 352 bool building_backend_; | 353 bool building_backend_; |
| 353 | 354 |
| 354 Mode mode_; | 355 Mode mode_; |
| 355 | 356 |
| 357 scoped_ptr<SSLHostInfoFactoryAdaptor> ssl_host_info_factory_; |
| 358 |
| 356 scoped_ptr<HttpTransactionFactory> network_layer_; | 359 scoped_ptr<HttpTransactionFactory> network_layer_; |
| 357 scoped_ptr<disk_cache::Backend> disk_cache_; | 360 scoped_ptr<disk_cache::Backend> disk_cache_; |
| 358 | 361 |
| 359 // The set of active entries indexed by cache key. | 362 // The set of active entries indexed by cache key. |
| 360 ActiveEntriesMap active_entries_; | 363 ActiveEntriesMap active_entries_; |
| 361 | 364 |
| 362 // The set of doomed entries. | 365 // The set of doomed entries. |
| 363 ActiveEntriesSet doomed_entries_; | 366 ActiveEntriesSet doomed_entries_; |
| 364 | 367 |
| 365 // The set of entries "under construction". | 368 // The set of entries "under construction". |
| 366 PendingOpsMap pending_ops_; | 369 PendingOpsMap pending_ops_; |
| 367 | 370 |
| 368 ScopedRunnableMethodFactory<HttpCache> task_factory_; | 371 ScopedRunnableMethodFactory<HttpCache> task_factory_; |
| 369 | 372 |
| 370 bool enable_range_support_; | 373 bool enable_range_support_; |
| 371 | 374 |
| 372 typedef base::hash_map<std::string, int> PlaybackCacheMap; | 375 typedef base::hash_map<std::string, int> PlaybackCacheMap; |
| 373 scoped_ptr<PlaybackCacheMap> playback_cache_map_; | 376 scoped_ptr<PlaybackCacheMap> playback_cache_map_; |
| 374 | 377 |
| 375 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 378 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 376 }; | 379 }; |
| 377 | 380 |
| 378 } // namespace net | 381 } // namespace net |
| 379 | 382 |
| 380 #endif // NET_HTTP_HTTP_CACHE_H_ | 383 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |