| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ |
| 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 static void InsertInEntrySet(const EntryMetadata& entry_metadata, | 104 static void InsertInEntrySet(const EntryMetadata& entry_metadata, |
| 105 EntrySet* entry_set); | 105 EntrySet* entry_set); |
| 106 | 106 |
| 107 private: | 107 private: |
| 108 typedef base::Callback<void(scoped_ptr<EntrySet>, bool force_index_flush)> | 108 typedef base::Callback<void(scoped_ptr<EntrySet>, bool force_index_flush)> |
| 109 IndexCompletionCallback; | 109 IndexCompletionCallback; |
| 110 | 110 |
| 111 void PostponeWritingToDisk(); | 111 void PostponeWritingToDisk(); |
| 112 | 112 |
| 113 // Using the mtime of the file and its mtime, detects if the index file is |
| 114 // stale. |
| 115 static bool IsIndexFileStale(const base::FilePath& index_filename); |
| 116 |
| 113 static void LoadFromDisk( | 117 static void LoadFromDisk( |
| 114 const base::FilePath& index_filename, | 118 const base::FilePath& index_filename, |
| 115 base::SingleThreadTaskRunner* io_thread, | 119 base::SingleThreadTaskRunner* io_thread, |
| 116 const IndexCompletionCallback& completion_callback); | 120 const IndexCompletionCallback& completion_callback); |
| 117 | 121 |
| 118 // Enumerates all entries' files on disk and regenerates the index. | 122 // Enumerates all entries' files on disk and regenerates the index. |
| 119 static scoped_ptr<SimpleIndex::EntrySet> RestoreFromDisk( | 123 static scoped_ptr<SimpleIndex::EntrySet> RestoreFromDisk( |
| 120 const base::FilePath& index_filename); | 124 const base::FilePath& index_filename); |
| 121 | 125 |
| 122 static void WriteToDiskInternal(const base::FilePath& index_filename, | 126 static void WriteToDiskInternal(const base::FilePath& index_filename, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 146 // Timestamp of the last time we wrote the index to disk. | 150 // Timestamp of the last time we wrote the index to disk. |
| 147 // PostponeWritingToDisk() may give up postponing and allow the write if it | 151 // PostponeWritingToDisk() may give up postponing and allow the write if it |
| 148 // has been a while since last time we wrote. | 152 // has been a while since last time we wrote. |
| 149 base::Time last_write_to_disk_; | 153 base::Time last_write_to_disk_; |
| 150 base::OneShotTimer<SimpleIndex> write_to_disk_timer_; | 154 base::OneShotTimer<SimpleIndex> write_to_disk_timer_; |
| 151 }; | 155 }; |
| 152 | 156 |
| 153 } // namespace disk_cache | 157 } // namespace disk_cache |
| 154 | 158 |
| 155 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ | 159 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ |
| OLD | NEW |