commit 9598c17b4f72afd5d353c2fc2ef2c2b7d931469a
parent 331b03344f610817b98c496d502bc13bc6419882
Author: Randell Jesup <rjesup@mozilla.com>
Date: Thu, 23 Oct 2025 14:25:53 +0000
Bug 1995841: Show formatted data in about:cache for Compression Dictionary origin metadata r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D269647
Diffstat:
4 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp
@@ -1509,8 +1509,11 @@ Result<size_t, nsresult> CacheStorageService::MemoryPool::PurgeByFrecency(
mayPurgeSorted.AppendElement(std::move(copy));
} else {
if (entry->GetEnhanceID().EqualsLiteral("dict:")) {
- LOG(("*** Entry is a dictionary origin, metadata size %d",
- entry->GetMetadataMemoryConsumption()));
+ LOG(
+ ("*** Entry is a dictionary origin, metadata size %d, referenced "
+ "%d, Frecency %f",
+ entry->GetMetadataMemoryConsumption(), entry->IsReferenced(),
+ entry->GetFrecency()));
}
}
}
diff --git a/netwerk/cache2/Dictionary.cpp b/netwerk/cache2/Dictionary.cpp
@@ -487,6 +487,13 @@ bool DictionaryCacheEntry::ParseMetadata(const char* aSrc) {
return true;
}
+void DictionaryCacheEntry::AppendMatchDest(nsACString& aDest) const {
+ for (auto& dest : mMatchDest) {
+ aDest.Append(dom::GetEnumString(dest));
+ aDest.Append(" ");
+ }
+}
+
//-----------------------------------------------------------------------------
// nsIStreamListener implementation
//-----------------------------------------------------------------------------
diff --git a/netwerk/cache2/Dictionary.h b/netwerk/cache2/Dictionary.h
@@ -80,7 +80,7 @@ class DictionaryCacheEntry final : public nsICacheEntryOpenCallback,
nsresult Prefetch(nsILoadContextInfo* aLoadContextInfo, bool& aShouldSuspend,
const std::function<void()>& aFunc);
- const nsACString& GetHash() const { return mHash; }
+ const nsCString& GetHash() const { return mHash; }
bool HasHash() {
// Hard to statically check since we're called from lambdas in
@@ -160,12 +160,15 @@ class DictionaryCacheEntry final : public nsICacheEntryOpenCallback,
mURI = aOther->mURI;
mPattern = aOther->mPattern;
mId = aOther->mId;
- // XXX match-dest
- // XXX type
+ mMatchDest = aOther->mMatchDest;
+ // XXX mType = aOther->mType;
}
void UnblockAddEntry(DictionaryOrigin* aOrigin);
+ const nsCString& GetPattern() const { return mPattern; }
+ void AppendMatchDest(nsACString& aDest) const;
+
private:
// URI (without ref) for the dictionary
nsCString mURI;
@@ -174,7 +177,7 @@ class DictionaryCacheEntry final : public nsICacheEntryOpenCallback,
nsCString mPattern;
nsCString mId; // max length 1024
- nsTArray<dom::RequestDestination> mMatchDest;
+ CopyableTArray<dom::RequestDestination> mMatchDest;
// dcb and dcz use type 'raw'. We're allowed to ignore types we don't
// understand, so we can fail to record a dictionary with type != 'raw'
// nsCString mType;
diff --git a/netwerk/protocol/about/nsAboutCacheEntry.cpp b/netwerk/protocol/about/nsAboutCacheEntry.cpp
@@ -9,6 +9,7 @@
#include "CacheFileUtils.h"
#include "CacheObserver.h"
+#include "Dictionary.h"
#include "mozilla/Sprintf.h"
#include "nsAboutCache.h"
#include "nsAboutProtocolUtils.h"
@@ -489,6 +490,17 @@ nsAboutCacheEntry::Channel::OnMetaDataElement(char const* key,
mBuffer->AppendLiteral(
":</th>\n"
" <td>");
+ if (mEnhanceId.EqualsLiteral("dict:")) {
+ RefPtr<DictionaryCacheEntry> dict = new DictionaryCacheEntry("temp");
+ dict->ParseMetadata(value);
+ nsAppendEscapedHTML(
+ nsPrintfCString(
+ "Hash: %s\nPattern: %s\nId: %s\nMatch-Id: ", dict->GetHash().get(),
+ dict->GetPattern().get(), dict->GetId().get()),
+ *mBuffer);
+ dict->AppendMatchDest(*mBuffer);
+ mBuffer->AppendLiteral("\n");
+ }
nsAppendEscapedHTML(nsDependentCString(value), *mBuffer);
mBuffer->AppendLiteral(
"</td>\n"