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

Unified Diff: net/disk_cache/storage_block-inl.h

Issue 8658001: Disk cache: Add a hash to the entry's internal data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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
Index: net/disk_cache/storage_block-inl.h
===================================================================
--- net/disk_cache/storage_block-inl.h (revision 110637)
+++ net/disk_cache/storage_block-inl.h (working copy)
@@ -9,6 +9,7 @@
#include "net/disk_cache/storage_block.h"
#include "base/logging.h"
+#include "net/disk_cache/hash.h"
#include "net/disk_cache/trace.h"
namespace disk_cache {
@@ -98,6 +99,11 @@
return (NULL != data_);
}
+template<typename T> bool StorageBlock<T>::VerifyHash() const {
+ uint32 hash = CalculateHash();
+ return (!data_->self_hash || data_->self_hash == hash);
+}
+
template<typename T> bool StorageBlock<T>::own_data() const {
return own_data_;
}
@@ -123,6 +129,7 @@
template<typename T> bool StorageBlock<T>::Store() {
if (file_ && data_) {
+ data_->self_hash = CalculateHash();
if (file_->Store(this)) {
modified_ = false;
return true;
@@ -156,6 +163,10 @@
}
}
+template<typename T> uint32 StorageBlock<T>::CalculateHash() const {
+ return Hash(reinterpret_cast<char*>(data_), offsetof(T, self_hash));
+}
+
} // namespace disk_cache
#endif // NET_DISK_CACHE_STORAGE_BLOCK_INL_H_

Powered by Google App Engine
This is Rietveld 408576698