Index: net/disk_cache/simple/simple_index_util.h |
diff --git a/net/disk_cache/simple/simple_disk_format.h b/net/disk_cache/simple/simple_index_util.h |
similarity index 24% |
copy from net/disk_cache/simple/simple_disk_format.h |
copy to net/disk_cache/simple/simple_index_util.h |
index 1631e25862c1afab37c9bac2828dd1a1e46f3f5e..70414441393af225c02f15c9f64dc2eeec3e61fd 100644 |
--- a/net/disk_cache/simple/simple_disk_format.h |
+++ b/net/disk_cache/simple/simple_index_util.h |
@@ -2,13 +2,12 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_DISK_FORMAT_H_ |
-#define NET_DISK_CACHE_SIMPLE_SIMPLE_DISK_FORMAT_H_ |
+#ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_UTIL_H_ |
+#define NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_UTIL_H_ |
#include <string> |
#include "base/basictypes.h" |
-#include "base/port.h" |
namespace base { |
class Time; |
@@ -16,97 +15,8 @@ class Time; |
namespace disk_cache { |
-const uint64 kSimpleInitialMagicNumber = GG_UINT64_C(0xfcfb6d1ba7725c30); |
-const uint64 kSimpleIndexInitialMagicNumber = GG_UINT64_C(0x656e74657220796f); |
- |
-// A file in the Simple cache consists of a SimpleFileHeader followed |
-// by data. |
- |
-const uint32 kSimpleVersion = 1; |
- |
-static const int kSimpleEntryFileCount = 3; |
- |
-struct SimpleFileHeader { |
- SimpleFileHeader(); |
- uint64 initial_magic_number; |
- uint32 version; |
- uint32 key_length; |
- uint32 key_hash; |
-}; |
- |
-// Simple Index File sketch: |
-// This is based on the struct Header and Footer as seem below, and the struct |
-// alignment is platform dependent. |
-// The CRC check is a guarantee that we don't read incorrect values. |
-// ------------------------- |
-// struct Header; |
-// ------------------------- |
-// Repeated |size| times { |
-// struct EntryMetadata; |
-// } |
-// ------------------------- |
-// struct Footer; |
-// ------------------------- |
-namespace SimpleIndexFile { |
- // Simple Index File metadata is defined here. |
- struct Header { |
- Header(); |
- uint64 initial_magic_number; |
- uint32 version; |
- uint64 number_of_entries; |
- uint64 cache_size; // Total cache storage size in bytes. |
- }; |
- |
- // TODO(felipeg): At some point we should consider using a protobuffer. See |
- // that we are re-implementing most of protobuffer's functionality such as |
- // Serialize and Merge. |
- // We must keep this struct a POD. |
- struct EntryMetadata { |
- EntryMetadata(); |
- EntryMetadata(uint64 hash_key_p, |
- base::Time last_used_time_p, |
- uint64 entry_size_p); |
- |
- base::Time GetLastUsedTime() const; |
- uint64 GetHashKey() const; |
- void SetLastUsedTime(const base::Time& last_used_time_p); |
- |
- // Serialize the data from |in_entry_metadata| and appends the bytes in |
- // |out_buffer|. The serialization is platform dependent since it simply |
- // writes the whole struct from memory into the given buffer. |
- static void Serialize(const EntryMetadata& in_entry_metadata, |
- std::string* out_buffer); |
- |
- static void DeSerialize(const char* in_buffer, |
- EntryMetadata* out_entry_metadata); |
- |
- // Merge two EntryMetadata instances. |
- // The existing valid data in |out_entry_metadata| will prevail. |
- static void Merge(const EntryMetadata& entry_metadata, |
- EntryMetadata* out_entry_metadata); |
- |
- uint64 hash_key; |
- |
- // This is the serialized format from Time::ToInternalValue(). |
- // If you want to make calculations/comparisons, you should use the |
- // base::Time() class. Use the GetLastUsedTime() method above. |
- int64 last_used_time; |
- |
- uint64 entry_size; // Storage size in bytes. |
- }; |
- |
- const size_t kEntryMetadataSize = sizeof(EntryMetadata); |
- |
- struct Footer { |
- Footer(); |
- uint32 crc; |
- }; |
- |
-} // namespace SimpleIndexFile |
- |
// Size of the uint64 hash_key number in Hex format in a string. |
-const size_t kEntryHashKeyAsHexStringSize = 2 * sizeof( |
- SimpleIndexFile::EntryMetadata::hash_key); |
+const size_t kEntryHashKeyAsHexStringSize = 2 * sizeof(uint64); |
std::string ConvertEntryHashKeyToHexString(uint64 hash_key); |
@@ -125,4 +35,4 @@ bool GetEntryHashKeyFromHexString(const std::string& hash_key, |
} // namespace disk_cache |
-#endif // NET_DISK_CACHE_SIMPLE_SIMPLE_DISK_FORMAT_H_ |
+#endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_UTIL_H_ |