diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-06 01:25:06 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-06 01:25:06 +0000 |
commit | 761d342a5307a6b858a3bfd2feaa14eb4d9830ce (patch) | |
tree | e245a933e168c61cbb1af1d6d6883421080e084d /net/disk_cache/stats.cc | |
parent | 952a078a76e9f8c22cc43d5ce47c5c83e2f8e772 (diff) | |
download | chromium_src-761d342a5307a6b858a3bfd2feaa14eb4d9830ce.zip chromium_src-761d342a5307a6b858a3bfd2feaa14eb4d9830ce.tar.gz chromium_src-761d342a5307a6b858a3bfd2feaa14eb4d9830ce.tar.bz2 |
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
Diffstat (limited to 'net/disk_cache/stats.cc')
-rw-r--r-- | net/disk_cache/stats.cc | 11 |
1 files changed, 8 insertions, 3 deletions
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<int>(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<unsigned int>(stats->size) > sizeof(*stats)) { memset(stats, 0, sizeof(*stats)); + } return true; } |