Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM ServiceWorkerContainer.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_SERVICEWORKERCONTAINERBINDING_H_
#define DOM_SERVICEWORKERCONTAINERBINDING_H_
#include "ServiceWorkerRegistrationBinding.h"
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/FakeString.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/UnionMember.h"
namespace mozilla {
namespace dom {
struct NativePropertyHooks;
class OwningServiceWorkerRegistrationOrUndefined;
class ProtoAndIfaceCache;
struct RegistrationOptionsAtoms;
class ServiceWorkerContainer;
class ServiceWorkerRegistration;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningServiceWorkerRegistrationOrUndefined& aUnion, const char* aName, uint32_t aFlags = 0);
void
ImplCycleCollectionUnlink(OwningServiceWorkerRegistrationOrUndefined& aUnion);
struct RegistrationOptions : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mScope;
MOZ_INIT_OUTSIDE_CTOR ServiceWorkerUpdateViaCache mUpdateViaCache;
RegistrationOptions();
explicit inline RegistrationOptions(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
RegistrationOptions(RegistrationOptions&& aOther) = default;
explicit inline RegistrationOptions(const RegistrationOptions& aOther)
{
*this = aOther;
}
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);
void
TraceDictionary(JSTracer* trc);
RegistrationOptions&
operator=(const RegistrationOptions& aOther);
private:
static bool
InitIds(JSContext* cx, RegistrationOptionsAtoms* atomsCache);
};
namespace binding_detail {
struct FastRegistrationOptions : public RegistrationOptions
{
inline FastRegistrationOptions()
: RegistrationOptions(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
class ServiceWorkerRegistrationOrUndefined : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eServiceWorkerRegistration,
eUndefined
};
public:
enum class Type
{
eServiceWorkerRegistration = TypeOrUninit::eServiceWorkerRegistration,
eUndefined = TypeOrUninit::eUndefined
};
private:
union Value
{
UnionMember<NonNull<mozilla::dom::ServiceWorkerRegistration> > mServiceWorkerRegistration;
};
TypeOrUninit mType;
Value mValue;
ServiceWorkerRegistrationOrUndefined(const ServiceWorkerRegistrationOrUndefined&) = delete;
ServiceWorkerRegistrationOrUndefined& operator=(const ServiceWorkerRegistrationOrUndefined&) = delete;
public:
explicit inline ServiceWorkerRegistrationOrUndefined()
: mType(eUninitialized)
{
}
inline ~ServiceWorkerRegistrationOrUndefined()
{
Uninit();
}
[[nodiscard]] inline NonNull<mozilla::dom::ServiceWorkerRegistration>&
RawSetAsServiceWorkerRegistration()
{
if (mType == eServiceWorkerRegistration) {
return mValue.mServiceWorkerRegistration.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eServiceWorkerRegistration;
return mValue.mServiceWorkerRegistration.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::ServiceWorkerRegistration>&
SetAsServiceWorkerRegistration()
{
if (mType == eServiceWorkerRegistration) {
return mValue.mServiceWorkerRegistration.Value();
}
Uninit();
mType = eServiceWorkerRegistration;
return mValue.mServiceWorkerRegistration.SetValue();
}
inline bool
IsServiceWorkerRegistration() const
{
return mType == eServiceWorkerRegistration;
}
inline NonNull<mozilla::dom::ServiceWorkerRegistration>&
GetAsServiceWorkerRegistration()
{
MOZ_RELEASE_ASSERT(IsServiceWorkerRegistration(), "Wrong type!");
return mValue.mServiceWorkerRegistration.Value();
}
inline mozilla::dom::ServiceWorkerRegistration&
GetAsServiceWorkerRegistration() const
{
MOZ_RELEASE_ASSERT(IsServiceWorkerRegistration(), "Wrong type!");
return mValue.mServiceWorkerRegistration.Value();
}
inline bool
IsUndefined() const
{
return mType == eUndefined;
}
inline void
SetUndefined()
{
Uninit();
mType = eUndefined;
}
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 eServiceWorkerRegistration: {
DestroyServiceWorkerRegistration();
break;
}
case eUndefined: {
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToServiceWorkerRegistration(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToServiceWorkerRegistration(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyServiceWorkerRegistration()
{
MOZ_RELEASE_ASSERT(IsServiceWorkerRegistration(), "Wrong type!");
mValue.mServiceWorkerRegistration.Destroy();
mType = eUninitialized;
}
};
class OwningServiceWorkerRegistrationOrUndefined : public AllOwningUnionBase
{
friend void ImplCycleCollectionUnlink(OwningServiceWorkerRegistrationOrUndefined& aUnion);
enum TypeOrUninit
{
eUninitialized,
eServiceWorkerRegistration,
eUndefined
};
public:
enum class Type
{
eServiceWorkerRegistration = TypeOrUninit::eServiceWorkerRegistration,
eUndefined = TypeOrUninit::eUndefined
};
private:
union Value
{
UnionMember<OwningNonNull<mozilla::dom::ServiceWorkerRegistration> > mServiceWorkerRegistration;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningServiceWorkerRegistrationOrUndefined()
: mType(eUninitialized)
{
}
OwningServiceWorkerRegistrationOrUndefined(OwningServiceWorkerRegistrationOrUndefined&& aOther);
explicit inline OwningServiceWorkerRegistrationOrUndefined(const OwningServiceWorkerRegistrationOrUndefined& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningServiceWorkerRegistrationOrUndefined()
{
Uninit();
}
[[nodiscard]] OwningNonNull<mozilla::dom::ServiceWorkerRegistration>&
RawSetAsServiceWorkerRegistration();
[[nodiscard]] OwningNonNull<mozilla::dom::ServiceWorkerRegistration>&
SetAsServiceWorkerRegistration();
inline bool
IsServiceWorkerRegistration() const
{
return mType == eServiceWorkerRegistration;
}
inline OwningNonNull<mozilla::dom::ServiceWorkerRegistration>&
GetAsServiceWorkerRegistration()
{
MOZ_RELEASE_ASSERT(IsServiceWorkerRegistration(), "Wrong type!");
return mValue.mServiceWorkerRegistration.Value();
}
inline OwningNonNull<mozilla::dom::ServiceWorkerRegistration> const &
GetAsServiceWorkerRegistration() const
{
MOZ_RELEASE_ASSERT(IsServiceWorkerRegistration(), "Wrong type!");
return mValue.mServiceWorkerRegistration.Value();
}
inline bool
IsUndefined() const
{
return mType == eUndefined;
}
inline void
SetUndefined()
{
Uninit();
mType = eUndefined;
}
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;
OwningServiceWorkerRegistrationOrUndefined&
operator=(OwningServiceWorkerRegistrationOrUndefined&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningServiceWorkerRegistrationOrUndefined&
operator=(const OwningServiceWorkerRegistrationOrUndefined& aOther);
private:
bool
TrySetToServiceWorkerRegistration(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToServiceWorkerRegistration(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyServiceWorkerRegistration();
};
namespace ServiceWorkerContainer_Binding {
typedef mozilla::dom::ServiceWorkerContainer NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::ServiceWorkerContainer* 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, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx);
inline bool CreateAndDefineOnGlobal(JSContext* aCx)
{
// Get the interface or namespace object for this class. This will
// create the object as needed and always define the properties for
// it on the global. The caller should make sure the interface or
// namespace is exposed on the global before calling this.
return GetPerInterfaceObjectHandle(aCx, constructors::id::ServiceWorkerContainer,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace ServiceWorkerContainer_Binding
} // namespace mozilla::dom
#endif // DOM_SERVICEWORKERCONTAINERBINDING_H_