diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-16 19:32:06 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-16 19:32:06 +0000 |
commit | a8d8d24a94a87830253b27537cd05069a3b369b6 (patch) | |
tree | b55701430cc0a4ff8c893bd4b352a897299fef8d /net/disk_cache/rankings.h | |
parent | 557f1c9bb1c8c7f5cebbb6914a244b4b111725a6 (diff) | |
download | chromium_src-a8d8d24a94a87830253b27537cd05069a3b369b6.zip chromium_src-a8d8d24a94a87830253b27537cd05069a3b369b6.tar.gz chromium_src-a8d8d24a94a87830253b27537cd05069a3b369b6.tar.bz2 |
Disk cache: remove the hard coded list from rankings.cc
The rankings module now works with any list, not just
the first one. This is part of the support needed for
new eviction algorithms.
note: Rankings::CheckList() is basically the code that
was implementing the old Rankings::SelfCheck() (moved
with this cl).
The disk cache behavior is not changing with this cl.
Review URL: http://codereview.chromium.org/14141
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7074 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/rankings.h')
-rw-r--r-- | net/disk_cache/rankings.h | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/net/disk_cache/rankings.h b/net/disk_cache/rankings.h index 4347fa2..1434235 100644 --- a/net/disk_cache/rankings.h +++ b/net/disk_cache/rankings.h @@ -48,6 +48,15 @@ enum RankCrashes { // This class handles the ranking information for the cache. class Rankings { public: + // Possible lists of entries. + enum List { + NO_USE = 0, // List of entries that have not been reused. + LOW_USE, // List of entries with low reuse. + HIGH_USE, // List of entries with high reuse. + DELETED, // List of recently deleted or doomed entries. + LAST_ELEMENT + }; + // This class provides a specialized version of scoped_ptr, that calls // Rankings whenever a CacheRankingsBlock is deleted, to keep track of cache // iterators that may go stale. @@ -73,8 +82,7 @@ class Rankings { DISALLOW_EVIL_CONSTRUCTORS(ScopedRankingsBlock); }; - Rankings() - : init_(false), head_(0), tail_(0) {} + Rankings() : init_(false) {} ~Rankings() {} bool Init(BackendImpl* backend); @@ -83,20 +91,20 @@ class Rankings { void Reset(); // Inserts a given entry at the head of the queue. - void Insert(CacheRankingsBlock* node, bool modified); + void Insert(CacheRankingsBlock* node, bool modified, List list); // Removes a given entry from the LRU list. - void Remove(CacheRankingsBlock* node); + void Remove(CacheRankingsBlock* node, List list); // Moves a given entry to the head. - void UpdateRank(CacheRankingsBlock* node, bool modified); + void UpdateRank(CacheRankingsBlock* node, bool modified, List list); // Iterates through the list. - CacheRankingsBlock* GetNext(CacheRankingsBlock* node); - CacheRankingsBlock* GetPrev(CacheRankingsBlock* node); + CacheRankingsBlock* GetNext(CacheRankingsBlock* node, List list); + CacheRankingsBlock* GetPrev(CacheRankingsBlock* node, List list); void FreeRankingsBlock(CacheRankingsBlock* node); - // Peforms a simple self-check of the list, and returns the number of items + // Peforms a simple self-check of the lists, and returns the number of items // or an error code (negative value). int SelfCheck(); @@ -108,10 +116,10 @@ class Rankings { typedef std::pair<CacheAddr, CacheRankingsBlock*> IteratorPair; typedef std::list<IteratorPair> IteratorList; - Addr ReadHead(); - Addr ReadTail(); - void WriteHead(); - void WriteTail(); + void ReadHeads(); + void ReadTails(); + void WriteHead(List list); + void WriteTail(List list); // Gets the rankings information for a given rankings node. bool GetRanking(CacheRankingsBlock* rankings); @@ -127,11 +135,19 @@ class Rankings { // Returns false if node is not properly linked. bool CheckLinks(CacheRankingsBlock* node, CacheRankingsBlock* prev, - CacheRankingsBlock* next); + CacheRankingsBlock* next, List list); // Checks the links between two consecutive nodes. bool CheckSingleLink(CacheRankingsBlock* prev, CacheRankingsBlock* next); + // Peforms a simple check of the list, and returns the number of items or an + // error code (negative value). + int CheckList(List list); + + // Returns true if addr is the head or tail of any list. + bool IsHead(CacheAddr addr); + bool IsTail(CacheAddr addr); + // Controls tracking of nodes used for enumerations. void TrackRankingsBlock(CacheRankingsBlock* node, bool start_tracking); @@ -139,8 +155,8 @@ class Rankings { void UpdateIterators(CacheRankingsBlock* node); bool init_; - Addr head_; - Addr tail_; + Addr heads_[LAST_ELEMENT]; + Addr tails_[LAST_ELEMENT]; BackendImpl* backend_; LruData* control_data_; // Data related to the LRU lists. IteratorList iterators_; |