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_FILE_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_FILE_H_ |
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_FILE_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_FILE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // Write the specified set of entries to disk. | 88 // Write the specified set of entries to disk. |
89 virtual void WriteToDisk(const SimpleIndex::EntrySet& entry_set, | 89 virtual void WriteToDisk(const SimpleIndex::EntrySet& entry_set, |
90 uint64 cache_size, | 90 uint64 cache_size, |
91 const base::TimeTicks& start, | 91 const base::TimeTicks& start, |
92 bool app_on_background); | 92 bool app_on_background); |
93 | 93 |
94 private: | 94 private: |
95 friend class WrappedSimpleIndexFile; | 95 friend class WrappedSimpleIndexFile; |
96 | 96 |
97 // Used for cache directory traversal. | 97 // Used for cache directory traversal. |
98 typedef base::Callback<void (const base::FilePath&)> EntryFileCallback; | 98 typedef base::Callback<void(const base::FilePath&)> EntryFileCallback; |
99 | 99 |
100 // When loading the entries from disk, add this many extra hash buckets to | 100 // When loading the entries from disk, add this many extra hash buckets to |
101 // prevent reallocation on the IO thread when merging in new live entries. | 101 // prevent reallocation on the IO thread when merging in new live entries. |
102 static const int kExtraSizeForMerge = 512; | 102 static const int kExtraSizeForMerge = 512; |
103 | 103 |
104 // Synchronous (IO performing) implementation of LoadIndexEntries. | 104 // Synchronous (IO performing) implementation of LoadIndexEntries. |
105 static void SyncLoadIndexEntries(net::CacheType cache_type, | 105 static void SyncLoadIndexEntries(net::CacheType cache_type, |
106 base::Time cache_last_modified, | 106 base::Time cache_last_modified, |
107 const base::FilePath& cache_directory, | 107 const base::FilePath& cache_directory, |
108 const base::FilePath& index_file_path, | 108 const base::FilePath& index_file_path, |
(...skipping 13 matching lines...) Expand all Loading... |
122 const SimpleIndex::EntrySet& entries); | 122 const SimpleIndex::EntrySet& entries); |
123 | 123 |
124 // Appends cache modification time data to the serialized format. This is | 124 // Appends cache modification time data to the serialized format. This is |
125 // performed on a thread accessing the disk. It is not combined with the main | 125 // performed on a thread accessing the disk. It is not combined with the main |
126 // serialization path to avoid extra thread hops or copying the pickle to the | 126 // serialization path to avoid extra thread hops or copying the pickle to the |
127 // worker thread. | 127 // worker thread. |
128 static bool SerializeFinalData(base::Time cache_modified, Pickle* pickle); | 128 static bool SerializeFinalData(base::Time cache_modified, Pickle* pickle); |
129 | 129 |
130 // Given the contents of an index file |data| of length |data_len|, returns | 130 // Given the contents of an index file |data| of length |data_len|, returns |
131 // the corresponding EntrySet. Returns NULL on error. | 131 // the corresponding EntrySet. Returns NULL on error. |
132 static void Deserialize(const char* data, int data_len, | 132 static void Deserialize(const char* data, |
| 133 int data_len, |
133 base::Time* out_cache_last_modified, | 134 base::Time* out_cache_last_modified, |
134 SimpleIndexLoadResult* out_result); | 135 SimpleIndexLoadResult* out_result); |
135 | 136 |
136 // Implemented either in simple_index_file_posix.cc or | 137 // Implemented either in simple_index_file_posix.cc or |
137 // simple_index_file_win.cc. base::FileEnumerator turned out to be very | 138 // simple_index_file_win.cc. base::FileEnumerator turned out to be very |
138 // expensive in terms of memory usage therefore it's used only on non-POSIX | 139 // expensive in terms of memory usage therefore it's used only on non-POSIX |
139 // environments for convenience (for now). Returns whether the traversal | 140 // environments for convenience (for now). Returns whether the traversal |
140 // succeeded. | 141 // succeeded. |
141 static bool TraverseCacheDirectory( | 142 static bool TraverseCacheDirectory( |
142 const base::FilePath& cache_path, | 143 const base::FilePath& cache_path, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 const base::FilePath index_file_; | 176 const base::FilePath index_file_; |
176 const base::FilePath temp_index_file_; | 177 const base::FilePath temp_index_file_; |
177 | 178 |
178 static const char kIndexDirectory[]; | 179 static const char kIndexDirectory[]; |
179 static const char kIndexFileName[]; | 180 static const char kIndexFileName[]; |
180 static const char kTempIndexFileName[]; | 181 static const char kTempIndexFileName[]; |
181 | 182 |
182 DISALLOW_COPY_AND_ASSIGN(SimpleIndexFile); | 183 DISALLOW_COPY_AND_ASSIGN(SimpleIndexFile); |
183 }; | 184 }; |
184 | 185 |
185 | |
186 } // namespace disk_cache | 186 } // namespace disk_cache |
187 | 187 |
188 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_FILE_H_ | 188 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_FILE_H_ |
OLD | NEW |