Bug 1806709 - Part 2: Clean up some trivial nsIPrincipal helper methods from nsIGlobalObject, r=asuth

These methods only existed because nsIGlobalObject::PrincipalOrNull was not
available off-main-thread, so can now be removed.

Depends on D165198

Differential Revision: https://phabricator.services.mozilla.com/D165199
This commit is contained in:
Nika Layzell
2022-12-21 15:53:22 +00:00
parent 26bdf63600
commit 8c037ef668
12 changed files with 5 additions and 53 deletions

View File

@@ -1647,13 +1647,6 @@ FontFaceSet* nsGlobalWindowInner::Fonts() {
return nullptr;
}
uint32_t nsGlobalWindowInner::GetPrincipalHashValue() const {
if (mDoc) {
return mDoc->NodePrincipal()->GetHashValue();
}
return 0;
}
mozilla::Result<mozilla::ipc::PrincipalInfo, nsresult>
nsGlobalWindowInner::GetStorageKey() {
MOZ_ASSERT(NS_IsMainThread());

View File

@@ -248,7 +248,6 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
// nsIGlobalObject
bool ShouldResistFingerprinting() const final;
uint32_t GetPrincipalHashValue() const final;
mozilla::OriginTrials Trials() const final;
mozilla::dom::FontFaceSet* Fonts() final;

View File

@@ -1672,13 +1672,6 @@ bool nsGlobalWindowOuter::ShouldResistFingerprinting() const {
"to make an informed RFP choice, so we fall back to the global pref");
}
uint32_t nsGlobalWindowOuter::GetPrincipalHashValue() const {
if (mDoc) {
return mDoc->NodePrincipal()->GetHashValue();
}
return 0;
}
OriginTrials nsGlobalWindowOuter::Trials() const {
return mInnerWindow ? nsGlobalWindowInner::Cast(mInnerWindow)->Trials()
: OriginTrials();

View File

@@ -234,7 +234,6 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
// nsIGlobalObject
bool ShouldResistFingerprinting() const final;
uint32_t GetPrincipalHashValue() const final;
mozilla::OriginTrials Trials() const final;
mozilla::dom::FontFaceSet* Fonts() final;

View File

@@ -394,12 +394,8 @@ mozilla::Result<bool, nsresult> nsIGlobalObject::HasEqualStorageKey(
return mozilla::ipc::StorageKeysEqual(storageKey, aStorageKey);
}
bool nsIGlobalObject::IsSystemPrincipal() const {
return PrincipalOrNull()->IsSystemPrincipal();
}
RTPCallerType nsIGlobalObject::GetRTPCallerType() const {
if (IsSystemPrincipal()) {
if (PrincipalOrNull()->IsSystemPrincipal()) {
return RTPCallerType::SystemPrincipal;
}

View File

@@ -258,12 +258,6 @@ class nsIGlobalObject : public nsISupports,
RTPCallerType GetRTPCallerType() const;
/**
* Threadsafe way to get nsIPrincipal::GetHashValue for the associated
* principal.
*/
virtual uint32_t GetPrincipalHashValue() const { return 0; }
/**
* Get the module loader to use for this global, if any. By default this
* returns null.
@@ -284,8 +278,6 @@ class nsIGlobalObject : public nsISupports,
protected:
virtual ~nsIGlobalObject();
virtual bool IsSystemPrincipal() const;
void StartDying() { mIsDying = true; }
void StartForbiddingScript() { mIsScriptForbidden = true; }

View File

@@ -5678,7 +5678,10 @@ uint32_t ClientWebGLContext::GetPrincipalHashValue() const {
if (mOffscreenCanvas) {
nsIGlobalObject* global = mOffscreenCanvas->GetOwnerGlobal();
if (global) {
return global->GetPrincipalHashValue();
nsIPrincipal* principal = global->PrincipalOrNull();
if (principal) {
return principal->GetHashValue();
}
}
}
return 0;

View File

@@ -772,10 +772,6 @@ class WorkerPrivate final
return *mLoadInfo.mPartitionedPrincipalInfo;
}
uint32_t GetPrincipalHashValue() const {
return GetPrincipal()->GetHashValue();
}
const mozilla::ipc::PrincipalInfo& GetEffectiveStoragePrincipalInfo() const;
already_AddRefed<nsIChannel> ForgetWorkerChannel() {

View File

@@ -275,15 +275,6 @@ bool WorkerGlobalScopeBase::ShouldResistFingerprinting() const {
return mShouldResistFingerprinting;
}
bool WorkerGlobalScopeBase::IsSystemPrincipal() const {
return mWorkerPrivate->UsesSystemPrincipal();
}
uint32_t WorkerGlobalScopeBase::GetPrincipalHashValue() const {
AssertIsOnWorkerThread();
return mWorkerPrivate->GetPrincipalHashValue();
}
OriginTrials WorkerGlobalScopeBase::Trials() const {
AssertIsOnWorkerThread();
return mWorkerPrivate->Trials();

View File

@@ -120,8 +120,6 @@ class WorkerGlobalScopeBase : public DOMEventTargetHelper,
bool ShouldResistFingerprinting() const final;
uint32_t GetPrincipalHashValue() const final;
OriginTrials Trials() const final;
StorageAccess GetStorageAccess() final;
@@ -174,8 +172,6 @@ class WorkerGlobalScopeBase : public DOMEventTargetHelper,
protected:
~WorkerGlobalScopeBase();
bool IsSystemPrincipal() const final;
CheckedUnsafePtr<WorkerPrivate> mWorkerPrivate;
void AssertIsOnWorkerThread() const {

View File

@@ -76,10 +76,6 @@ bool WorkletGlobalScope::ShouldResistFingerprinting() const {
return mImpl->ShouldResistFingerprinting();
}
bool WorkletGlobalScope::IsSystemPrincipal() const {
return mImpl->IsSystemPrincipal();
}
void WorkletGlobalScope::Dump(const Optional<nsAString>& aString) const {
WorkletThread::AssertIsOnWorkletThread();

View File

@@ -73,8 +73,6 @@ class WorkletGlobalScope : public nsIGlobalObject, public nsWrapperCache {
protected:
~WorkletGlobalScope();
bool IsSystemPrincipal() const override;
const RefPtr<WorkletImpl> mImpl;
private: