Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Unified Diff: net/disk_cache/simple/simple_disk_format.h

Issue 14263005: Refactor our SimpleIndex file format and serialization to use Pickle instead of the previously bugg… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: to commit again, since the last dcommit failed Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/backend_unittest.cc ('k') | net/disk_cache/simple/simple_disk_format.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/simple/simple_disk_format.h
diff --git a/net/disk_cache/simple/simple_disk_format.h b/net/disk_cache/simple/simple_disk_format.h
deleted file mode 100644
index 08fd2e26f07cdcac57ccb2d5d034d30bf1f95b68..0000000000000000000000000000000000000000
--- a/net/disk_cache/simple/simple_disk_format.h
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// 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_
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/port.h"
-#include "net/base/net_export.h"
-
-namespace base {
-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 NET_EXPORT_PRIVATE 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(uint64);
-
-std::string ConvertEntryHashKeyToHexString(uint64 hash_key);
-
-// |key| is the regular HTTP Cache key, which is a URL.
-// Returns the Hex ascii representation of the uint64 hash_key.
-std::string GetEntryHashKeyAsHexString(const std::string& key);
-
-// |key| is the regular HTTP Cache key, which is a URL.
-// Returns the hash of the key as uint64.
-uint64 GetEntryHashKey(const std::string& key);
-
-// Parses the |hash_key| string into a uint64 buffer.
-// |hash_key| string must be of the form: FFFFFFFFFFFFFFFF .
-bool GetEntryHashKeyFromHexString(const std::string& hash_key,
- uint64* hash_key_out);
-
-} // namespace disk_cache
-
-#endif // NET_DISK_CACHE_SIMPLE_SIMPLE_DISK_FORMAT_H_
« no previous file with comments | « net/disk_cache/backend_unittest.cc ('k') | net/disk_cache/simple/simple_disk_format.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698