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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 net::NetLog* net_log); | 59 net::NetLog* net_log); |
60 virtual ~BackendImpl(); | 60 virtual ~BackendImpl(); |
61 | 61 |
62 // Performs general initialization for this current instance of the cache. | 62 // Performs general initialization for this current instance of the cache. |
63 int Init(const CompletionCallback& callback); | 63 int Init(const CompletionCallback& callback); |
64 | 64 |
65 // Performs the actual initialization and final cleanup on destruction. | 65 // Performs the actual initialization and final cleanup on destruction. |
66 int SyncInit(); | 66 int SyncInit(); |
67 void CleanupCache(); | 67 void CleanupCache(); |
68 | 68 |
69 // Same behavior as OpenNextEntry but walks the list from back to front. | |
70 int OpenPrevEntry(void** iter, Entry** prev_entry, | |
71 const CompletionCallback& callback); | |
72 | |
73 // Synchronous implementation of the asynchronous interface. | 69 // Synchronous implementation of the asynchronous interface. |
74 int SyncOpenEntry(const std::string& key, Entry** entry); | 70 int SyncOpenEntry(const std::string& key, Entry** entry); |
75 int SyncCreateEntry(const std::string& key, Entry** entry); | 71 int SyncCreateEntry(const std::string& key, Entry** entry); |
76 int SyncDoomEntry(const std::string& key); | 72 int SyncDoomEntry(const std::string& key); |
77 int SyncDoomAllEntries(); | 73 int SyncDoomAllEntries(); |
78 int SyncDoomEntriesBetween(base::Time initial_time, | 74 int SyncDoomEntriesBetween(base::Time initial_time, |
79 base::Time end_time); | 75 base::Time end_time); |
80 int SyncDoomEntriesSince(base::Time initial_time); | 76 int SyncDoomEntriesSince(base::Time initial_time); |
81 int SyncOpenNextEntry(void** iter, Entry** next_entry); | 77 int SyncOpenNextEntry(void** iter, Entry** next_entry); |
82 int SyncOpenPrevEntry(void** iter, Entry** prev_entry); | |
83 void SyncEndEnumeration(void* iter); | 78 void SyncEndEnumeration(void* iter); |
84 void SyncOnExternalCacheHit(const std::string& key); | 79 void SyncOnExternalCacheHit(const std::string& key); |
85 | 80 |
86 // Open or create an entry for the given |key| or |iter|. | 81 // Open or create an entry for the given |key| or |iter|. |
87 EntryImpl* OpenEntryImpl(const std::string& key); | 82 EntryImpl* OpenEntryImpl(const std::string& key); |
88 EntryImpl* CreateEntryImpl(const std::string& key); | 83 EntryImpl* CreateEntryImpl(const std::string& key); |
89 EntryImpl* OpenNextEntryImpl(void** iter); | 84 EntryImpl* OpenNextEntryImpl(void** iter); |
90 EntryImpl* OpenPrevEntryImpl(void** iter); | |
91 | 85 |
92 // 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. |
93 bool SetMaxSize(int max_bytes); | 87 bool SetMaxSize(int max_bytes); |
94 | 88 |
95 // Sets the cache type for this backend. | 89 // Sets the cache type for this backend. |
96 void SetType(net::CacheType type); | 90 void SetType(net::CacheType type); |
97 | 91 |
98 // Returns the full name for an external storage file. | 92 // Returns the full name for an external storage file. |
99 base::FilePath GetFileName(Addr address) const; | 93 base::FilePath GetFileName(Addr address) const; |
100 | 94 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // Returns a given entry from the cache. The entry to match is determined by | 301 // Returns a given entry from the cache. The entry to match is determined by |
308 // key and hash, and the returned entry may be the matched one or it's parent | 302 // key and hash, and the returned entry may be the matched one or it's parent |
309 // on the list of entries with the same hash (or bucket). To look for a parent | 303 // on the list of entries with the same hash (or bucket). To look for a parent |
310 // of a given entry, |entry_addr| should be grabbed from that entry, so that | 304 // of a given entry, |entry_addr| should be grabbed from that entry, so that |
311 // if it doesn't match the entry on the index, we know that it was replaced | 305 // if it doesn't match the entry on the index, we know that it was replaced |
312 // with a new entry; in this case |*match_error| will be set to true and the | 306 // with a new entry; in this case |*match_error| will be set to true and the |
313 // return value will be NULL. | 307 // return value will be NULL. |
314 EntryImpl* MatchEntry(const std::string& key, uint32 hash, bool find_parent, | 308 EntryImpl* MatchEntry(const std::string& key, uint32 hash, bool find_parent, |
315 Addr entry_addr, bool* match_error); | 309 Addr entry_addr, bool* match_error); |
316 | 310 |
317 // Opens the next or previous entry on a cache iteration. | |
318 EntryImpl* OpenFollowingEntry(bool forward, void** iter); | |
319 | |
320 // Opens the next or previous entry on a single list. If successful, | 311 // Opens the next or previous entry on a single list. If successful, |
321 // |from_entry| will be updated to point to the new entry, otherwise it will | 312 // |from_entry| will be updated to point to the new entry, otherwise it will |
322 // be set to NULL; in other words, it is used as an explicit iterator. | 313 // be set to NULL; in other words, it is used as an explicit iterator. |
323 bool OpenFollowingEntryFromList(bool forward, Rankings::List list, | 314 bool OpenFollowingEntryFromList(Rankings::List list, |
324 CacheRankingsBlock** from_entry, | 315 CacheRankingsBlock** from_entry, |
325 EntryImpl** next_entry); | 316 EntryImpl** next_entry); |
326 | 317 |
327 // Returns the entry that is pointed by |next|, from the given |list|. | 318 // Returns the entry that is pointed by |next|, from the given |list|. |
328 EntryImpl* GetEnumeratedEntry(CacheRankingsBlock* next, Rankings::List list); | 319 EntryImpl* GetEnumeratedEntry(CacheRankingsBlock* next, Rankings::List list); |
329 | 320 |
330 // Re-opens an entry that was previously deleted. | 321 // Re-opens an entry that was previously deleted. |
331 EntryImpl* ResurrectEntry(EntryImpl* deleted_entry); | 322 EntryImpl* ResurrectEntry(EntryImpl* deleted_entry); |
332 | 323 |
333 void DestroyInvalidEntry(EntryImpl* entry); | 324 void DestroyInvalidEntry(EntryImpl* entry); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 base::WaitableEvent done_; // Signals the end of background work. | 390 base::WaitableEvent done_; // Signals the end of background work. |
400 scoped_refptr<TraceObject> trace_object_; // Initializes internal tracing. | 391 scoped_refptr<TraceObject> trace_object_; // Initializes internal tracing. |
401 base::WeakPtrFactory<BackendImpl> ptr_factory_; | 392 base::WeakPtrFactory<BackendImpl> ptr_factory_; |
402 | 393 |
403 DISALLOW_COPY_AND_ASSIGN(BackendImpl); | 394 DISALLOW_COPY_AND_ASSIGN(BackendImpl); |
404 }; | 395 }; |
405 | 396 |
406 } // namespace disk_cache | 397 } // namespace disk_cache |
407 | 398 |
408 #endif // NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ | 399 #endif // NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ |
OLD | NEW |