Index: net/disk_cache/simple/simple_index.h |
diff --git a/net/disk_cache/simple/simple_index.h b/net/disk_cache/simple/simple_index.h |
index f07476d2409d41988bbeba0dd91b1bc27f540ec6..154bdde6d4e5d0c7588aa7975eb94b0666ed7589 100644 |
--- a/net/disk_cache/simple/simple_index.h |
+++ b/net/disk_cache/simple/simple_index.h |
@@ -29,12 +29,12 @@ class SimpleIndex |
public: |
SimpleIndex( |
const scoped_refptr<base::TaskRunner>& cache_thread, |
+ const scoped_refptr<base::TaskRunner>& io_thread, |
const base::FilePath& path); |
virtual ~SimpleIndex(); |
- // Should be called on CacheThread. |
- bool Initialize(); |
+ void Initialize(); |
void Insert(const std::string& key); |
void Remove(const std::string& key); |
@@ -45,7 +45,7 @@ class SimpleIndex |
// iff the entry exist in the index. |
bool UseIfExists(const std::string& key); |
- void Cleanup(); |
+ void WriteToDisk(); |
bool UpdateEntrySize(const std::string& key, uint64 entry_size); |
@@ -56,10 +56,18 @@ class SimpleIndex |
// EntryMetadata itself. |
typedef base::hash_map<std::string, SimpleIndexFile::EntryMetadata> EntrySet; |
- void InsertInternal(const SimpleIndexFile::EntryMetadata& entry_metadata); |
+ static void InsertInternal( |
+ EntrySet* entry_set, |
+ const SimpleIndexFile::EntryMetadata& entry_metadata); |
+ |
+ // Load index file from disk, if file is corrupted it calls RestoreFromDisk(). |
+ void LoadFromDisk(); |
// Enumerates all entries' files on disk and regenerates the index. |
- bool RestoreFromDisk(); |
+ void RestoreFromDisk(); |
+ |
+ // Must run on IO Thread. |
gavinp
2013/04/10 10:51:56
Can you add a base::ThreadChecker to this class?
felipeg
2013/04/10 14:21:45
Done.
|
+ void MergeInitializingSet(); |
// |out_buffer| needs to be pre-allocated. The serialized index is stored in |
// |out_buffer|. |
@@ -77,13 +85,22 @@ class SimpleIndex |
EntrySet entries_set_; |
uint64 cache_size_; // Total cache storage size in bytes. |
+ // These sets are only used during initialization phase. |
+ // They are merged back in the entries_set_ once it finishes. |
+ EntrySet initializing_set_; |
+ // This stores all the hash_key of entries that are removed during |
+ // initialization. |
+ base::hash_set<std::string> removals_set_; |
+ bool initialized_; |
+ |
base::FilePath index_filename_; |
base::PlatformFile index_file_; |
// We keep the thread from where Initialize() method has been called so that |
- // we run the Cleanup method in the same thread. Usually that should be the |
- // CacheThread. |
+ // we run the WriteToDisk method in the same thread. Usually that should be |
+ // the Cache Thread. |
gavinp
2013/04/10 10:51:56
Is this comment right anymore? I think these come
felipeg
2013/04/10 14:21:45
Done.
|
scoped_refptr<base::TaskRunner> cache_thread_; |
+ scoped_refptr<base::TaskRunner> io_thread_; |
}; |
} // namespace disk_cache |