Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM MessageManager.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_MESSAGEMANAGERBINDING_H_
#define DOM_MESSAGEMANAGERBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/CallbackInterface.h"
#include "mozilla/dom/MessagePort.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsFrameLoader.h"
#include "nsISupports.h"
class nsFrameLoader;
class nsISupports;
namespace mozilla {
namespace dom {
class ChildProcessMessageManager;
class ChromeMessageBroadcaster;
class ChromeMessageSender;
class ContentFrameMessageManager;
class ContentProcessMessageManager;
class MessageBroadcaster;
class MessageListener;
struct MessageListenerAtoms;
class MessageListenerManager;
class MessagePort;
class MessageSender;
struct NativePropertyHooks;
class ParentProcessMessageManager;
class ProcessMessageManager;
class ProtoAndIfaceCache;
struct ReceiveMessageArgument;
struct ReceiveMessageArgumentAtoms;
class SyncMessageSender;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
struct ReceiveMessageArgument : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR JS::Value mData;
MOZ_INIT_OUTSIDE_CTOR JS::Value mJson;
MOZ_INIT_OUTSIDE_CTOR nsString mName;
MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<OwningNonNull<mozilla::dom::MessagePort>>> mPorts;
MOZ_INIT_OUTSIDE_CTOR bool mSync;
MOZ_INIT_OUTSIDE_CTOR RefPtr<nsISupports> mTarget;
MOZ_INIT_OUTSIDE_CTOR Optional<OwningNonNull<nsFrameLoader>> mTargetFrameLoader;
ReceiveMessageArgument();
explicit inline ReceiveMessageArgument(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
ReceiveMessageArgument(ReceiveMessageArgument&& aOther) = default;
private:
ReceiveMessageArgument(const ReceiveMessageArgument&) = delete;
ReceiveMessageArgument& operator=(const ReceiveMessageArgument&) = delete;
static bool
InitIds(JSContext* cx, ReceiveMessageArgumentAtoms* atomsCache);
public:
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
inline void
TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags)
{
ImplCycleCollectionTraverse(aCallback, mPorts, "mPorts", aFlags);
ImplCycleCollectionTraverse(aCallback, mTarget, "mTarget", aFlags);
ImplCycleCollectionTraverse(aCallback, mTargetFrameLoader, "mTargetFrameLoader", aFlags);
}
inline void
UnlinkForCC()
{
ImplCycleCollectionUnlink(mPorts);
ImplCycleCollectionUnlink(mTarget);
ImplCycleCollectionUnlink(mTargetFrameLoader);
}
};
namespace binding_detail {
struct FastReceiveMessageArgument : public ReceiveMessageArgument
{
inline FastReceiveMessageArgument()
: ReceiveMessageArgument(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace ChildProcessMessageManager_Binding {
typedef mozilla::dom::ChildProcessMessageManager NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::ChildProcessMessageManager* 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::ChildProcessMessageManager,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace ChildProcessMessageManager_Binding
namespace ChromeMessageBroadcaster_Binding {
typedef mozilla::dom::ChromeMessageBroadcaster NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::ChromeMessageBroadcaster* 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::ChromeMessageBroadcaster,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace ChromeMessageBroadcaster_Binding
namespace ChromeMessageSender_Binding {
typedef mozilla::dom::ChromeMessageSender NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::ChromeMessageSender* 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::ChromeMessageSender,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace ChromeMessageSender_Binding
namespace ContentFrameMessageManager_Binding {
typedef mozilla::dom::ContentFrameMessageManager NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::ContentFrameMessageManager* 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::ContentFrameMessageManager,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace ContentFrameMessageManager_Binding
namespace ContentProcessMessageManager_Binding {
typedef mozilla::dom::ContentProcessMessageManager NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::ContentProcessMessageManager* 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::ContentProcessMessageManager,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace ContentProcessMessageManager_Binding
namespace MessageBroadcaster_Binding {
typedef mozilla::dom::MessageBroadcaster NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetProtoObjectHandle(JSContext* aCx);
JSObject*
GetProtoObject(JSContext* aCx);
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::MessageBroadcaster,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace MessageBroadcaster_Binding
namespace MessageListenerManager_Binding {
typedef mozilla::dom::MessageListenerManager NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetProtoObjectHandle(JSContext* aCx);
JSObject*
GetProtoObject(JSContext* aCx);
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::MessageListenerManager,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace MessageListenerManager_Binding
namespace MessageSender_Binding {
typedef mozilla::dom::MessageSender NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetProtoObjectHandle(JSContext* aCx);
JSObject*
GetProtoObject(JSContext* aCx);
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::MessageSender,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace MessageSender_Binding
namespace ParentProcessMessageManager_Binding {
typedef mozilla::dom::ParentProcessMessageManager NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::ParentProcessMessageManager* 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::ParentProcessMessageManager,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace ParentProcessMessageManager_Binding
namespace ProcessMessageManager_Binding {
typedef mozilla::dom::ProcessMessageManager NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::ProcessMessageManager* 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::ProcessMessageManager,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace ProcessMessageManager_Binding
namespace SyncMessageSender_Binding {
typedef mozilla::dom::SyncMessageSender NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetProtoObjectHandle(JSContext* aCx);
JSObject*
GetProtoObject(JSContext* aCx);
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::SyncMessageSender,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace SyncMessageSender_Binding
class MessageListener : public CallbackInterface
{
public:
explicit inline MessageListener(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackInterface(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
}
explicit inline MessageListener(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackInterface(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
explicit inline MessageListener(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackInterface(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
}
template <typename T>
inline void
ReceiveMessage(const T& thisVal, const ReceiveMessageArgument& argument, JS::MutableHandle<JS::Value> aRetVal, 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 = "MessageListener.receiveMessage";
}
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 ReceiveMessage(s.GetCallContext(), thisValJS, argument, aRetVal, aRv);
}
inline void
ReceiveMessage(const ReceiveMessageArgument& argument, JS::MutableHandle<JS::Value> aRetVal, 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 = "MessageListener.receiveMessage";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
return ReceiveMessage(s.GetCallContext(), JS::UndefinedHandleValue, argument, aRetVal, aRv);
}
template <typename T>
inline void
ReceiveMessage(const T& thisVal, const ReceiveMessageArgument& argument, JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr)
{
return ReceiveMessage(thisVal, argument, aRetVal, IgnoreErrors(), aExecutionReason);
}
inline void
ReceiveMessage(const ReceiveMessageArgument& argument, JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr)
{
return ReceiveMessage(argument, aRetVal, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
}
inline bool
operator==(const MessageListener& aOther) const
{
return CallbackInterface::operator==(aOther);
}
private:
void ReceiveMessage(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, const ReceiveMessageArgument& argument, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv);
static bool
InitIds(JSContext* cx, MessageListenerAtoms* atomsCache);
};
namespace binding_detail {
class FastMessageListener : public MessageListener
{
public:
explicit inline FastMessageListener(JSObject* aCallback, JSObject* aCallbackGlobal)
: MessageListener(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
inline void
Trace(JSTracer* aTracer)
{
MessageListener::Trace(aTracer);
}
inline void
FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
{
MessageListener::FinishSlowJSInitIfMoreThanOneOwner(aCx);
}
};
} // namespace binding_detail
} // namespace mozilla::dom
#endif // DOM_MESSAGEMANAGERBINDING_H_