| 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 // See net/disk_cache/disk_cache.h for the public interface of the cache. | 5 // See net/disk_cache/disk_cache.h for the public interface of the cache. |
| 6 | 6 |
| 7 #ifndef NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ | 7 #ifndef NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ |
| 8 #define NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ | 8 #define NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 void CleanupCache(); | 67 void CleanupCache(); |
| 68 | 68 |
| 69 // Synchronous implementation of the asynchronous interface. | 69 // Synchronous implementation of the asynchronous interface. |
| 70 int SyncOpenEntry(const std::string& key, Entry** entry); | 70 int SyncOpenEntry(const std::string& key, Entry** entry); |
| 71 int SyncCreateEntry(const std::string& key, Entry** entry); | 71 int SyncCreateEntry(const std::string& key, Entry** entry); |
| 72 int SyncDoomEntry(const std::string& key); | 72 int SyncDoomEntry(const std::string& key); |
| 73 int SyncDoomAllEntries(); | 73 int SyncDoomAllEntries(); |
| 74 int SyncDoomEntriesBetween(base::Time initial_time, | 74 int SyncDoomEntriesBetween(base::Time initial_time, |
| 75 base::Time end_time); | 75 base::Time end_time); |
| 76 int SyncDoomEntriesSince(base::Time initial_time); | 76 int SyncDoomEntriesSince(base::Time initial_time); |
| 77 int SyncOpenNextEntry(void** iter, Entry** next_entry); | 77 int SyncOpenNextEntry(Rankings::Iterator* iterator, Entry** next_entry); |
| 78 void SyncEndEnumeration(void* iter); | 78 void SyncEndEnumeration(scoped_ptr<Rankings::Iterator> iterator); |
| 79 void SyncOnExternalCacheHit(const std::string& key); | 79 void SyncOnExternalCacheHit(const std::string& key); |
| 80 | 80 |
| 81 // Open or create an entry for the given |key| or |iter|. | 81 // Open or create an entry for the given |key| or |iter|. |
| 82 EntryImpl* OpenEntryImpl(const std::string& key); | 82 EntryImpl* OpenEntryImpl(const std::string& key); |
| 83 EntryImpl* CreateEntryImpl(const std::string& key); | 83 EntryImpl* CreateEntryImpl(const std::string& key); |
| 84 EntryImpl* OpenNextEntryImpl(void** iter); | 84 EntryImpl* OpenNextEntryImpl(Rankings::Iterator* iter); |
| 85 | 85 |
| 86 // Sets the maximum size for the total amount of data stored by this instance. | 86 // Sets the maximum size for the total amount of data stored by this instance. |
| 87 bool SetMaxSize(int max_bytes); | 87 bool SetMaxSize(int max_bytes); |
| 88 | 88 |
| 89 // Sets the cache type for this backend. | 89 // Sets the cache type for this backend. |
| 90 void SetType(net::CacheType type); | 90 void SetType(net::CacheType type); |
| 91 | 91 |
| 92 // Returns the full name for an external storage file. | 92 // Returns the full name for an external storage file. |
| 93 base::FilePath GetFileName(Addr address) const; | 93 base::FilePath GetFileName(Addr address) const; |
| 94 | 94 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 virtual int CreateEntry(const std::string& key, Entry** entry, | 266 virtual int CreateEntry(const std::string& key, Entry** entry, |
| 267 const CompletionCallback& callback) OVERRIDE; | 267 const CompletionCallback& callback) OVERRIDE; |
| 268 virtual int DoomEntry(const std::string& key, | 268 virtual int DoomEntry(const std::string& key, |
| 269 const CompletionCallback& callback) OVERRIDE; | 269 const CompletionCallback& callback) OVERRIDE; |
| 270 virtual int DoomAllEntries(const CompletionCallback& callback) OVERRIDE; | 270 virtual int DoomAllEntries(const CompletionCallback& callback) OVERRIDE; |
| 271 virtual int DoomEntriesBetween(base::Time initial_time, | 271 virtual int DoomEntriesBetween(base::Time initial_time, |
| 272 base::Time end_time, | 272 base::Time end_time, |
| 273 const CompletionCallback& callback) OVERRIDE; | 273 const CompletionCallback& callback) OVERRIDE; |
| 274 virtual int DoomEntriesSince(base::Time initial_time, | 274 virtual int DoomEntriesSince(base::Time initial_time, |
| 275 const CompletionCallback& callback) OVERRIDE; | 275 const CompletionCallback& callback) OVERRIDE; |
| 276 virtual int OpenNextEntry(void** iter, Entry** next_entry, | 276 // NOTE: The blockfile Backend::Iterator::OpenNextEntry method does not modify |
| 277 const CompletionCallback& callback) OVERRIDE; | 277 // the last_used field of the entry, and therefore it does not impact the |
| 278 virtual void EndEnumeration(void** iter) OVERRIDE; | 278 // eviction ranking of the entry. However, an enumeration will go through all |
| 279 // entries on the cache only if the cache is not modified while the |
| 280 // enumeration is taking place. Significantly altering the entry pointed by |
| 281 // the iterator (for example, deleting the entry) will invalidate the |
| 282 // iterator. Performing operations on an entry that modify the entry may |
| 283 // result in loops in the iteration, skipped entries or similar. |
| 284 virtual scoped_ptr<Iterator> CreateIterator() OVERRIDE; |
| 279 virtual void GetStats(StatsItems* stats) OVERRIDE; | 285 virtual void GetStats(StatsItems* stats) OVERRIDE; |
| 280 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; | 286 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; |
| 281 | 287 |
| 282 private: | 288 private: |
| 283 typedef base::hash_map<CacheAddr, EntryImpl*> EntriesMap; | 289 typedef base::hash_map<CacheAddr, EntryImpl*> EntriesMap; |
| 290 class IteratorImpl; |
| 284 | 291 |
| 285 // Creates a new backing file for the cache index. | 292 // Creates a new backing file for the cache index. |
| 286 bool CreateBackingStore(disk_cache::File* file); | 293 bool CreateBackingStore(disk_cache::File* file); |
| 287 bool InitBackingStore(bool* file_created); | 294 bool InitBackingStore(bool* file_created); |
| 288 void AdjustMaxCacheSize(int table_len); | 295 void AdjustMaxCacheSize(int table_len); |
| 289 | 296 |
| 290 bool InitStats(); | 297 bool InitStats(); |
| 291 void StoreStats(); | 298 void StoreStats(); |
| 292 | 299 |
| 293 // Deletes the cache and starts again. | 300 // Deletes the cache and starts again. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 base::WaitableEvent done_; // Signals the end of background work. | 397 base::WaitableEvent done_; // Signals the end of background work. |
| 391 scoped_refptr<TraceObject> trace_object_; // Initializes internal tracing. | 398 scoped_refptr<TraceObject> trace_object_; // Initializes internal tracing. |
| 392 base::WeakPtrFactory<BackendImpl> ptr_factory_; | 399 base::WeakPtrFactory<BackendImpl> ptr_factory_; |
| 393 | 400 |
| 394 DISALLOW_COPY_AND_ASSIGN(BackendImpl); | 401 DISALLOW_COPY_AND_ASSIGN(BackendImpl); |
| 395 }; | 402 }; |
| 396 | 403 |
| 397 } // namespace disk_cache | 404 } // namespace disk_cache |
| 398 | 405 |
| 399 #endif // NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ | 406 #endif // NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ |
| OLD | NEW |