Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM PushManager.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_PUSHMANAGERBINDING_H_
#define DOM_PUSHMANAGERBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "js/Value.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/CallbackInterface.h"
#include "mozilla/dom/FakeString.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/dom/TypedArray.h"
#include "mozilla/dom/UnionMember.h"
#include "nsWeakReference.h"
namespace mozilla {
namespace dom {
class ArrayBufferViewOrArrayBufferOrString;
struct NativePropertyHooks;
class OwningArrayBufferViewOrArrayBufferOrString;
class Promise;
class ProtoAndIfaceCache;
class PushManager;
class PushManagerImpl;
struct PushManagerImplAtoms;
struct PushSubscriptionOptionsInit;
struct PushSubscriptionOptionsInitAtoms;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
class ArrayBufferViewOrArrayBufferOrString : public AllUnionBase,
public UnionWithTypedArraysBase
{
public:
using ApplyToTypedArrays = binding_detail::ApplyToTypedArraysHelper<ArrayBufferViewOrArrayBufferOrString, true, ArrayBufferView, ArrayBuffer>;
private:
enum TypeOrUninit
{
eUninitialized,
eArrayBufferView,
eArrayBuffer,
eString
};
public:
enum class Type
{
eArrayBufferView = TypeOrUninit::eArrayBufferView,
eArrayBuffer = TypeOrUninit::eArrayBuffer,
eString = TypeOrUninit::eString
};
private:
union Value
{
UnionMember<RootedSpiderMonkeyInterface<ArrayBufferView> > mArrayBufferView;
UnionMember<RootedSpiderMonkeyInterface<ArrayBuffer> > mArrayBuffer;
UnionMember<binding_detail::FakeString<char16_t> > mString;
};
TypeOrUninit mType;
Value mValue;
ArrayBufferViewOrArrayBufferOrString(const ArrayBufferViewOrArrayBufferOrString&) = delete;
ArrayBufferViewOrArrayBufferOrString& operator=(const ArrayBufferViewOrArrayBufferOrString&) = delete;
public:
explicit inline ArrayBufferViewOrArrayBufferOrString()
: mType(eUninitialized)
{
}
inline ~ArrayBufferViewOrArrayBufferOrString()
{
Uninit();
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<ArrayBufferView>&
RawSetAsArrayBufferView(JSContext* cx)
{
if (mType == eArrayBufferView) {
return mValue.mArrayBufferView.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eArrayBufferView;
return mValue.mArrayBufferView.SetValue(cx);
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<ArrayBufferView>&
SetAsArrayBufferView(JSContext* cx)
{
if (mType == eArrayBufferView) {
return mValue.mArrayBufferView.Value();
}
Uninit();
mType = eArrayBufferView;
return mValue.mArrayBufferView.SetValue(cx);
}
inline bool
IsArrayBufferView() const
{
return mType == eArrayBufferView;
}
inline RootedSpiderMonkeyInterface<ArrayBufferView>&
GetAsArrayBufferView()
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
return mValue.mArrayBufferView.Value();
}
inline ArrayBufferView const &
GetAsArrayBufferView() const
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
return mValue.mArrayBufferView.Value();
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<ArrayBuffer>&
RawSetAsArrayBuffer(JSContext* cx)
{
if (mType == eArrayBuffer) {
return mValue.mArrayBuffer.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eArrayBuffer;
return mValue.mArrayBuffer.SetValue(cx);
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<ArrayBuffer>&
SetAsArrayBuffer(JSContext* cx)
{
if (mType == eArrayBuffer) {
return mValue.mArrayBuffer.Value();
}
Uninit();
mType = eArrayBuffer;
return mValue.mArrayBuffer.SetValue(cx);
}
inline bool
IsArrayBuffer() const
{
return mType == eArrayBuffer;
}
inline RootedSpiderMonkeyInterface<ArrayBuffer>&
GetAsArrayBuffer()
{
MOZ_RELEASE_ASSERT(IsArrayBuffer(), "Wrong type!");
return mValue.mArrayBuffer.Value();
}
inline ArrayBuffer const &
GetAsArrayBuffer() const
{
MOZ_RELEASE_ASSERT(IsArrayBuffer(), "Wrong type!");
return mValue.mArrayBuffer.Value();
}
[[nodiscard]] inline binding_detail::FakeString<char16_t>&
RawSetAsString()
{
if (mType == eString) {
return mValue.mString.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eString;
return mValue.mString.SetValue();
}
[[nodiscard]] inline binding_detail::FakeString<char16_t>&
SetAsString()
{
if (mType == eString) {
return mValue.mString.Value();
}
Uninit();
mType = eString;
return mValue.mString.SetValue();
}
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsString().AssignLiteral(aData);
}
inline bool
IsString() const
{
return mType == eString;
}
inline binding_detail::FakeString<char16_t>&
GetAsString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
inline const nsAString&
GetAsString() const
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
inline void
Uninit()
{
switch (mType) {
case eUninitialized: {
break;
}
case eArrayBufferView: {
DestroyArrayBufferView();
break;
}
case eArrayBuffer: {
DestroyArrayBuffer();
break;
}
case eString: {
DestroyString();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToArrayBufferView(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToArrayBufferView(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyArrayBufferView()
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
mValue.mArrayBufferView.Destroy();
mType = eUninitialized;
}
bool
TrySetToArrayBuffer(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToArrayBuffer(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyArrayBuffer()
{
MOZ_RELEASE_ASSERT(IsArrayBuffer(), "Wrong type!");
mValue.mArrayBuffer.Destroy();
mType = eUninitialized;
}
bool
TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
mValue.mString.Destroy();
mType = eUninitialized;
}
};
class OwningArrayBufferViewOrArrayBufferOrString : public AllOwningUnionBase,
public UnionWithTypedArraysBase
{
public:
using ApplyToTypedArrays = binding_detail::ApplyToTypedArraysHelper<OwningArrayBufferViewOrArrayBufferOrString, true, ArrayBufferView, ArrayBuffer>;
private:
enum TypeOrUninit
{
eUninitialized,
eArrayBufferView,
eArrayBuffer,
eString
};
public:
enum class Type
{
eArrayBufferView = TypeOrUninit::eArrayBufferView,
eArrayBuffer = TypeOrUninit::eArrayBuffer,
eString = TypeOrUninit::eString
};
private:
union Value
{
UnionMember<ArrayBufferView > mArrayBufferView;
UnionMember<ArrayBuffer > mArrayBuffer;
UnionMember<nsString > mString;
};
TypeOrUninit mType;
Value mValue;
OwningArrayBufferViewOrArrayBufferOrString(const OwningArrayBufferViewOrArrayBufferOrString&) = delete;
OwningArrayBufferViewOrArrayBufferOrString& operator=(const OwningArrayBufferViewOrArrayBufferOrString&) = delete;
public:
explicit inline OwningArrayBufferViewOrArrayBufferOrString()
: mType(eUninitialized)
{
}
OwningArrayBufferViewOrArrayBufferOrString(OwningArrayBufferViewOrArrayBufferOrString&& aOther);
inline ~OwningArrayBufferViewOrArrayBufferOrString()
{
Uninit();
}
[[nodiscard]] ArrayBufferView&
RawSetAsArrayBufferView();
[[nodiscard]] ArrayBufferView&
SetAsArrayBufferView();
inline bool
IsArrayBufferView() const
{
return mType == eArrayBufferView;
}
inline ArrayBufferView&
GetAsArrayBufferView()
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
return mValue.mArrayBufferView.Value();
}
inline ArrayBufferView const &
GetAsArrayBufferView() const
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
return mValue.mArrayBufferView.Value();
}
[[nodiscard]] ArrayBuffer&
RawSetAsArrayBuffer();
[[nodiscard]] ArrayBuffer&
SetAsArrayBuffer();
inline bool
IsArrayBuffer() const
{
return mType == eArrayBuffer;
}
inline ArrayBuffer&
GetAsArrayBuffer()
{
MOZ_RELEASE_ASSERT(IsArrayBuffer(), "Wrong type!");
return mValue.mArrayBuffer.Value();
}
inline ArrayBuffer const &
GetAsArrayBuffer() const
{
MOZ_RELEASE_ASSERT(IsArrayBuffer(), "Wrong type!");
return mValue.mArrayBuffer.Value();
}
[[nodiscard]] nsString&
RawSetAsString();
[[nodiscard]] nsString&
SetAsString();
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsString().AssignLiteral(aData);
}
inline bool
IsString() const
{
return mType == eString;
}
inline nsString&
GetAsString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
inline nsString const &
GetAsString() const
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
Uninit();
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
void
TraceUnion(JSTracer* trc);
OwningArrayBufferViewOrArrayBufferOrString&
operator=(OwningArrayBufferViewOrArrayBufferOrString&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
private:
bool
TrySetToArrayBufferView(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToArrayBufferView(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyArrayBufferView();
bool
TrySetToArrayBuffer(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToArrayBuffer(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyArrayBuffer();
bool
TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyString();
};
struct PushSubscriptionOptionsInit : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Nullable<OwningArrayBufferViewOrArrayBufferOrString > mApplicationServerKey;
PushSubscriptionOptionsInit();
explicit inline PushSubscriptionOptionsInit(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
PushSubscriptionOptionsInit(PushSubscriptionOptionsInit&& aOther) = default;
private:
PushSubscriptionOptionsInit(const PushSubscriptionOptionsInit&) = delete;
PushSubscriptionOptionsInit& operator=(const PushSubscriptionOptionsInit&) = delete;
static bool
InitIds(JSContext* cx, PushSubscriptionOptionsInitAtoms* atomsCache);
public:
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
};
namespace binding_detail {
struct FastPushSubscriptionOptionsInit : public PushSubscriptionOptionsInit
{
inline FastPushSubscriptionOptionsInit()
: PushSubscriptionOptionsInit(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace PushManager_Binding {
typedef mozilla::dom::PushManager NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::PushManager* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx)
{
/* Get the interface prototype object for this class. This will create the
object as needed. */
return GetPerInterfaceObjectHandle(aCx, prototypes::id::PushManager,
&CreateInterfaceObjects,
/* aDefineOnGlobal = */ true);
}
inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true)
{
/* Get the interface object for this class. This will create the object as
needed. */
return GetPerInterfaceObjectHandle(aCx, constructors::id::PushManager,
&CreateInterfaceObjects,
aDefineOnGlobal);
}
JSObject*
GetConstructorObject(JSContext* aCx);
} // namespace PushManager_Binding
namespace PushManagerImpl_Binding {
typedef mozilla::dom::PushManagerImpl NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::PushManagerImpl* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx)
{
/* Get the interface prototype object for this class. This will create the
object as needed. */
return GetPerInterfaceObjectHandle(aCx, prototypes::id::PushManagerImpl,
&CreateInterfaceObjects,
/* aDefineOnGlobal = */ true);
}
inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true)
{
/* Get the interface object for this class. This will create the object as
needed. */
return GetPerInterfaceObjectHandle(aCx, constructors::id::PushManagerImpl,
&CreateInterfaceObjects,
aDefineOnGlobal);
}
JSObject*
GetConstructorObject(JSContext* aCx);
} // namespace PushManagerImpl_Binding
class PushManagerImplJSImpl : public CallbackInterface
{
public:
explicit inline PushManagerImplJSImpl(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackInterface(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
}
explicit inline PushManagerImplJSImpl(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackInterface(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
explicit inline PushManagerImplJSImpl(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackInterface(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
}
already_AddRefed<Promise> Subscribe(const PushSubscriptionOptionsInit& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
already_AddRefed<Promise> GetSubscription(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
already_AddRefed<Promise> PermissionState(const PushSubscriptionOptionsInit& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
void __Init(const nsAString& scope, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
inline bool
operator==(const PushManagerImplJSImpl& aOther) const
{
return CallbackInterface::operator==(aOther);
}
private:
static bool
InitIds(JSContext* cx, PushManagerImplAtoms* atomsCache);
};
class PushManagerImpl final : public nsSupportsWeakReference,
public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(PushManagerImpl)
private:
RefPtr<PushManagerImplJSImpl> mImpl;
nsCOMPtr<nsIGlobalObject> mParent;
public:
PushManagerImpl(JS::Handle<JSObject*> aJSImplObject, JS::Handle<JSObject*> aJSImplGlobal, nsIGlobalObject* aParent);
private:
~PushManagerImpl();
public:
nsISupports* GetParentObject() const;
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
static already_AddRefed<PushManagerImpl> Constructor(const GlobalObject& global, JSContext* cx, const nsAString& scope, ErrorResult& aRv, JS::Handle<JSObject*> aGivenProto = nullptr);
// Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
already_AddRefed<Promise> Subscribe(const PushSubscriptionOptionsInit& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
// Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
already_AddRefed<Promise> GetSubscription(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
// Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
already_AddRefed<Promise> PermissionState(const PushSubscriptionOptionsInit& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
static bool
_Create(JSContext* cx, unsigned argc, JS::Value* vp);
};
} // namespace mozilla::dom
#endif // DOM_PUSHMANAGERBINDING_H_