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

Unified Diff: net/disk_cache/blockfile/stats.cc

Issue 980003002: Disk cache: Re-initialize stats counters if they are zero on-disk. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 5 years, 10 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/blockfile/stats.h ('k') | net/disk_cache/blockfile/stats_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/blockfile/stats.cc
diff --git a/net/disk_cache/blockfile/stats.cc b/net/disk_cache/blockfile/stats.cc
index e6b10b878569c04b733e39ecfe1d4f532b994890..bb319f55b152314f2ba39ac05c522d9290ed81df 100644
--- a/net/disk_cache/blockfile/stats.cc
+++ b/net/disk_cache/blockfile/stats.cc
@@ -107,8 +107,18 @@ bool Stats::Init(void* data, int num_bytes, Addr address) {
local_stats.size = sizeof(local_stats);
} else if (num_bytes >= static_cast<int>(sizeof(*stats))) {
stats = reinterpret_cast<OnDiskStats*>(data);
- if (!VerifyStats(stats))
- return false;
+ if (!VerifyStats(stats)) {
+ memset(&local_stats, 0, sizeof(local_stats));
+ if (memcmp(stats, &local_stats, sizeof(local_stats))) {
+ return false;
+ } else {
+ // The storage is empty which means that SerializeStats() was never
+ // called on the last run. Just re-initialize everything.
+ local_stats.signature = kDiskSignature;
+ local_stats.size = sizeof(local_stats);
+ stats = &local_stats;
+ }
+ }
} else {
return false;
}
« no previous file with comments | « net/disk_cache/blockfile/stats.h ('k') | net/disk_cache/blockfile/stats_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698