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; | |
204 class Transaction; | 203 class Transaction; |
205 class WorkItem; | 204 class WorkItem; |
206 friend class Transaction; | 205 friend class Transaction; |
207 struct PendingOp; // Info for an entry under construction. | 206 struct PendingOp; // Info for an entry under construction. |
208 | 207 |
209 typedef std::list<Transaction*> TransactionList; | 208 typedef std::list<Transaction*> TransactionList; |
210 typedef std::list<WorkItem*> WorkItemList; | 209 typedef std::list<WorkItem*> WorkItemList; |
211 | 210 |
212 struct ActiveEntry { | 211 struct ActiveEntry { |
213 disk_cache::Entry* disk_entry; | 212 disk_cache::Entry* disk_entry; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 346 |
348 | 347 |
349 // Variables ---------------------------------------------------------------- | 348 // Variables ---------------------------------------------------------------- |
350 | 349 |
351 // Used when lazily constructing the disk_cache_. | 350 // Used when lazily constructing the disk_cache_. |
352 scoped_ptr<BackendFactory> backend_factory_; | 351 scoped_ptr<BackendFactory> backend_factory_; |
353 bool building_backend_; | 352 bool building_backend_; |
354 | 353 |
355 Mode mode_; | 354 Mode mode_; |
356 | 355 |
357 scoped_ptr<SSLHostInfoFactoryAdaptor> ssl_host_info_factory_; | |
358 | |
359 scoped_ptr<HttpTransactionFactory> network_layer_; | 356 scoped_ptr<HttpTransactionFactory> network_layer_; |
360 scoped_ptr<disk_cache::Backend> disk_cache_; | 357 scoped_ptr<disk_cache::Backend> disk_cache_; |
361 | 358 |
362 // The set of active entries indexed by cache key. | 359 // The set of active entries indexed by cache key. |
363 ActiveEntriesMap active_entries_; | 360 ActiveEntriesMap active_entries_; |
364 | 361 |
365 // The set of doomed entries. | 362 // The set of doomed entries. |
366 ActiveEntriesSet doomed_entries_; | 363 ActiveEntriesSet doomed_entries_; |
367 | 364 |
368 // The set of entries "under construction". | 365 // The set of entries "under construction". |
369 PendingOpsMap pending_ops_; | 366 PendingOpsMap pending_ops_; |
370 | 367 |
371 ScopedRunnableMethodFactory<HttpCache> task_factory_; | 368 ScopedRunnableMethodFactory<HttpCache> task_factory_; |
372 | 369 |
373 bool enable_range_support_; | 370 bool enable_range_support_; |
374 | 371 |
375 typedef base::hash_map<std::string, int> PlaybackCacheMap; | 372 typedef base::hash_map<std::string, int> PlaybackCacheMap; |
376 scoped_ptr<PlaybackCacheMap> playback_cache_map_; | 373 scoped_ptr<PlaybackCacheMap> playback_cache_map_; |
377 | 374 |
378 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 375 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
379 }; | 376 }; |
380 | 377 |
381 } // namespace net | 378 } // namespace net |
382 | 379 |
383 #endif // NET_HTTP_HTTP_CACHE_H_ | 380 #endif // NET_HTTP_HTTP_CACHE_H_ |
OLD | NEW |