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_DISK_FORMAT_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_DISK_FORMAT_H_ |
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_DISK_FORMAT_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_DISK_FORMAT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // } | 49 // } |
50 // ------------------------- | 50 // ------------------------- |
51 // struct Footer; | 51 // struct Footer; |
52 // ------------------------- | 52 // ------------------------- |
53 namespace SimpleIndexFile { | 53 namespace SimpleIndexFile { |
54 // Simple Index File metadata is defined here. | 54 // Simple Index File metadata is defined here. |
55 struct Header { | 55 struct Header { |
56 uint64 initial_magic_number; | 56 uint64 initial_magic_number; |
57 uint32 version; | 57 uint32 version; |
58 uint64 number_of_entries; | 58 uint64 number_of_entries; |
| 59 uint64 cache_size; // Total cache storage size in bytes. |
59 }; | 60 }; |
60 | 61 |
61 // We must keep this struct a POD. | 62 // We must keep this struct a POD. |
62 struct EntryMetadata { | 63 struct EntryMetadata { |
63 EntryMetadata(); | 64 EntryMetadata(); |
64 EntryMetadata(const std::string& hash_key_p, base::Time last_used_time_p); | 65 EntryMetadata(const std::string& hash_key_p, |
| 66 base::Time last_used_time_p, |
| 67 uint64 entry_size_p); |
65 | 68 |
66 base::Time GetLastUsedTime() const; | 69 base::Time GetLastUsedTime() const; |
67 std::string GetHashKey() const; | 70 std::string GetHashKey() const; |
68 void SetLastUsedTime(const base::Time& last_used_time_p); | 71 void SetLastUsedTime(const base::Time& last_used_time_p); |
69 | 72 |
70 static void Serialize(const EntryMetadata& in_entry_metadata, | 73 static void Serialize(const EntryMetadata& in_entry_metadata, |
71 std::string* out_buffer); | 74 std::string* out_buffer); |
72 | 75 |
73 static void DeSerialize(const char* in_buffer, | 76 static void DeSerialize(const char* in_buffer, |
74 EntryMetadata* out_entry_metadata); | 77 EntryMetadata* out_entry_metadata); |
75 | 78 |
76 char hash_key[kEntryHashKeySize]; // Not a c_string, not null terminated. | 79 char hash_key[kEntryHashKeySize]; // Not a c_string, not null terminated. |
77 | 80 |
78 // This is the serialized format from Time::ToInternalValue(). | 81 // This is the serialized format from Time::ToInternalValue(). |
79 // If you want to make calculations/comparisons, you should use the | 82 // If you want to make calculations/comparisons, you should use the |
80 // base::Time() class. Use the GetLastUsedTime() method above. | 83 // base::Time() class. Use the GetLastUsedTime() method above. |
81 int64 last_used_time; | 84 int64 last_used_time; |
| 85 |
| 86 uint64 entry_size; // Storage size in bytes. |
82 }; | 87 }; |
83 | 88 |
84 const size_t kEntryMetadataSize = sizeof(EntryMetadata); | 89 const size_t kEntryMetadataSize = sizeof(EntryMetadata); |
85 | 90 |
86 struct Footer { | 91 struct Footer { |
87 uint32 crc; | 92 uint32 crc; |
88 }; | 93 }; |
89 | 94 |
90 } // namespace SimpleIndexFile | 95 } // namespace SimpleIndexFile |
91 | 96 |
92 } // namespace disk_cache | 97 } // namespace disk_cache |
93 | 98 |
94 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_DISK_FORMAT_H_ | 99 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_DISK_FORMAT_H_ |
OLD | NEW |