From 761d342a5307a6b858a3bfd2feaa14eb4d9830ce Mon Sep 17 00:00:00 2001 From: "rvargas@google.com" Date: Thu, 6 Jan 2011 01:25:06 +0000 Subject: Disk cache: Add a few more histograms and stats to figure out why there are so many users with available cache space. BUG=none TEST=none Review URL: http://codereview.chromium.org/6020008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70575 0039d316-1c4b-4281-b951-d872f2087c98 --- net/disk_cache/stats.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'net/disk_cache/stats.cc') diff --git a/net/disk_cache/stats.cc b/net/disk_cache/stats.cc index f0446fb..5222112 100644 --- a/net/disk_cache/stats.cc +++ b/net/disk_cache/stats.cc @@ -20,6 +20,7 @@ struct OnDiskStats { int data_sizes[disk_cache::Stats::kDataSizesLength]; int64 counters[disk_cache::Stats::MAX_COUNTER]; }; +COMPILE_ASSERT(sizeof(OnDiskStats) < 512, needs_more_than_2_blocks); // Returns the "floor" (as opposed to "ceiling") of log base 2 of number. int LogBase2(int32 number) { @@ -37,6 +38,7 @@ int LogBase2(int32 number) { return static_cast(result); } +// WARNING: Add new stats only at the end, or change LoadStats(). static const char* kCounterNames[] = { "Open miss", "Open hit", @@ -57,7 +59,8 @@ static const char* kCounterNames[] = { "Get rankings", "Fatal error", "Last report", - "Last report timer" + "Last report timer", + "Doom recent entries" }; COMPILE_ASSERT(arraysize(kCounterNames) == disk_cache::Stats::MAX_COUNTER, update_the_names); @@ -73,6 +76,7 @@ bool LoadStats(BackendImpl* backend, Addr address, OnDiskStats* stats) { size_t offset = address.start_block() * address.BlockSize() + kBlockHeaderSize; + memset(stats, 0, sizeof(*stats)); if (!file->Read(stats, sizeof(*stats), offset)) return false; @@ -80,9 +84,10 @@ bool LoadStats(BackendImpl* backend, Addr address, OnDiskStats* stats) { return false; // We don't want to discard the whole cache every time we have one extra - // counter; just reset them to zero. - if (stats->size != sizeof(*stats)) + // counter; we keep old data if we can. + if (static_cast(stats->size) > sizeof(*stats)) { memset(stats, 0, sizeof(*stats)); + } return true; } -- cgit v1.1