| 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_
|
|
|