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

Unified Diff: net/disk_cache/flash/segment.cc

Issue 11269008: Cache backend for devices with flash storage (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: test Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/flash/segment.h ('k') | net/disk_cache/flash/segment_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/flash/segment.cc
diff --git a/net/disk_cache/flash/segment.cc b/net/disk_cache/flash/segment.cc
index a63a5a39985d077b7eca9393321204e57eddfa0f..b00b38a5209c64fac7fdca02727170d41ccbe0c8 100644
--- a/net/disk_cache/flash/segment.cc
+++ b/net/disk_cache/flash/segment.cc
@@ -18,17 +18,19 @@ Segment::Segment(int32 index, bool read_only, Storage* storage)
write_offset_(offset_) {
DCHECK(storage);
DCHECK(storage->size() % kFlashSegmentSize == 0);
- DCHECK(offset_ >= 0 && offset_ + kFlashSegmentSize <= storage->size());
}
Segment::~Segment() {
- DCHECK(read_only_);
+ DCHECK(!init_ || read_only_);
}
bool Segment::Init() {
if (init_)
return false;
+ if (offset_ < 0 || offset_ + kFlashSegmentSize > storage_->size())
+ return false;
+
if (!read_only_) {
init_ = true;
return true;
@@ -82,6 +84,7 @@ bool Segment::Close() {
DCHECK(header_offsets_.size() <= kFlashMaxEntryCount);
int32 summary[kFlashMaxEntryCount + 1];
+ memset(summary, 0, kFlashSummarySize);
summary[0] = header_offsets_.size();
std::copy(header_offsets_.begin(), header_offsets_.end(), summary + 1);
if (!storage_->Write(summary, kFlashSummarySize, summary_offset_))
« no previous file with comments | « net/disk_cache/flash/segment.h ('k') | net/disk_cache/flash/segment_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698