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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 const base::FilePath& index_filename, | 188 const base::FilePath& index_filename, |
189 const base::FilePath& temp_index_filename, | 189 const base::FilePath& temp_index_filename, |
190 scoped_ptr<Pickle> pickle, | 190 scoped_ptr<Pickle> pickle, |
191 const base::TimeTicks& start_time, | 191 const base::TimeTicks& start_time, |
192 bool app_on_background) { | 192 bool app_on_background) { |
193 // There is a chance that the index containing all the necessary data about | 193 // There is a chance that the index containing all the necessary data about |
194 // newly created entries will appear to be stale. This can happen if on-disk | 194 // newly created entries will appear to be stale. This can happen if on-disk |
195 // part of a Create operation does not fit into the time budget for the index | 195 // part of a Create operation does not fit into the time budget for the index |
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; | |
199 base::Time cache_dir_mtime; | 198 base::Time cache_dir_mtime; |
200 if (!simple_util::GetMTime(cache_directory, &cache_dir_mtime)) { | 199 if (!simple_util::GetMTime(cache_directory, &cache_dir_mtime)) { |
201 LOG(ERROR) << "Could obtain information about cache age"; | 200 LOG(ERROR) << "Could obtain information about cache age"; |
202 return; | 201 return; |
203 } | 202 } |
204 SerializeFinalData(cache_dir_mtime, pickle.get()); | 203 SerializeFinalData(cache_dir_mtime, pickle.get()); |
205 if (!WritePickleFile(pickle.get(), temp_index_filename)) { | 204 if (!WritePickleFile(pickle.get(), temp_index_filename)) { |
206 if (!base::CreateDirectory(temp_index_filename.DirName())) { | 205 if (!base::CreateDirectory(temp_index_filename.DirName())) { |
207 LOG(ERROR) << "Could not create a directory to hold the index file"; | 206 LOG(ERROR) << "Could not create a directory to hold the index file"; |
208 return; | 207 return; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 bool SimpleIndexFile::LegacyIsIndexFileStale( | 454 bool SimpleIndexFile::LegacyIsIndexFileStale( |
456 base::Time cache_last_modified, | 455 base::Time cache_last_modified, |
457 const base::FilePath& index_file_path) { | 456 const base::FilePath& index_file_path) { |
458 base::Time index_mtime; | 457 base::Time index_mtime; |
459 if (!simple_util::GetMTime(index_file_path, &index_mtime)) | 458 if (!simple_util::GetMTime(index_file_path, &index_mtime)) |
460 return true; | 459 return true; |
461 return index_mtime < cache_last_modified; | 460 return index_mtime < cache_last_modified; |
462 } | 461 } |
463 | 462 |
464 } // namespace disk_cache | 463 } // namespace disk_cache |
OLD | NEW |