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

Unified Diff: net/disk_cache/v3/index_table.h

Issue 15203004: Disk cache: Reference CL for the implementation of file format version 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 7 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/v3/eviction_v3.cc ('k') | net/disk_cache/v3/index_table.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/v3/index_table.h
===================================================================
--- net/disk_cache/v3/index_table.h (revision 0)
+++ net/disk_cache/v3/index_table.h (revision 0)
@@ -0,0 +1,136 @@
+// 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_V3_INDEX_TABLE_V3_H_
+#define NET_DISK_CACHE_V3_INDEX_TABLE_V3_H_
+
+#include <vector>
+
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/time.h"
+#include "net/base/net_export.h"
+#include "net/disk_cache/addr.h"
+#include "net/disk_cache/bitmap.h"
+#include "net/disk_cache/v3/disk_format_v3.h"
+
+namespace base {
+class FilePath;
+}
+
+namespace disk_cache {
+
+class BackendImplV3;
+struct InitResult;
+
+class EntryCell {
+ public:
+ EntryCell();
+ EntryCell(int32 cell_id, uint32 hash, Addr address);
+ EntryCell(int32 cell_id, uint32 hash, const IndexCell& cell);
+ ~EntryCell();
+
+ int32 cell_id() const { return cell_id_; }
+ EntryState state() const { return static_cast<EntryState>(cell_.state); }
+ EntryGroup group() const { return static_cast<EntryGroup>(cell_.group); }
+ int reuse() const { return cell_.reuse; }
+ uint32 hash() const { return hash_; }
+ IndexCell cell() const { return cell_; }
+
+ Addr GetAddress() const;
+ int GetTimestamp() const;
+
+ void set_state(EntryState state) { cell_.state = state; }
+ void set_group(EntryGroup group) { cell_.group = group; }
+ void set_reuse(int count);
+ void set_timestamp(int timestamp);
+
+ static bool ValidAddress(Addr address);
+ static uint32 GetHash(const IndexCell& cell);
+ static int GetTimestamp(const IndexCell& cell);
+ static bool IsNormalState(const IndexCell& cell);
+
+ bool IsValid() const { return cell_.address != 0; }
+ void Clear() { cell_.Clear(); }
+ void FixSum();
+
+ private:
+ int32 cell_id_;
+ uint32 hash_;
+ IndexCell cell_;
+};
+
+struct EntrySet {
+ EntrySet();
+
+ int evicted_count;
+ size_t current;
+ std::vector<EntryCell> cells;
+};
+
+struct CellId { uint32 hash; Addr address; };
+typedef std::vector<CellId> CellList;
+struct IndexIterator {
+ CellList cells;
+ int timestamp;
+ bool forward;
+};
+
+class IndexTable {
+ public:
+ IndexTable(BackendImplV3* backend);
+
+ void Init(InitResult* params);
+ void Reset();
+
+ EntrySet LookupEntry(uint32 hash);
+ EntryCell CreateEntryCell(uint32 hash, Addr address);
+ bool SetSate(uint32 hash, Addr address, EntryState state);
+ bool SetGroup(uint32 hash, Addr address, EntryGroup group);
+ int GetTimestamp(base::Time time);
+ void UpdateTime(uint32 hash, Addr address);
+
+ EntryCell FindEntryCell(uint32 hash, Addr address);
+ void Save(EntryCell* cell);
+
+ void GetOldest(CellList* no_use, CellList* low_use, CellList* high_use);
+ bool GetNextCells(IndexIterator* iterator);
+
+ IndexHeaderV3* header() { return header_; }
+ const IndexHeaderV3* header() const { return header_; }
+
+ private:
+ EntryCell FindEntryCellImpl(uint32 hash, Addr address, bool allow_deleted);
+ void CheckState(IndexCell* cell, int32 cell_id);
+ void Write(const EntryCell& cell);
+ int NewExtraBucket();
+ void GetOldestFromBucket(IndexBucket* bucket, int bucket_hash,
+ CellList* no_use, int* no_use_time,
+ CellList* low_use, int* low_use_time,
+ CellList* high_use, int* high_use_time);
+ void MoveCells(IndexBucket* old_extra_table);
+ void MoveSingleCell(IndexCell* current_cell, int cell_id,
+ int main_table_index, bool growing);
+ void HandleMisplacedCell(IndexCell* current_cell, int cell_id,
+ int main_table_index);
+ void CheckBucketList(int bucket_id);
+
+ BackendImplV3* backend_;
+ IndexHeaderV3* header_;
+ scoped_ptr<Bitmap> bitmap_;
+ scoped_ptr<Bitmap> backup_bitmap_;
+ scoped_ptr<uint32[]> backup_bitmap_storage_;
+ scoped_ptr<IndexHeaderV3> backup_header_;
+ IndexBucket* main_table_;
+ IndexBucket* extra_table_;
+ uint32 mask_; // Binary mask to map a hash to the hash table.
+ int extra_bits_; // How many bits are in mask_ above the default value.
+
+ DISALLOW_COPY_AND_ASSIGN(IndexTable);
+};
+
+} // namespace disk_cache
+
+#endif // NET_DISK_CACHE_V3_INDEX_TABLE_V3_H_
Property changes on: net\disk_cache\v3\index_table.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « net/disk_cache/v3/eviction_v3.cc ('k') | net/disk_cache/v3/index_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698