Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM FetchObserver.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_FETCHOBSERVERBINDING_H_
#define DOM_FETCHOBSERVERBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/EnumTypeTraits.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/Span.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/CallbackInterface.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/ToJSValue.h"
namespace mozilla {
namespace dom {
class FetchObserver;
struct NativePropertyHooks;
class ObserverCallback;
struct ObserverCallbackAtoms;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
enum class FetchState : uint8_t {
Requesting,
Responding,
Aborted,
Errored,
Complete,
};
namespace binding_detail {
template <> struct EnumStrings<FetchState> {
static const nsLiteralCString Values[5];
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, FetchState aArgument, JS::MutableHandle<JS::Value> aValue);
namespace FetchObserver_Binding {
typedef mozilla::dom::FetchObserver NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::FetchObserver* 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::FetchObserver,
&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::FetchObserver,
&CreateInterfaceObjects,
aDefineOnGlobal);
}
JSObject*
GetConstructorObject(JSContext* aCx);
} // namespace FetchObserver_Binding
class ObserverCallback : public CallbackInterface
{
public:
explicit inline ObserverCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackInterface(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
}
explicit inline ObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackInterface(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
explicit inline ObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackInterface(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
}
template <typename T>
inline void
HandleEvent(const T& thisVal, FetchObserver& observer, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "ObserverCallback.handleEvent";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
JS::Rooted<JS::Value> thisValJS(s.GetContext());
if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
return HandleEvent(s.GetCallContext(), thisValJS, observer, aRv);
}
inline void
HandleEvent(FetchObserver& observer, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "ObserverCallback.handleEvent";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
return HandleEvent(s.GetCallContext(), JS::UndefinedHandleValue, observer, aRv);
}
template <typename T>
inline void
HandleEvent(const T& thisVal, FetchObserver& observer, const char* aExecutionReason = nullptr)
{
return HandleEvent(thisVal, observer, IgnoreErrors(), aExecutionReason);
}
inline void
HandleEvent(FetchObserver& observer, const char* aExecutionReason = nullptr)
{
return HandleEvent(observer, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
}
inline bool
operator==(const ObserverCallback& aOther) const
{
return CallbackInterface::operator==(aOther);
}
private:
void HandleEvent(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, FetchObserver& observer, ErrorResult& aRv);
static bool
InitIds(JSContext* cx, ObserverCallbackAtoms* atomsCache);
};
namespace binding_detail {
class FastObserverCallback : public ObserverCallback
{
public:
explicit inline FastObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
: ObserverCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
inline void
Trace(JSTracer* aTracer)
{
ObserverCallback::Trace(aTracer);
}
inline void
FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
{
ObserverCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
}
};
} // namespace binding_detail
} // namespace dom
template <>
struct MaxContiguousEnumValue<dom::FetchState>
{
static constexpr dom::FetchState value = dom::FetchState::Complete;
static_assert(static_cast<uint8_t>(dom::FetchState::Requesting) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(mozilla::ArrayLength(dom::binding_detail::EnumStrings<dom::FetchState>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
} // namespace mozilla
#endif // DOM_FETCHOBSERVERBINDING_H_