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 #include "net/disk_cache/simple/simple_index_file.h" | 5 #include "net/disk_cache/simple/simple_index_file.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/hash.h" | 8 #include "base/hash.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 LOG(ERROR) << "Could not write Simple Cache index to temporary file: " | 154 LOG(ERROR) << "Could not write Simple Cache index to temporary file: " |
155 << temp_filename.value(); | 155 << temp_filename.value(); |
156 file_util::Delete(temp_filename, /* recursive = */ false); | 156 file_util::Delete(temp_filename, /* recursive = */ false); |
157 return; | 157 return; |
158 } | 158 } |
159 // Swap temp and index_file. | 159 // Swap temp and index_file. |
160 bool result = file_util::ReplaceFile(temp_filename, index_filename); | 160 bool result = file_util::ReplaceFile(temp_filename, index_filename); |
161 DCHECK(result); | 161 DCHECK(result); |
162 } | 162 } |
163 | 163 |
164 // static | |
165 bool SimpleIndexFile::IndexFileIsStale(const base::FilePath& index_filename) { | |
166 base::PlatformFileInfo dir_info; | |
167 base::PlatformFileInfo index_info; | |
168 if (!file_util::GetFileInfo(index_filename.DirName(), &dir_info)) | |
169 return false; | |
170 DCHECK(dir_info.is_directory); | |
171 if (!file_util::GetFileInfo(index_filename, &index_info)) | |
172 return false; | |
173 | |
174 // Index file last_modified must be equal to the directory last_modified since | |
175 // the last operation we do is ReplaceFile in the | |
176 // SimpleIndexFile::WriteToDisk(). | |
177 // If not true, we need to restore the index. | |
178 return index_info.last_modified != dir_info.last_modified; | |
gavinp
2013/04/19 09:30:17
I think index_info.last_modified >= dir_info.last_
felipeg
2013/04/19 10:14:05
Done.
| |
179 } | |
180 | |
164 } // namespace disk_cache | 181 } // namespace disk_cache |
OLD | NEW |