Bug 455606 - Remove old cache elements when pushing elements with the same key r/sr=stuart

This commit is contained in:
Joe Drew 2008-09-30 17:47:47 -04:00
Родитель 8ffa1cf185
Коммит 15abb5060d
1 изменённых файлов: 8 добавлений и 6 удалений

Просмотреть файл

@ -643,15 +643,17 @@ PRBool imgLoader::PutIntoCache(nsIURI *key, imgCacheEntry *entry)
if (!tmpRequest->IsReusable(cacheId)) if (!tmpRequest->IsReusable(cacheId))
return PR_FALSE; return PR_FALSE;
if (gCacheTracker) // If it already exists, and we're putting the same key into the cache, we
gCacheTracker->MarkUsed(tmpCacheEntry); // should remove the old version.
PR_LOG(gImgLog, PR_LOG_DEBUG,
("[this=%p] imgLoader::PutIntoCache -- Replacing cached element", nsnull));
return PR_TRUE; RemoveFromCache(key);
} else {
PR_LOG(gImgLog, PR_LOG_DEBUG,
("[this=%p] imgLoader::PutIntoCache -- Element NOT already in the cache", nsnull));
} }
PR_LOG(gImgLog, PR_LOG_DEBUG,
("[this=%p] imgLoader::PutIntoCache -- Element NOT already in the cache", nsnull));
if (!cache.Put(spec, entry)) if (!cache.Put(spec, entry))
return PR_FALSE; return PR_FALSE;