summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/storage_block-inl.h
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 00:37:15 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 00:37:15 +0000
commitf20920fc7d56aebfd9631318c2b0d1adf36c5a9e (patch)
tree907380abc63c04e1d5a1a93713132bba9814d338 /net/disk_cache/storage_block-inl.h
parentbded84c49d2944862dd2d009919ef6a272e8c5f2 (diff)
downloadchromium_src-f20920fc7d56aebfd9631318c2b0d1adf36c5a9e.zip
chromium_src-f20920fc7d56aebfd9631318c2b0d1adf36c5a9e.tar.gz
chromium_src-f20920fc7d56aebfd9631318c2b0d1adf36c5a9e.tar.bz2
Disk cache: Fix handling of invalid entries that are detected
when doing evictions or enumerations. This cl fixes an issue with dirty entries being deleted twice from disk, and improves the whole thing so that different flavors or corrupt entries are removed gracefully. We started deleting things twice when we created the map of currently-open entries, because we don't want to have dirty entries on that map, so it is possible to have multiple EntryImpl objects that refer to the same entry (for corrupt entries). BUG=17474 TEST=Unittests, stress_cache.exe Review URL: http://codereview.chromium.org/155951 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21360 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/storage_block-inl.h')
-rw-r--r--net/disk_cache/storage_block-inl.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/net/disk_cache/storage_block-inl.h b/net/disk_cache/storage_block-inl.h
index 9ec9fa0..909b717 100644
--- a/net/disk_cache/storage_block-inl.h
+++ b/net/disk_cache/storage_block-inl.h
@@ -62,6 +62,20 @@ template<typename T> void StorageBlock<T>::SetData(T* other) {
data_ = other;
}
+template<typename T> void StorageBlock<T>::Discard() {
+ if (!data_)
+ return;
+ if (!own_data_) {
+ NOTREACHED();
+ return;
+ }
+ DeleteData();
+ data_ = NULL;
+ modified_ = false;
+ own_data_ = false;
+ extended_ = false;
+}
+
template<typename T> void StorageBlock<T>::set_modified() {
DCHECK(data_);
modified_ = true;
@@ -97,7 +111,7 @@ template<typename T> bool StorageBlock<T>::Load() {
}
template<typename T> bool StorageBlock<T>::Store() {
- if (file_) {
+ if (file_ && data_) {
if (file_->Store(this)) {
modified_ = false;
return true;