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

Side by Side Diff: net/disk_cache/storage_block-inl.h

Issue 155951: Disk cache: Fix handling of invalid entries that are detected... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/storage_block.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 DCHECK(sizeof(*data_) == address.BlockSize()); 55 DCHECK(sizeof(*data_) == address.BlockSize());
56 return true; 56 return true;
57 } 57 }
58 58
59 template<typename T> void StorageBlock<T>::SetData(T* other) { 59 template<typename T> void StorageBlock<T>::SetData(T* other) {
60 DCHECK(!modified_); 60 DCHECK(!modified_);
61 DeleteData(); 61 DeleteData();
62 data_ = other; 62 data_ = other;
63 } 63 }
64 64
65 template<typename T> void StorageBlock<T>::Discard() {
66 if (!data_)
67 return;
68 if (!own_data_) {
69 NOTREACHED();
70 return;
71 }
72 DeleteData();
73 data_ = NULL;
74 modified_ = false;
75 own_data_ = false;
76 extended_ = false;
77 }
78
65 template<typename T> void StorageBlock<T>::set_modified() { 79 template<typename T> void StorageBlock<T>::set_modified() {
66 DCHECK(data_); 80 DCHECK(data_);
67 modified_ = true; 81 modified_ = true;
68 } 82 }
69 83
70 template<typename T> T* StorageBlock<T>::Data() { 84 template<typename T> T* StorageBlock<T>::Data() {
71 if (!data_) 85 if (!data_)
72 AllocateData(); 86 AllocateData();
73 return data_; 87 return data_;
74 } 88 }
(...skipping 15 matching lines...) Expand all
90 modified_ = false; 104 modified_ = false;
91 return true; 105 return true;
92 } 106 }
93 } 107 }
94 LOG(WARNING) << "Failed data load."; 108 LOG(WARNING) << "Failed data load.";
95 Trace("Failed data load."); 109 Trace("Failed data load.");
96 return false; 110 return false;
97 } 111 }
98 112
99 template<typename T> bool StorageBlock<T>::Store() { 113 template<typename T> bool StorageBlock<T>::Store() {
100 if (file_) { 114 if (file_ && data_) {
101 if (file_->Store(this)) { 115 if (file_->Store(this)) {
102 modified_ = false; 116 modified_ = false;
103 return true; 117 return true;
104 } 118 }
105 } 119 }
106 LOG(ERROR) << "Failed data store."; 120 LOG(ERROR) << "Failed data store.";
107 Trace("Failed data store."); 121 Trace("Failed data store.");
108 return false; 122 return false;
109 } 123 }
110 124
(...skipping 16 matching lines...) Expand all
127 data_->~T(); 141 data_->~T();
128 delete[] reinterpret_cast<char*>(data_); 142 delete[] reinterpret_cast<char*>(data_);
129 } 143 }
130 own_data_ = false; 144 own_data_ = false;
131 } 145 }
132 } 146 }
133 147
134 } // namespace disk_cache 148 } // namespace disk_cache
135 149
136 #endif // NET_DISK_CACHE_STORAGE_BLOCK_INL_H_ 150 #endif // NET_DISK_CACHE_STORAGE_BLOCK_INL_H_
OLDNEW
« no previous file with comments | « net/disk_cache/storage_block.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698