зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1356334: Part 1 - Add helpers for safely casting principals without COM overhead. r=bholley
MozReview-Commit-ID: EOtK17WiLZl --HG-- extra : rebase_source : ac4a18a377d513d276df24f7e9e25903bc437084
This commit is contained in:
Родитель
6fe60db96c
Коммит
c22f3ee673
|
@ -40,6 +40,19 @@ public:
|
|||
|
||||
explicit BasePrincipal(PrincipalKind aKind);
|
||||
|
||||
template<typename T>
|
||||
bool Is() const
|
||||
{
|
||||
return mKind == T::Kind();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* As()
|
||||
{
|
||||
MOZ_ASSERT(Is<T>());
|
||||
return static_cast<T*>(this);
|
||||
}
|
||||
|
||||
enum DocumentDomainConsideration { DontConsiderDocumentDomain, ConsiderDocumentDomain};
|
||||
bool Subsumes(nsIPrincipal* aOther, DocumentDomainConsideration aConsideration);
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ public:
|
|||
|
||||
ContentPrincipal();
|
||||
|
||||
static PrincipalKind Kind() { return eCodebasePrincipal; }
|
||||
|
||||
// Init() must be called before the principal is in a usable state.
|
||||
nsresult Init(nsIURI* aCodebase,
|
||||
const mozilla::OriginAttributes& aOriginAttributes,
|
||||
|
|
|
@ -20,6 +20,8 @@ public:
|
|||
Create(nsTArray<nsCOMPtr<nsIPrincipal>>& aWhiteList,
|
||||
const mozilla::OriginAttributes& aAttrs);
|
||||
|
||||
static PrincipalKind Kind() { return eExpandedPrincipal; }
|
||||
|
||||
NS_DECL_NSIEXPANDEDPRINCIPAL
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static PrincipalKind Kind() { return eNullPrincipal; }
|
||||
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
||||
|
|
|
@ -30,6 +30,8 @@ class SystemPrincipal final : public mozilla::BasePrincipal
|
|||
public:
|
||||
static already_AddRefed<SystemPrincipal> Create();
|
||||
|
||||
static PrincipalKind Kind() { return eSystemPrincipal; }
|
||||
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
||||
NS_IMETHOD GetHashValue(uint32_t* aHashValue) override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче