Chromium Code Reviews| 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 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_FILE_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_FILE_H_ |
| 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_FILE_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_FILE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 // Returns a scoped_ptr for a newly allocated Pickle containing the serialized | 61 // Returns a scoped_ptr for a newly allocated Pickle containing the serialized |
| 62 // data to be written to a file. | 62 // data to be written to a file. |
| 63 static scoped_ptr<Pickle> Serialize( | 63 static scoped_ptr<Pickle> Serialize( |
| 64 const SimpleIndexFile::IndexMetadata& index_metadata, | 64 const SimpleIndexFile::IndexMetadata& index_metadata, |
| 65 const SimpleIndex::EntrySet& entries); | 65 const SimpleIndex::EntrySet& entries); |
| 66 | 66 |
| 67 // Write the serialized data from |pickle| into the index file. | 67 // Write the serialized data from |pickle| into the index file. |
| 68 static void WriteToDisk(const base::FilePath& index_filename, | 68 static void WriteToDisk(const base::FilePath& index_filename, |
| 69 const Pickle& pickle); | 69 const Pickle& pickle); |
| 70 | 70 |
| 71 // Using mtime of the file and the path, it detects if the index file is | |
| 72 // stale. | |
| 73 static bool IndexFileIsStale(const base::FilePath& index_filename); | |
|
gavinp
2013/04/19 09:30:17
IsIndexFileStale is a better name. I did a double
felipeg
2013/04/19 10:14:05
that comes from my bad english mixed up with frenc
| |
| 74 | |
| 71 private: | 75 private: |
| 72 FRIEND_TEST_ALL_PREFIXES(SimpleIndexFileTest, Serialize); | 76 FRIEND_TEST_ALL_PREFIXES(SimpleIndexFileTest, Serialize); |
| 73 | 77 |
| 74 // Deserialize() is separate from LoadFromDisk() for easier testing. | 78 // Deserialize() is separate from LoadFromDisk() for easier testing. |
| 75 static scoped_ptr<SimpleIndex::EntrySet> Deserialize(const char* data, | 79 static scoped_ptr<SimpleIndex::EntrySet> Deserialize(const char* data, |
| 76 int data_len); | 80 int data_len); |
| 77 | 81 |
| 78 struct PickleHeader : public Pickle::Header { | 82 struct PickleHeader : public Pickle::Header { |
| 79 uint32 crc; | 83 uint32 crc; |
| 80 }; | 84 }; |
| 81 | 85 |
| 82 DISALLOW_COPY_AND_ASSIGN(SimpleIndexFile); | 86 DISALLOW_COPY_AND_ASSIGN(SimpleIndexFile); |
| 83 }; | 87 }; |
| 84 | 88 |
| 85 | 89 |
| 86 } // namespace disk_cache | 90 } // namespace disk_cache |
| 87 | 91 |
| 88 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_FILE_H_ | 92 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_FILE_H_ |
| OLD | NEW |