Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 // 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_BACKEND_IMPL_H_ | 7 #ifndef NET_DISK_CACHE_BACKEND_IMPL_H_ |
| 8 #define NET_DISK_CACHE_BACKEND_IMPL_H_ | 8 #define NET_DISK_CACHE_BACKEND_IMPL_H_ |
| 9 #pragma once | 9 #pragma once |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 // CreateCacheBackend(). | 53 // CreateCacheBackend(). |
| 54 static int CreateBackend(const FilePath& full_path, bool force, | 54 static int CreateBackend(const FilePath& full_path, bool force, |
| 55 int max_bytes, net::CacheType type, | 55 int max_bytes, net::CacheType type, |
| 56 uint32 flags, base::MessageLoopProxy* thread, | 56 uint32 flags, base::MessageLoopProxy* thread, |
| 57 net::NetLog* net_log, Backend** backend, | 57 net::NetLog* net_log, Backend** backend, |
| 58 CompletionCallback* callback); | 58 CompletionCallback* callback); |
| 59 | 59 |
| 60 // Performs general initialization for this current instance of the cache. | 60 // Performs general initialization for this current instance of the cache. |
| 61 int Init(CompletionCallback* callback); | 61 int Init(CompletionCallback* callback); |
| 62 | 62 |
| 63 // Backend interface. | |
| 64 virtual int32 GetEntryCount() const; | |
| 65 virtual int OpenEntry(const std::string& key, Entry** entry, | |
| 66 CompletionCallback* callback); | |
| 67 virtual int CreateEntry(const std::string& key, Entry** entry, | |
| 68 CompletionCallback* callback); | |
| 69 virtual int DoomEntry(const std::string& key, CompletionCallback* callback); | |
| 70 virtual int DoomAllEntries(CompletionCallback* callback); | |
| 71 virtual int DoomEntriesBetween(const base::Time initial_time, | |
| 72 const base::Time end_time, | |
| 73 CompletionCallback* callback); | |
| 74 virtual int DoomEntriesSince(const base::Time initial_time, | |
| 75 CompletionCallback* callback); | |
| 76 virtual int OpenNextEntry(void** iter, Entry** next_entry, | |
| 77 CompletionCallback* callback); | |
| 78 virtual void EndEnumeration(void** iter); | |
| 79 virtual void GetStats(StatsItems* stats); | |
| 80 | |
| 81 // Performs the actual initialization and final cleanup on destruction. | 63 // Performs the actual initialization and final cleanup on destruction. |
| 82 int SyncInit(); | 64 int SyncInit(); |
| 83 void CleanupCache(); | 65 void CleanupCache(); |
| 84 | 66 |
| 85 // Same bahavior as OpenNextEntry but walks the list from back to front. | 67 // Same bahavior as OpenNextEntry but walks the list from back to front. |
| 86 int OpenPrevEntry(void** iter, Entry** prev_entry, | 68 int OpenPrevEntry(void** iter, Entry** prev_entry, |
| 87 CompletionCallback* callback); | 69 CompletionCallback* callback); |
| 88 | 70 |
| 89 // Synchronous implementation of the asynchronous interface. | 71 // Synchronous implementation of the asynchronous interface. |
| 90 int SyncOpenEntry(const std::string& key, Entry** entry); | 72 int SyncOpenEntry(const std::string& key, Entry** entry); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 // deleted after it runs. | 237 // deleted after it runs. |
| 256 int RunTaskForTest(Task* task, CompletionCallback* callback); | 238 int RunTaskForTest(Task* task, CompletionCallback* callback); |
| 257 | 239 |
| 258 // Starts or stops throttling requests. | 240 // Starts or stops throttling requests. |
| 259 void ThrottleRequestsForTest(bool throttle); | 241 void ThrottleRequestsForTest(bool throttle); |
| 260 | 242 |
| 261 // Peforms a simple self-check, and returns the number of dirty items | 243 // Peforms a simple self-check, and returns the number of dirty items |
| 262 // or an error code (negative value). | 244 // or an error code (negative value). |
| 263 int SelfCheck(); | 245 int SelfCheck(); |
| 264 | 246 |
| 247 // Backend interface. | |
|
rvargas (doing something else)
2011/01/08 00:25:57
Sorry to differ, but I *really* prefer the current
| |
| 248 virtual int32 GetEntryCount() const; | |
| 249 virtual int OpenEntry(const std::string& key, Entry** entry, | |
| 250 CompletionCallback* callback); | |
| 251 virtual int CreateEntry(const std::string& key, Entry** entry, | |
| 252 CompletionCallback* callback); | |
| 253 virtual int DoomEntry(const std::string& key, CompletionCallback* callback); | |
| 254 virtual int DoomAllEntries(CompletionCallback* callback); | |
| 255 virtual int DoomEntriesBetween(const base::Time initial_time, | |
| 256 const base::Time end_time, | |
| 257 CompletionCallback* callback); | |
| 258 virtual int DoomEntriesSince(const base::Time initial_time, | |
| 259 CompletionCallback* callback); | |
| 260 virtual int OpenNextEntry(void** iter, Entry** next_entry, | |
| 261 CompletionCallback* callback); | |
| 262 virtual void EndEnumeration(void** iter); | |
| 263 virtual void GetStats(StatsItems* stats); | |
| 264 | |
| 265 private: | 265 private: |
| 266 typedef base::hash_map<CacheAddr, EntryImpl*> EntriesMap; | 266 typedef base::hash_map<CacheAddr, EntryImpl*> EntriesMap; |
| 267 | 267 |
| 268 // Creates a new backing file for the cache index. | 268 // Creates a new backing file for the cache index. |
| 269 bool CreateBackingStore(disk_cache::File* file); | 269 bool CreateBackingStore(disk_cache::File* file); |
| 270 bool InitBackingStore(bool* file_created); | 270 bool InitBackingStore(bool* file_created); |
| 271 void AdjustMaxCacheSize(int table_len); | 271 void AdjustMaxCacheSize(int table_len); |
| 272 | 272 |
| 273 // Deletes the cache and starts again. | 273 // Deletes the cache and starts again. |
| 274 void RestartCache(bool failure); | 274 void RestartCache(bool failure); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 | 374 |
| 375 DISALLOW_COPY_AND_ASSIGN(BackendImpl); | 375 DISALLOW_COPY_AND_ASSIGN(BackendImpl); |
| 376 }; | 376 }; |
| 377 | 377 |
| 378 // Returns the prefered max cache size given the available disk space. | 378 // Returns the prefered max cache size given the available disk space. |
| 379 int PreferedCacheSize(int64 available); | 379 int PreferedCacheSize(int64 available); |
| 380 | 380 |
| 381 } // namespace disk_cache | 381 } // namespace disk_cache |
| 382 | 382 |
| 383 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_ | 383 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_ |
| OLD | NEW |