Bug 1639807 - Isolate image cache per first-party when privacy.partition.network_state is set to true - part 1 - Rename isolation key member in ImageCacheKey, r=timhuang
Differential Revision: https://phabricator.services.mozilla.com/D76282
This commit is contained in:
@@ -10,11 +10,13 @@
|
||||
#include "mozilla/ContentBlocking.h"
|
||||
#include "mozilla/HashFunctions.h"
|
||||
#include "mozilla/StorageAccess.h"
|
||||
#include "mozilla/StoragePrincipalHelper.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/BlobURLProtocolHandler.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/ServiceWorkerManager.h"
|
||||
#include "mozilla/StaticPrefs_privacy.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
@@ -45,7 +47,7 @@ ImageCacheKey::ImageCacheKey(nsIURI* aURI, const OriginAttributes& aAttrs,
|
||||
: mURI(aURI),
|
||||
mOriginAttributes(aAttrs),
|
||||
mControlledDocument(GetSpecialCaseDocumentToken(aDocument)),
|
||||
mTopLevelBaseDomain(GetTopLevelBaseDomain(aDocument, aURI)),
|
||||
mIsolationKey(GetIsolationKey(aDocument, aURI)),
|
||||
mIsChrome(false) {
|
||||
if (mURI->SchemeIs("blob")) {
|
||||
mBlobSerial = BlobSerial(mURI);
|
||||
@@ -60,7 +62,7 @@ ImageCacheKey::ImageCacheKey(const ImageCacheKey& aOther)
|
||||
mBlobRef(aOther.mBlobRef),
|
||||
mOriginAttributes(aOther.mOriginAttributes),
|
||||
mControlledDocument(aOther.mControlledDocument),
|
||||
mTopLevelBaseDomain(aOther.mTopLevelBaseDomain),
|
||||
mIsolationKey(aOther.mIsolationKey),
|
||||
mHash(aOther.mHash),
|
||||
mIsChrome(aOther.mIsChrome) {}
|
||||
|
||||
@@ -70,7 +72,7 @@ ImageCacheKey::ImageCacheKey(ImageCacheKey&& aOther)
|
||||
mBlobRef(std::move(aOther.mBlobRef)),
|
||||
mOriginAttributes(aOther.mOriginAttributes),
|
||||
mControlledDocument(aOther.mControlledDocument),
|
||||
mTopLevelBaseDomain(aOther.mTopLevelBaseDomain),
|
||||
mIsolationKey(aOther.mIsolationKey),
|
||||
mHash(aOther.mHash),
|
||||
mIsChrome(aOther.mIsChrome) {}
|
||||
|
||||
@@ -82,8 +84,8 @@ bool ImageCacheKey::operator==(const ImageCacheKey& aOther) const {
|
||||
}
|
||||
// Don't share the image cache between two top-level documents of different
|
||||
// base domains.
|
||||
if (!mTopLevelBaseDomain.Equals(aOther.mTopLevelBaseDomain,
|
||||
nsCaseInsensitiveCStringComparator())) {
|
||||
if (!mIsolationKey.Equals(aOther.mIsolationKey,
|
||||
nsCaseInsensitiveCStringComparator())) {
|
||||
return false;
|
||||
}
|
||||
// The origin attributes always have to match.
|
||||
@@ -138,7 +140,7 @@ void ImageCacheKey::EnsureHash() const {
|
||||
hash = HashString(spec);
|
||||
}
|
||||
|
||||
hash = AddToHash(hash, HashString(suffix), HashString(mTopLevelBaseDomain),
|
||||
hash = AddToHash(hash, HashString(suffix), HashString(mIsolationKey),
|
||||
HashString(ptr));
|
||||
mHash.emplace(hash);
|
||||
}
|
||||
@@ -163,8 +165,7 @@ void* ImageCacheKey::GetSpecialCaseDocumentToken(Document* aDocument) {
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsCString ImageCacheKey::GetTopLevelBaseDomain(Document* aDocument,
|
||||
nsIURI* aURI) {
|
||||
nsCString ImageCacheKey::GetIsolationKey(Document* aDocument, nsIURI* aURI) {
|
||||
if (!aDocument || !aDocument->GetInnerWindow()) {
|
||||
return EmptyCString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user