tor-browser

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

commit 17d6947e95f4de6de8848f118a4691a4924f9091
parent 10a3b590155247b10b3c0bf0c10f7d8e0aa734ec
Author: Randell Jesup <rjesup@mozilla.com>
Date:   Mon, 27 Oct 2025 18:11:25 +0000

Bug 1996560: Clear from dictionary cache on file removal, not metadata removal r=necko-reviewers,valentin

Also fix an issue with RemoveOrigin

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

Diffstat:
Mnetwerk/cache2/CacheEntry.cpp | 9+++++++++
Mnetwerk/cache2/CacheStorageService.cpp | 9---------
Mnetwerk/cache2/Dictionary.cpp | 8++++----
3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/netwerk/cache2/CacheEntry.cpp b/netwerk/cache2/CacheEntry.cpp @@ -1770,6 +1770,15 @@ void CacheEntry::DoomAlreadyRemoved() { mIsDoomed = true; + // Remove from DictionaryCache immediately, to ensure the removal is + // synchronous + LOG(("DoomAlreadyRemoved [entry=%p removed]", this)); + if (mEnhanceID.EqualsLiteral("dict:")) { + DictionaryCache::RemoveOriginFor(mURI); + } else { + DictionaryCache::RemoveDictionaryFor(mURI); + } + // Pretend pinning is know. This entry is now doomed for good, so don't // bother with defering doom because of unknown pinning state any more. mPinningKnown = true; diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp @@ -744,15 +744,6 @@ static bool RemoveExactEntry(CacheEntryTable* aEntries, nsACString const& aKey, return false; // Already replaced... } - // Remove from DictionaryCache immediately, to ensure the removal is - // synchronous - - if (aEntry->GetEnhanceID().EqualsLiteral("dict:")) { - DictionaryCache::RemoveOriginFor(aEntry->GetURI()); - } else { - DictionaryCache::RemoveDictionaryFor(aEntry->GetURI()); - } - LOG(("RemoveExactEntry [entry=%p removed]", aEntry)); aEntries->Remove(aKey); return true; diff --git a/netwerk/cache2/Dictionary.cpp b/netwerk/cache2/Dictionary.cpp @@ -918,7 +918,7 @@ void DictionaryCache::RemoveDictionaryFor(const nsACString& aKey) { // Remove a dictionary if it exists for the key given void DictionaryCache::RemoveDictionary(const nsACString& aKey) { DICTIONARY_LOG( - ("Removing dictionary for %80s", PromiseFlatCString(aKey).get())); + ("Removing dictionary for %s", PromiseFlatCString(aKey).get())); nsCOMPtr<nsIURI> uri; if (NS_FAILED(NS_NewURI(getter_AddRefs(uri), aKey))) { @@ -936,10 +936,10 @@ void DictionaryCache::RemoveDictionary(const nsACString& aKey) { void DictionaryCache::RemoveOriginFor(const nsACString& aKey) { RefPtr<DictionaryCache> cache = GetInstance(); DICTIONARY_LOG( - ("Removing dictionary for %80s", PromiseFlatCString(aKey).get())); + ("Removing dictionary origin %s", PromiseFlatCString(aKey).get())); NS_DispatchToMainThread(NewRunnableMethod<const nsCString>( - "DictionaryCache::RemoveDictionaryFor", cache, - &DictionaryCache::RemoveDictionary, aKey)); + "DictionaryCache::RemoveOriginFor", cache, &DictionaryCache::RemoveOrigin, + aKey)); } // Remove a dictionary if it exists for the key given