| Index: net/disk_cache/simple/simple_index.h
|
| diff --git a/net/disk_cache/simple/simple_index.h b/net/disk_cache/simple/simple_index.h
|
| index 71f5bb473a2355d5ca22b6d0400c7a878264a1f1..3fa0b163148001bfc23028da5476753e1a8ff309 100644
|
| --- a/net/disk_cache/simple/simple_index.h
|
| +++ b/net/disk_cache/simple/simple_index.h
|
| @@ -9,13 +9,11 @@
|
| #include <string>
|
|
|
| #include "base/basictypes.h"
|
| -#include "base/file_util.h"
|
| +#include "base/callback.h"
|
| #include "base/files/file_path.h"
|
| #include "base/hash_tables.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| -#include "net/disk_cache/disk_cache.h"
|
| -#include "net/disk_cache/simple/simple_disk_format.h"
|
|
|
| namespace base {
|
| class TaskRunner;
|
| @@ -23,6 +21,53 @@ class TaskRunner;
|
|
|
| namespace disk_cache {
|
|
|
| +class EntryMetadata {
|
| + public:
|
| + EntryMetadata();
|
| + EntryMetadata(uint64 hash_key,
|
| + base::Time last_used_time,
|
| + uint64 entry_size);
|
| +
|
| + uint64 GetHashKey() const;
|
| +
|
| + base::Time GetLastUsedTime() const;
|
| + void SetLastUsedTime(const base::Time& last_used_time);
|
| +
|
| + uint64 GetEntrySize() const { return entry_size_; }
|
| + void SetEntrySize(uint64 entry_size) { entry_size_ = entry_size; }
|
| +
|
| + // If we had cheese we could make a sandwitch if we had bread. But we got
|
| + // only pickles.
|
| + // Serialize the data into the provided pickle.
|
| + void Serialize(Pickle* pickle) const;
|
| + static bool DeSerialize(PickleIterator* it,
|
| + EntryMetadata* out);
|
| +
|
| + // Merge two EntryMetadata instances.
|
| + // The existing current valid data in this object will prevail.
|
| + void MergeWith(const EntryMetadata& entry_metadata);
|
| +
|
| + private:
|
| + 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.
|
| +};
|
| +
|
| +// TODO(felipeg): This way we are storing the hash_key twice (as the
|
| +// hash_map::key and as a member of EntryMetadata. We could save space if we
|
| +// use a hash_set.
|
| +typedef base::hash_map<uint64, EntryMetadata> EntrySet;
|
| +
|
| +void InsertInEntrySet(EntrySet* entry_set,
|
| + const EntryMetadata& entry_metadata);
|
| +
|
| +typedef base::Callback<void(scoped_ptr<EntrySet>)> IndexCompletionCallback;
|
| +
|
| // This class is not Thread-safe.
|
| class SimpleIndex
|
| : public base::SupportsWeakPtr<SimpleIndex> {
|
| @@ -53,29 +98,6 @@ class SimpleIndex
|
| bool UpdateEntrySize(const std::string& key, uint64 entry_size);
|
|
|
| private:
|
| - // TODO(felipeg): This way we are storing the hash_key twice (as the
|
| - // hash_map::key and as a member of EntryMetadata. We could save space if we
|
| - // use a hash_set.
|
| - typedef base::hash_map<uint64, SimpleIndexFile::EntryMetadata> EntrySet;
|
| -
|
| - typedef base::Callback<void(scoped_ptr<EntrySet>)> MergeCallback;
|
| -
|
| - static void InsertInternal(
|
| - EntrySet* entry_set,
|
| - const SimpleIndexFile::EntryMetadata& entry_metadata);
|
| -
|
| - // Load index from disk. If it is corrupted, call RestoreFromDisk().
|
| - static void LoadFromDisk(
|
| - const base::FilePath& index_filename,
|
| - const scoped_refptr<base::TaskRunner>& io_thread,
|
| - const MergeCallback& merge_callback);
|
| -
|
| - // Enumerates all entries' files on disk and regenerates the index.
|
| - static void RestoreFromDisk(
|
| - const base::FilePath& index_filename,
|
| - const scoped_refptr<base::TaskRunner>& io_thread,
|
| - const MergeCallback& merge_callback);
|
| -
|
| // Must run on IO Thread.
|
| void MergeInitializingSet(scoped_ptr<EntrySet> index_file_entries);
|
|
|
| @@ -83,13 +105,6 @@ class SimpleIndex
|
| // |out_buffer|.
|
| void Serialize(std::string* out_buffer);
|
|
|
| - bool OpenIndexFile();
|
| - bool CloseIndexFile();
|
| -
|
| - static void UpdateFile(const base::FilePath& index_filename,
|
| - const base::FilePath& temp_filename,
|
| - scoped_ptr<std::string> buffer);
|
| -
|
| EntrySet entries_set_;
|
| uint64 cache_size_; // Total cache storage size in bytes.
|
|
|
|
|