Bug 1955624 - Remove now unused OriginAttributes argument to ImageCacheKey constructor. r=arai

Just drive-by cleanup, the regressing bug made these unused.

Differential Revision: https://phabricator.services.mozilla.com/D242639
This commit is contained in:
Emilio Cobos Álvarez
2025-03-23 17:11:47 +00:00
parent dc708bbcee
commit 757741e34c
3 changed files with 7 additions and 28 deletions

View File

@@ -39,7 +39,6 @@ static nsIPrincipal* GetPartitionPrincipal(Document* aDocument) {
} }
ImageCacheKey::ImageCacheKey(nsIURI* aURI, CORSMode aCORSMode, ImageCacheKey::ImageCacheKey(nsIURI* aURI, CORSMode aCORSMode,
const OriginAttributes& aAttrs,
Document* aDocument) Document* aDocument)
: mURI(aURI), : mURI(aURI),
mControlledDocument(GetSpecialCaseDocumentToken(aDocument)), mControlledDocument(GetSpecialCaseDocumentToken(aDocument)),

View File

@@ -33,7 +33,7 @@ namespace image {
*/ */
class ImageCacheKey final { class ImageCacheKey final {
public: public:
ImageCacheKey(nsIURI*, CORSMode, const OriginAttributes&, dom::Document*); ImageCacheKey(nsIURI*, CORSMode, dom::Document*);
ImageCacheKey(const ImageCacheKey& aOther); ImageCacheKey(const ImageCacheKey& aOther);
ImageCacheKey(ImageCacheKey&& aOther); ImageCacheKey(ImageCacheKey&& aOther);

View File

@@ -1607,12 +1607,8 @@ imgLoader::RemoveEntry(nsIURI* aURI, Document* aDoc) {
if (!aURI) { if (!aURI) {
return NS_OK; return NS_OK;
} }
OriginAttributes attrs;
if (aDoc) {
attrs = aDoc->NodePrincipal()->OriginAttributesRef();
}
for (auto corsMode : AllCORSModes()) { for (auto corsMode : AllCORSModes()) {
ImageCacheKey key(aURI, corsMode, attrs, aDoc); ImageCacheKey key(aURI, corsMode, aDoc);
RemoveFromCache(key); RemoveFromCache(key);
} }
return NS_OK; return NS_OK;
@@ -1623,16 +1619,8 @@ imgLoader::FindEntryProperties(nsIURI* uri, Document* aDoc,
nsIProperties** _retval) { nsIProperties** _retval) {
*_retval = nullptr; *_retval = nullptr;
OriginAttributes attrs;
if (aDoc) {
nsCOMPtr<nsIPrincipal> principal = aDoc->NodePrincipal();
if (principal) {
attrs = principal->OriginAttributesRef();
}
}
for (auto corsMode : AllCORSModes()) { for (auto corsMode : AllCORSModes()) {
ImageCacheKey key(uri, corsMode, attrs, aDoc); ImageCacheKey key(uri, corsMode, aDoc);
RefPtr<imgCacheEntry> entry; RefPtr<imgCacheEntry> entry;
if (!mCache.Get(key, getter_AddRefs(entry)) || !entry) { if (!mCache.Get(key, getter_AddRefs(entry)) || !entry) {
continue; continue;
@@ -2327,8 +2315,7 @@ static void MakeRequestStaticIfNeeded(
bool imgLoader::IsImageAvailable(nsIURI* aURI, bool imgLoader::IsImageAvailable(nsIURI* aURI,
nsIPrincipal* aTriggeringPrincipal, nsIPrincipal* aTriggeringPrincipal,
CORSMode aCORSMode, Document* aDocument) { CORSMode aCORSMode, Document* aDocument) {
ImageCacheKey key(aURI, aCORSMode, ImageCacheKey key(aURI, aCORSMode, aDocument);
aTriggeringPrincipal->OriginAttributesRef(), aDocument);
RefPtr<imgCacheEntry> entry; RefPtr<imgCacheEntry> entry;
if (!mCache.Get(key, getter_AddRefs(entry)) || !entry) { if (!mCache.Get(key, getter_AddRefs(entry)) || !entry) {
return false; return false;
@@ -2498,11 +2485,7 @@ nsresult imgLoader::LoadImage(
// XXX For now ignore aCacheKey. We will need it in the future // XXX For now ignore aCacheKey. We will need it in the future
// for correctly dealing with image load requests that are a result // for correctly dealing with image load requests that are a result
// of post data. // of post data.
OriginAttributes attrs; ImageCacheKey key(aURI, corsmode, aLoadingDocument);
if (aTriggeringPrincipal) {
attrs = aTriggeringPrincipal->OriginAttributesRef();
}
ImageCacheKey key(aURI, corsmode, attrs, aLoadingDocument);
if (mCache.Get(key, getter_AddRefs(entry)) && entry) { if (mCache.Get(key, getter_AddRefs(entry)) && entry) {
bool newChannelCreated = false; bool newChannelCreated = false;
if (ValidateEntry(entry, aURI, aInitialDocumentURI, aReferrerInfo, if (ValidateEntry(entry, aURI, aInitialDocumentURI, aReferrerInfo,
@@ -2739,11 +2722,9 @@ nsresult imgLoader::LoadImageWithChannel(nsIChannel* channel,
NS_ENSURE_TRUE(channel, NS_ERROR_FAILURE); NS_ENSURE_TRUE(channel, NS_ERROR_FAILURE);
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo(); nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
OriginAttributes attrs = loadInfo->GetOriginAttributes();
// TODO: Get a meaningful cors mode from the caller probably? // TODO: Get a meaningful cors mode from the caller probably?
const auto corsMode = CORS_NONE; const auto corsMode = CORS_NONE;
ImageCacheKey key(uri, corsMode, attrs, aLoadingDocument); ImageCacheKey key(uri, corsMode, aLoadingDocument);
nsLoadFlags requestFlags = nsIRequest::LOAD_NORMAL; nsLoadFlags requestFlags = nsIRequest::LOAD_NORMAL;
channel->GetLoadFlags(&requestFlags); channel->GetLoadFlags(&requestFlags);
@@ -2854,8 +2835,7 @@ nsresult imgLoader::LoadImageWithChannel(nsIChannel* channel,
// constructed above with the *current URI* and not the *original URI*. I'm // constructed above with the *current URI* and not the *original URI*. I'm
// pretty sure this is a bug, and it's preventing us from ever getting a // pretty sure this is a bug, and it's preventing us from ever getting a
// cache hit in LoadImageWithChannel when redirects are involved. // cache hit in LoadImageWithChannel when redirects are involved.
ImageCacheKey originalURIKey(originalURI, corsMode, attrs, ImageCacheKey originalURIKey(originalURI, corsMode, aLoadingDocument);
aLoadingDocument);
// Default to doing a principal check because we don't know who // Default to doing a principal check because we don't know who
// started that load and whether their principal ended up being // started that load and whether their principal ended up being