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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
14 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/memory/scoped_ptr.h" | |
19 #include "base/pickle.h" | 19 #include "base/pickle.h" |
20 #include "net/base/cache_type.h" | 20 #include "net/base/cache_type.h" |
21 #include "net/base/net_export.h" | 21 #include "net/base/net_export.h" |
22 #include "net/disk_cache/simple/simple_index.h" | 22 #include "net/disk_cache/simple/simple_index.h" |
23 | 23 |
24 namespace base { | 24 namespace base { |
25 class SingleThreadTaskRunner; | 25 class SingleThreadTaskRunner; |
26 class TaskRunner; | 26 class TaskRunner; |
27 } | 27 } |
28 | 28 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // Load the index file from disk returning an EntrySet. | 115 // Load the index file from disk returning an EntrySet. |
116 static void SyncLoadFromDisk(const base::FilePath& index_filename, | 116 static void SyncLoadFromDisk(const base::FilePath& index_filename, |
117 base::Time* out_last_cache_seen_by_index, | 117 base::Time* out_last_cache_seen_by_index, |
118 SimpleIndexLoadResult* out_result); | 118 SimpleIndexLoadResult* out_result); |
119 | 119 |
120 // Returns a scoped_ptr for a newly allocated base::Pickle containing the | 120 // Returns a scoped_ptr for a newly allocated base::Pickle containing the |
121 // serialized | 121 // serialized |
122 // data to be written to a file. Note: the pickle is not in a consistent state | 122 // data to be written to a file. Note: the pickle is not in a consistent state |
123 // immediately after calling this menthod, one needs to call | 123 // immediately after calling this menthod, one needs to call |
124 // SerializeFinalData to make it ready to write to a file. | 124 // SerializeFinalData to make it ready to write to a file. |
125 static scoped_ptr<base::Pickle> Serialize( | 125 static std::unique_ptr<base::Pickle> Serialize( |
126 const SimpleIndexFile::IndexMetadata& index_metadata, | 126 const SimpleIndexFile::IndexMetadata& index_metadata, |
127 const SimpleIndex::EntrySet& entries); | 127 const SimpleIndex::EntrySet& entries); |
128 | 128 |
129 // Appends cache modification time data to the serialized format. This is | 129 // Appends cache modification time data to the serialized format. This is |
130 // performed on a thread accessing the disk. It is not combined with the main | 130 // performed on a thread accessing the disk. It is not combined with the main |
131 // serialization path to avoid extra thread hops or copying the pickle to the | 131 // serialization path to avoid extra thread hops or copying the pickle to the |
132 // worker thread. | 132 // worker thread. |
133 static bool SerializeFinalData(base::Time cache_modified, | 133 static bool SerializeFinalData(base::Time cache_modified, |
134 base::Pickle* pickle); | 134 base::Pickle* pickle); |
135 | 135 |
(...skipping 10 matching lines...) Expand all Loading... |
146 // succeeded. | 146 // succeeded. |
147 static bool TraverseCacheDirectory( | 147 static bool TraverseCacheDirectory( |
148 const base::FilePath& cache_path, | 148 const base::FilePath& cache_path, |
149 const EntryFileCallback& entry_file_callback); | 149 const EntryFileCallback& entry_file_callback); |
150 | 150 |
151 // Writes the index file to disk atomically. | 151 // Writes the index file to disk atomically. |
152 static void SyncWriteToDisk(net::CacheType cache_type, | 152 static void SyncWriteToDisk(net::CacheType cache_type, |
153 const base::FilePath& cache_directory, | 153 const base::FilePath& cache_directory, |
154 const base::FilePath& index_filename, | 154 const base::FilePath& index_filename, |
155 const base::FilePath& temp_index_filename, | 155 const base::FilePath& temp_index_filename, |
156 scoped_ptr<base::Pickle> pickle, | 156 std::unique_ptr<base::Pickle> pickle, |
157 const base::TimeTicks& start_time, | 157 const base::TimeTicks& start_time, |
158 bool app_on_background); | 158 bool app_on_background); |
159 | 159 |
160 // Scan the index directory for entries, returning an EntrySet of all entries | 160 // Scan the index directory for entries, returning an EntrySet of all entries |
161 // found. | 161 // found. |
162 static void SyncRestoreFromDisk(const base::FilePath& cache_directory, | 162 static void SyncRestoreFromDisk(const base::FilePath& cache_directory, |
163 const base::FilePath& index_file_path, | 163 const base::FilePath& index_file_path, |
164 SimpleIndexLoadResult* out_result); | 164 SimpleIndexLoadResult* out_result); |
165 | 165 |
166 // Determines if an index file is stale relative to the time of last | 166 // Determines if an index file is stale relative to the time of last |
(...skipping 18 matching lines...) Expand all Loading... |
185 static const char kIndexFileName[]; | 185 static const char kIndexFileName[]; |
186 static const char kTempIndexFileName[]; | 186 static const char kTempIndexFileName[]; |
187 | 187 |
188 DISALLOW_COPY_AND_ASSIGN(SimpleIndexFile); | 188 DISALLOW_COPY_AND_ASSIGN(SimpleIndexFile); |
189 }; | 189 }; |
190 | 190 |
191 | 191 |
192 } // namespace disk_cache | 192 } // namespace disk_cache |
193 | 193 |
194 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_FILE_H_ | 194 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_FILE_H_ |
OLD | NEW |