Index: net/disk_cache/blockfile/storage_block-inl.h |
diff --git a/net/disk_cache/blockfile/storage_block-inl.h b/net/disk_cache/blockfile/storage_block-inl.h |
index f919c128c407629d2190bb04391fbfeff17bbf08..15c5975e82c35d2bc4e77204b57bb06ad3611599 100644 |
--- a/net/disk_cache/blockfile/storage_block-inl.h |
+++ b/net/disk_cache/blockfile/storage_block-inl.h |
@@ -13,37 +13,45 @@ |
namespace disk_cache { |
-template<typename T> StorageBlock<T>::StorageBlock(MappedFile* file, |
- Addr address) |
- : data_(NULL), file_(file), address_(address), modified_(false), |
- own_data_(false), extended_(false) { |
+template <typename T> |
+StorageBlock<T>::StorageBlock(MappedFile* file, Addr address) |
+ : data_(NULL), |
+ file_(file), |
+ address_(address), |
+ modified_(false), |
+ own_data_(false), |
+ extended_(false) { |
if (address.num_blocks() > 1) |
extended_ = true; |
DCHECK(!address.is_initialized() || sizeof(*data_) == address.BlockSize()); |
} |
-template<typename T> StorageBlock<T>::~StorageBlock() { |
+template <typename T> |
+StorageBlock<T>::~StorageBlock() { |
if (modified_) |
Store(); |
DeleteData(); |
} |
-template<typename T> void* StorageBlock<T>::buffer() const { |
+template <typename T> |
+void* StorageBlock<T>::buffer() const { |
return data_; |
} |
-template<typename T> size_t StorageBlock<T>::size() const { |
+template <typename T> |
+size_t StorageBlock<T>::size() const { |
if (!extended_) |
return sizeof(*data_); |
return address_.num_blocks() * sizeof(*data_); |
} |
-template<typename T> int StorageBlock<T>::offset() const { |
+template <typename T> |
+int StorageBlock<T>::offset() const { |
return address_.start_block() * address_.BlockSize(); |
} |
-template<typename T> bool StorageBlock<T>::LazyInit(MappedFile* file, |
- Addr address) { |
+template <typename T> |
+bool StorageBlock<T>::LazyInit(MappedFile* file, Addr address) { |
if (file_ || address_.is_initialized()) { |
NOTREACHED(); |
return false; |
@@ -57,13 +65,15 @@ template<typename T> bool StorageBlock<T>::LazyInit(MappedFile* file, |
return true; |
} |
-template<typename T> void StorageBlock<T>::SetData(T* other) { |
+template <typename T> |
+void StorageBlock<T>::SetData(T* other) { |
DCHECK(!modified_); |
DeleteData(); |
data_ = other; |
} |
-template<typename T> void StorageBlock<T>::Discard() { |
+template <typename T> |
+void StorageBlock<T>::Discard() { |
if (!data_) |
return; |
if (!own_data_) { |
@@ -76,46 +86,55 @@ template<typename T> void StorageBlock<T>::Discard() { |
extended_ = false; |
} |
-template<typename T> void StorageBlock<T>::StopSharingData() { |
+template <typename T> |
+void StorageBlock<T>::StopSharingData() { |
if (!data_ || own_data_) |
return; |
DCHECK(!modified_); |
data_ = NULL; |
} |
-template<typename T> void StorageBlock<T>::set_modified() { |
+template <typename T> |
+void StorageBlock<T>::set_modified() { |
DCHECK(data_); |
modified_ = true; |
} |
-template<typename T> void StorageBlock<T>::clear_modified() { |
+template <typename T> |
+void StorageBlock<T>::clear_modified() { |
modified_ = false; |
} |
-template<typename T> T* StorageBlock<T>::Data() { |
+template <typename T> |
+T* StorageBlock<T>::Data() { |
if (!data_) |
AllocateData(); |
return data_; |
} |
-template<typename T> bool StorageBlock<T>::HasData() const { |
+template <typename T> |
+bool StorageBlock<T>::HasData() const { |
return (NULL != data_); |
} |
-template<typename T> bool StorageBlock<T>::VerifyHash() const { |
+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 { |
+template <typename T> |
+bool StorageBlock<T>::own_data() const { |
return own_data_; |
} |
-template<typename T> const Addr StorageBlock<T>::address() const { |
+template <typename T> |
+const Addr StorageBlock<T>::address() const { |
return address_; |
} |
-template<typename T> bool StorageBlock<T>::Load() { |
+template <typename T> |
+bool StorageBlock<T>::Load() { |
if (file_) { |
if (!data_) |
AllocateData(); |
@@ -130,7 +149,8 @@ template<typename T> bool StorageBlock<T>::Load() { |
return false; |
} |
-template<typename T> bool StorageBlock<T>::Store() { |
+template <typename T> |
+bool StorageBlock<T>::Store() { |
if (file_ && data_) { |
data_->self_hash = CalculateHash(); |
if (file_->Store(this)) { |
@@ -143,8 +163,8 @@ template<typename T> bool StorageBlock<T>::Store() { |
return false; |
} |
-template<typename T> bool StorageBlock<T>::Load(FileIOCallback* callback, |
- bool* completed) { |
+template <typename T> |
+bool StorageBlock<T>::Load(FileIOCallback* callback, bool* completed) { |
if (file_) { |
if (!data_) |
AllocateData(); |
@@ -159,8 +179,8 @@ template<typename T> bool StorageBlock<T>::Load(FileIOCallback* callback, |
return false; |
} |
-template<typename T> bool StorageBlock<T>::Store(FileIOCallback* callback, |
- bool* completed) { |
+template <typename T> |
+bool StorageBlock<T>::Store(FileIOCallback* callback, bool* completed) { |
if (file_ && data_) { |
data_->self_hash = CalculateHash(); |
if (file_->Store(this, callback, completed)) { |
@@ -173,18 +193,20 @@ template<typename T> bool StorageBlock<T>::Store(FileIOCallback* callback, |
return false; |
} |
-template<typename T> void StorageBlock<T>::AllocateData() { |
+template <typename T> |
+void StorageBlock<T>::AllocateData() { |
DCHECK(!data_); |
if (!extended_) { |
data_ = new T; |
} else { |
void* buffer = new char[address_.num_blocks() * sizeof(*data_)]; |
- data_ = new(buffer) T; |
+ data_ = new (buffer) T; |
} |
own_data_ = true; |
} |
-template<typename T> void StorageBlock<T>::DeleteData() { |
+template <typename T> |
+void StorageBlock<T>::DeleteData() { |
if (own_data_) { |
if (!extended_) { |
delete data_; |
@@ -196,7 +218,8 @@ template<typename T> void StorageBlock<T>::DeleteData() { |
} |
} |
-template<typename T> uint32 StorageBlock<T>::CalculateHash() const { |
+template <typename T> |
+uint32 StorageBlock<T>::CalculateHash() const { |
return base::Hash(reinterpret_cast<char*>(data_), offsetof(T, self_hash)); |
} |