mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1600963 - reduce boilerplate for serialized keys in principals; r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D55686 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
874e5c0f9e
commit
3c6e6ca1c9
@ -256,6 +256,16 @@ class BasePrincipal : public nsJSPrincipals {
|
||||
void FinishInit(BasePrincipal* aOther,
|
||||
const OriginAttributes& aOriginAttributes);
|
||||
|
||||
// KeyValT holds a principal subtype-specific key value and the associated
|
||||
// parsed value after JSON parsing.
|
||||
template<typename SerializedKey>
|
||||
struct KeyValT
|
||||
{
|
||||
bool valueWasSerialized;
|
||||
nsCString value;
|
||||
SerializedKey key;
|
||||
};
|
||||
|
||||
private:
|
||||
static already_AddRefed<BasePrincipal> CreateContentPrincipal(
|
||||
nsIURI* aURI, const OriginAttributes& aAttrs,
|
||||
|
@ -60,14 +60,8 @@ class ContentPrincipal final : public BasePrincipal {
|
||||
virtual nsresult PopulateJSONObject(Json::Value& aObject) override;
|
||||
// Serializable keys are the valid enum fields the serialization supports
|
||||
enum SerializableKeys { eURI = 0, eDomain, eSuffix, eMax = eSuffix };
|
||||
// KeyVal is a lightweight storage that passes
|
||||
// SerializableKeys and values after JSON parsing in the BasePrincipal to
|
||||
// FromProperties
|
||||
struct KeyVal {
|
||||
bool valueWasSerialized;
|
||||
nsCString value;
|
||||
SerializableKeys key;
|
||||
};
|
||||
typedef mozilla::BasePrincipal::KeyValT<SerializableKeys> KeyVal;
|
||||
|
||||
static already_AddRefed<BasePrincipal> FromProperties(
|
||||
nsTArray<ContentPrincipal::KeyVal>& aFields);
|
||||
|
||||
|
@ -63,14 +63,8 @@ class ExpandedPrincipal : public nsIExpandedPrincipal,
|
||||
virtual nsresult PopulateJSONObject(Json::Value& aObject) override;
|
||||
// Serializable keys are the valid enum fields the serialization supports
|
||||
enum SerializableKeys { eSpecs = 0, eSuffix, eMax = eSuffix };
|
||||
// KeyVal is a lightweight storage that passes
|
||||
// SerializableKeys and values after JSON parsing in the BasePrincipal to
|
||||
// FromProperties
|
||||
struct KeyVal {
|
||||
bool valueWasSerialized;
|
||||
nsCString value;
|
||||
SerializableKeys key;
|
||||
};
|
||||
typedef mozilla::BasePrincipal::KeyValT<SerializableKeys> KeyVal;
|
||||
|
||||
static already_AddRefed<BasePrincipal> FromProperties(
|
||||
nsTArray<ExpandedPrincipal::KeyVal>& aFields);
|
||||
|
||||
|
@ -87,14 +87,8 @@ class NullPrincipal final : public BasePrincipal {
|
||||
|
||||
// Serializable keys are the valid enum fields the serialization supports
|
||||
enum SerializableKeys { eSpec = 0, eSuffix, eMax = eSuffix };
|
||||
// KeyVal is a lightweight storage that passes
|
||||
// SerializableKeys and values after JSON parsing in the BasePrincipal to
|
||||
// FromProperties
|
||||
struct KeyVal {
|
||||
bool valueWasSerialized;
|
||||
nsCString value;
|
||||
SerializableKeys key;
|
||||
};
|
||||
typedef mozilla::BasePrincipal::KeyValT<SerializableKeys> KeyVal;
|
||||
|
||||
static already_AddRefed<BasePrincipal> FromProperties(
|
||||
nsTArray<NullPrincipal::KeyVal>& aFields);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user