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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 *out_cache_last_modified = base::Time::FromInternalValue(cache_last_modified); | 427 *out_cache_last_modified = base::Time::FromInternalValue(cache_last_modified); |
428 | 428 |
429 out_result->did_load = true; | 429 out_result->did_load = true; |
430 } | 430 } |
431 | 431 |
432 // static | 432 // static |
433 void SimpleIndexFile::SyncRestoreFromDisk( | 433 void SimpleIndexFile::SyncRestoreFromDisk( |
434 const base::FilePath& cache_directory, | 434 const base::FilePath& cache_directory, |
435 const base::FilePath& index_file_path, | 435 const base::FilePath& index_file_path, |
436 SimpleIndexLoadResult* out_result) { | 436 SimpleIndexLoadResult* out_result) { |
437 LOG(INFO) << "Simple Cache Index is being restored from disk."; | 437 VLOG(0) << "Simple Cache Index is being restored from disk."; |
438 base::DeleteFile(index_file_path, /* recursive = */ false); | 438 base::DeleteFile(index_file_path, /* recursive = */ false); |
439 out_result->Reset(); | 439 out_result->Reset(); |
440 SimpleIndex::EntrySet* entries = &out_result->entries; | 440 SimpleIndex::EntrySet* entries = &out_result->entries; |
441 | 441 |
442 const bool did_succeed = TraverseCacheDirectory( | 442 const bool did_succeed = TraverseCacheDirectory( |
443 cache_directory, base::Bind(&ProcessEntryFile, entries)); | 443 cache_directory, base::Bind(&ProcessEntryFile, entries)); |
444 if (!did_succeed) { | 444 if (!did_succeed) { |
445 LOG(ERROR) << "Could not reconstruct index from disk"; | 445 LOG(ERROR) << "Could not reconstruct index from disk"; |
446 return; | 446 return; |
447 } | 447 } |
448 out_result->did_load = true; | 448 out_result->did_load = true; |
449 // When we restore from disk we write the merged index file to disk right | 449 // When we restore from disk we write the merged index file to disk right |
450 // away, this might save us from having to restore again next time. | 450 // away, this might save us from having to restore again next time. |
451 out_result->flush_required = true; | 451 out_result->flush_required = true; |
452 } | 452 } |
453 | 453 |
454 // static | 454 // static |
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 |