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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/memory_mapped_file.h" | 10 #include "base/files/memory_mapped_file.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // flush delay. This simple approach will be reconsidered if it does not allow | 196 // flush delay. This simple approach will be reconsidered if it does not allow |
197 // for maintaining freshness. | 197 // for maintaining freshness. |
198 base::PlatformFileInfo cache_dir_info; | 198 base::PlatformFileInfo cache_dir_info; |
199 base::Time cache_dir_mtime; | 199 base::Time cache_dir_mtime; |
200 if (!simple_util::GetMTime(cache_directory, &cache_dir_mtime)) { | 200 if (!simple_util::GetMTime(cache_directory, &cache_dir_mtime)) { |
201 LOG(ERROR) << "Could obtain information about cache age"; | 201 LOG(ERROR) << "Could obtain information about cache age"; |
202 return; | 202 return; |
203 } | 203 } |
204 SerializeFinalData(cache_dir_mtime, pickle.get()); | 204 SerializeFinalData(cache_dir_mtime, pickle.get()); |
205 if (!WritePickleFile(pickle.get(), temp_index_filename)) { | 205 if (!WritePickleFile(pickle.get(), temp_index_filename)) { |
206 if (!file_util::CreateDirectory(temp_index_filename.DirName())) { | 206 if (!base::CreateDirectory(temp_index_filename.DirName())) { |
207 LOG(ERROR) << "Could not create a directory to hold the index file"; | 207 LOG(ERROR) << "Could not create a directory to hold the index file"; |
208 return; | 208 return; |
209 } | 209 } |
210 if (!WritePickleFile(pickle.get(), temp_index_filename)) { | 210 if (!WritePickleFile(pickle.get(), temp_index_filename)) { |
211 LOG(ERROR) << "Failed to write the temporary index file"; | 211 LOG(ERROR) << "Failed to write the temporary index file"; |
212 return; | 212 return; |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 // Atomically rename the temporary index file to become the real one. | 216 // Atomically rename the temporary index file to become the real one. |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 bool SimpleIndexFile::LegacyIsIndexFileStale( | 455 bool SimpleIndexFile::LegacyIsIndexFileStale( |
456 base::Time cache_last_modified, | 456 base::Time cache_last_modified, |
457 const base::FilePath& index_file_path) { | 457 const base::FilePath& index_file_path) { |
458 base::Time index_mtime; | 458 base::Time index_mtime; |
459 if (!simple_util::GetMTime(index_file_path, &index_mtime)) | 459 if (!simple_util::GetMTime(index_file_path, &index_mtime)) |
460 return true; | 460 return true; |
461 return index_mtime < cache_last_modified; | 461 return index_mtime < cache_last_modified; |
462 } | 462 } |
463 | 463 |
464 } // namespace disk_cache | 464 } // namespace disk_cache |
OLD | NEW |