Bug 1147973 - Detailed disk cache hit rate telemetry is wrong, r=honzab

This commit is contained in:
Michal Novotny 2015-03-30 21:08:52 +02:00
parent 6d13980c63
commit 45032afa61

View File

@ -337,6 +337,8 @@ bool CacheEntry::Load(bool aTruncate, bool aPriority)
nsAutoCString fileKey;
rv = HashingKeyWithStorage(fileKey);
bool reportMiss = false;
// Check the index under two conditions for two states and take appropriate action:
// 1. When this is a disk entry and not told to truncate, check there is a disk file.
// If not, set the 'truncate' flag to true so that this entry will open instantly
@ -351,6 +353,9 @@ bool CacheEntry::Load(bool aTruncate, bool aPriority)
switch (status) {
case CacheIndex::DOES_NOT_EXIST:
LOG((" entry doesn't exist according information from the index, truncating"));
if (!aTruncate && mUseDisk) {
reportMiss = true;
}
aTruncate = true;
break;
case CacheIndex::EXISTS:
@ -380,6 +385,11 @@ bool CacheEntry::Load(bool aTruncate, bool aPriority)
{
mozilla::MutexAutoUnlock unlock(mLock);
if (reportMiss) {
CacheFileUtils::DetailedCacheHitTelemetry::AddRecord(
CacheFileUtils::DetailedCacheHitTelemetry::MISS, mLoadStart);
}
LOG((" performing load, file=%p", mFile.get()));
if (NS_SUCCEEDED(rv)) {
rv = mFile->Init(fileKey,