summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/rankings.h
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-29 18:59:03 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-29 18:59:03 +0000
commite47737e2a8eb0e3f321c0c4ff39255c8f60f82d2 (patch)
tree9737555e08e63549bf628c3ba4883a6555cfab22 /net/disk_cache/rankings.h
parent1b570ee3cd4e89c2ff0d38098e04d3db20bc5ada (diff)
downloadchromium_src-e47737e2a8eb0e3f321c0c4ff39255c8f60f82d2.zip
chromium_src-e47737e2a8eb0e3f321c0c4ff39255c8f60f82d2.tar.gz
chromium_src-e47737e2a8eb0e3f321c0c4ff39255c8f60f82d2.tar.bz2
Disk Cache: Improve handling of dirty entries.
* Split the entry sanity checks in two parts: a critical one and a non-critical one. This allows us to return dirty entries instead of failing to open them. * Make sure that we cannot reach an entry through the index before the actual data reaches the disk (when creating an entry linked through a parent we were not respecting that). * When deleting a block from a block file, first clean it up and then update the map (avoid leaving a dirty free block if there is a crash) * Handle the case of errors when opening entries through the enumerations path. BUG=73102 TEST=net_unittests Review URL: http://codereview.chromium.org/8065015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103323 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/rankings.h')
-rw-r--r--net/disk_cache/rankings.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/net/disk_cache/rankings.h b/net/disk_cache/rankings.h
index f78c97e..b5f6daa 100644
--- a/net/disk_cache/rankings.h
+++ b/net/disk_cache/rankings.h
@@ -112,8 +112,12 @@ class Rankings {
// Inserts a given entry at the head of the queue.
void Insert(CacheRankingsBlock* node, bool modified, List list);
- // Removes a given entry from the LRU list.
- void Remove(CacheRankingsBlock* node, List list);
+ // Removes a given entry from the LRU list. If |strict| is true, this method
+ // assumes that |node| is not pointed to by an active iterator. On the other
+ // hand, removing that restriction allows the current "head" of an iterator
+ // to be removed from the list (basically without control of the code that is
+ // performing the iteration), so it should be used with extra care.
+ void Remove(CacheRankingsBlock* node, List list, bool strict);
// Moves a given entry to the head.
void UpdateRank(CacheRankingsBlock* node, bool modified, List list);
@@ -132,7 +136,11 @@ class Rankings {
// Returns false if the entry is clearly invalid. from_list is true if the
// node comes from the LRU list.
- bool SanityCheck(CacheRankingsBlock* node, bool from_list);
+ bool SanityCheck(CacheRankingsBlock* node, bool from_list) const;
+ bool DataSanityCheck(CacheRankingsBlock* node, bool from_list) const;
+
+ // Sets the |contents| field of |node| to |address|.
+ void SetContents(CacheRankingsBlock* node, CacheAddr address);
private:
typedef std::pair<CacheAddr, CacheRankingsBlock*> IteratorPair;
@@ -174,8 +182,8 @@ class Rankings {
// Returns true if addr is the head or tail of any list. When there is a
// match |list| will contain the list number for |addr|.
- bool IsHead(CacheAddr addr, List* list);
- bool IsTail(CacheAddr addr, List* list);
+ bool IsHead(CacheAddr addr, List* list) const;
+ bool IsTail(CacheAddr addr, List* list) const;
// Updates the iterators whenever node is being changed.
void UpdateIterators(CacheRankingsBlock* node);