Bug 1820280 - Don't proxy some principal destruction to the main thread. r=dshin

Drive-by, but nsIPrincipal is thread-safe now.

Differential Revision: https://phabricator.services.mozilla.com/D171642
This commit is contained in:
Emilio Cobos Álvarez 2023-03-09 10:22:35 +00:00
parent b288401947
commit 48efee8e29
3 changed files with 5 additions and 15 deletions

View File

@ -5,7 +5,6 @@
#include "gfxFontSrcPrincipal.h"
#include "nsProxyRelease.h"
#include "nsURIHashKey.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/HashFunctions.h"
@ -29,12 +28,7 @@ gfxFontSrcPrincipal::gfxFontSrcPrincipal(nsIPrincipal* aNodePrincipal,
mozilla::HashString(suffix));
}
gfxFontSrcPrincipal::~gfxFontSrcPrincipal() {
NS_ReleaseOnMainThread("gfxFontSrcPrincipal::mNodePrincipal",
mNodePrincipal.forget());
NS_ReleaseOnMainThread("gfxFontSrcPrincipal::mStoragePrincipal",
mStoragePrincipal.forget());
}
gfxFontSrcPrincipal::~gfxFontSrcPrincipal() = default;
bool gfxFontSrcPrincipal::Equals(gfxFontSrcPrincipal* aOther) {
return BasePrincipal::Cast(mStoragePrincipal)

View File

@ -20,6 +20,9 @@ class nsSimpleURI;
/**
* A wrapper for an nsIPrincipal that can be used OMT, which has cached
* information useful for the gfxUserFontSet.
*
* TODO(emilio): This has grown a bit more complex, but nsIPrincipal is now
* thread-safe, re-evaluate the existence of this class.
*/
class gfxFontSrcPrincipal {
public:
@ -28,8 +31,6 @@ class gfxFontSrcPrincipal {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(gfxFontSrcPrincipal)
nsIPrincipal* get() const { return NodePrincipal(); }
nsIPrincipal* NodePrincipal() const { return mNodePrincipal; }
nsIPrincipal* StoragePrincipal() const { return mStoragePrincipal; }

View File

@ -9,7 +9,6 @@
#include "mozilla/URLExtraData.h"
#include "mozilla/NullPrincipal.h"
#include "nsProxyRelease.h"
#include "ReferrerInfo.h"
namespace mozilla {
@ -36,11 +35,7 @@ void URLExtraData::Shutdown() {
sDummyChrome = nullptr;
}
URLExtraData::~URLExtraData() {
if (!NS_IsMainThread()) {
NS_ReleaseOnMainThread("URLExtraData::mPrincipal", mPrincipal.forget());
}
}
URLExtraData::~URLExtraData() = default;
StaticRefPtr<URLExtraData>
URLExtraData::sShared[size_t(UserAgentStyleSheetID::Count)];