| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_DISK_CACHE_STORAGE_BLOCK_INL_H_ | 5 #ifndef NET_DISK_CACHE_STORAGE_BLOCK_INL_H_ |
| 6 #define NET_DISK_CACHE_STORAGE_BLOCK_INL_H_ | 6 #define NET_DISK_CACHE_STORAGE_BLOCK_INL_H_ |
| 7 | 7 |
| 8 #include "net/disk_cache/storage_block.h" | 8 #include "net/disk_cache/storage_block.h" |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 template<typename T> void StorageBlock<T>::Discard() { | 65 template<typename T> void StorageBlock<T>::Discard() { |
| 66 if (!data_) | 66 if (!data_) |
| 67 return; | 67 return; |
| 68 if (!own_data_) { | 68 if (!own_data_) { |
| 69 NOTREACHED(); | 69 NOTREACHED(); |
| 70 return; | 70 return; |
| 71 } | 71 } |
| 72 DeleteData(); | 72 DeleteData(); |
| 73 data_ = NULL; | 73 data_ = NULL; |
| 74 modified_ = false; | 74 modified_ = false; |
| 75 own_data_ = false; | |
| 76 extended_ = false; | 75 extended_ = false; |
| 77 } | 76 } |
| 78 | 77 |
| 78 template<typename T> void StorageBlock<T>::StopSharingData() { |
| 79 if (!data_ || own_data_) |
| 80 return; |
| 81 DCHECK(!modified_); |
| 82 data_ = NULL; |
| 83 } |
| 84 |
| 79 template<typename T> void StorageBlock<T>::set_modified() { | 85 template<typename T> void StorageBlock<T>::set_modified() { |
| 80 DCHECK(data_); | 86 DCHECK(data_); |
| 81 modified_ = true; | 87 modified_ = true; |
| 82 } | 88 } |
| 83 | 89 |
| 84 template<typename T> T* StorageBlock<T>::Data() { | 90 template<typename T> T* StorageBlock<T>::Data() { |
| 85 if (!data_) | 91 if (!data_) |
| 86 AllocateData(); | 92 AllocateData(); |
| 87 return data_; | 93 return data_; |
| 88 } | 94 } |
| 89 | 95 |
| 90 template<typename T> bool StorageBlock<T>::HasData() const { | 96 template<typename T> bool StorageBlock<T>::HasData() const { |
| 91 return (NULL != data_); | 97 return (NULL != data_); |
| 92 } | 98 } |
| 93 | 99 |
| 100 template<typename T> bool StorageBlock<T>::own_data() const { |
| 101 return own_data_; |
| 102 } |
| 103 |
| 94 template<typename T> const Addr StorageBlock<T>::address() const { | 104 template<typename T> const Addr StorageBlock<T>::address() const { |
| 95 return address_; | 105 return address_; |
| 96 } | 106 } |
| 97 | 107 |
| 98 template<typename T> bool StorageBlock<T>::Load() { | 108 template<typename T> bool StorageBlock<T>::Load() { |
| 99 if (file_) { | 109 if (file_) { |
| 100 if (!data_) | 110 if (!data_) |
| 101 AllocateData(); | 111 AllocateData(); |
| 102 | 112 |
| 103 if (file_->Load(this)) { | 113 if (file_->Load(this)) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 data_->~T(); | 151 data_->~T(); |
| 142 delete[] reinterpret_cast<char*>(data_); | 152 delete[] reinterpret_cast<char*>(data_); |
| 143 } | 153 } |
| 144 own_data_ = false; | 154 own_data_ = false; |
| 145 } | 155 } |
| 146 } | 156 } |
| 147 | 157 |
| 148 } // namespace disk_cache | 158 } // namespace disk_cache |
| 149 | 159 |
| 150 #endif // NET_DISK_CACHE_STORAGE_BLOCK_INL_H_ | 160 #endif // NET_DISK_CACHE_STORAGE_BLOCK_INL_H_ |
| OLD | NEW |