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 12 matching lines...) Expand all Loading... |
23 #include "third_party/zlib/zlib.h" | 23 #include "third_party/zlib/zlib.h" |
24 | 24 |
25 namespace disk_cache { | 25 namespace disk_cache { |
26 namespace { | 26 namespace { |
27 | 27 |
28 const int kEntryFilesHashLength = 16; | 28 const int kEntryFilesHashLength = 16; |
29 const int kEntryFilesSuffixLength = 2; | 29 const int kEntryFilesSuffixLength = 2; |
30 | 30 |
31 const uint64 kMaxEntiresInIndex = 100000000; | 31 const uint64 kMaxEntiresInIndex = 100000000; |
32 | 32 |
33 const char kIndexFileName[] = "the-real-index"; | |
34 const char kTempIndexFileName[] = "temp-index"; | |
35 | |
36 uint32 CalculatePickleCRC(const Pickle& pickle) { | 33 uint32 CalculatePickleCRC(const Pickle& pickle) { |
37 return crc32(crc32(0, Z_NULL, 0), | 34 return crc32(crc32(0, Z_NULL, 0), |
38 reinterpret_cast<const Bytef*>(pickle.payload()), | 35 reinterpret_cast<const Bytef*>(pickle.payload()), |
39 pickle.payload_size()); | 36 pickle.payload_size()); |
40 } | 37 } |
41 | 38 |
42 // Used in histograms. Please only add new values at the end. | 39 // Used in histograms. Please only add new values at the end. |
43 enum IndexFileState { | 40 enum IndexFileState { |
44 INDEX_STATE_CORRUPT = 0, | 41 INDEX_STATE_CORRUPT = 0, |
45 INDEX_STATE_STALE = 1, | 42 INDEX_STATE_STALE = 1, |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 bool SimpleIndexFile::LegacyIsIndexFileStale( | 455 bool SimpleIndexFile::LegacyIsIndexFileStale( |
459 base::Time cache_last_modified, | 456 base::Time cache_last_modified, |
460 const base::FilePath& index_file_path) { | 457 const base::FilePath& index_file_path) { |
461 base::Time index_mtime; | 458 base::Time index_mtime; |
462 if (!simple_util::GetMTime(index_file_path, &index_mtime)) | 459 if (!simple_util::GetMTime(index_file_path, &index_mtime)) |
463 return true; | 460 return true; |
464 return index_mtime < cache_last_modified; | 461 return index_mtime < cache_last_modified; |
465 } | 462 } |
466 | 463 |
467 } // namespace disk_cache | 464 } // namespace disk_cache |
OLD | NEW |