tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 331b03344f610817b98c496d502bc13bc6419882
parent 946ac296b56906a2134e41dfeb70dd8deb70a098
Author: Randell Jesup <rjesup@mozilla.com>
Date:   Thu, 23 Oct 2025 14:21:19 +0000

Bug 1995710: Don't purge dictionary cache entries r=necko-reviewers,valentin

Don't purge the metadata-only dictionary origin cache entries; when the
entries they refer to are deleted, the reference in the dictionary origin
cache entry will be removed

Differential Revision: https://phabricator.services.mozilla.com/D269559

Diffstat:
Mnetwerk/cache2/CacheStorageService.cpp | 16+++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp @@ -1497,11 +1497,21 @@ Result<size_t, nsresult> CacheStorageService::MemoryPool::PurgeByFrecency( StaticMutexAutoLock lock(CacheStorageService::Self()->Lock()); for (const auto& entry : mManagedEntries) { - // Referenced items cannot be purged and we deliberately want to not look - // at '0' frecency entries, these are new entries and can be ignored. - if (!entry->IsReferenced() && entry->GetFrecency() > 0.0) { + // Referenced items cannot be purged and we deliberately want to not + // look at '0' frecency entries, these are new entries and can be + // ignored. Also, any dict: (CompressionDictionary) entries for an + // origin should not be purged unless empty - they will empty out as + // the cache entries referenced by them are purged until they are empty. + if (!entry->IsReferenced() && entry->GetFrecency() > 0.0 && + (!entry->GetEnhanceID().EqualsLiteral("dict:") || + entry->GetMetadataMemoryConsumption() == 0)) { mayPurgeEntry copy(entry); mayPurgeSorted.AppendElement(std::move(copy)); + } else { + if (entry->GetEnhanceID().EqualsLiteral("dict:")) { + LOG(("*** Entry is a dictionary origin, metadata size %d", + entry->GetMetadataMemoryConsumption())); + } } } }