/* * DO NOT EDIT. THIS FILE IS GENERATED FROM $SRCDIR/xpcom/threads/nsIThreadManager.idl */ #ifndef __gen_nsIThreadManager_h__ #define __gen_nsIThreadManager_h__ #include "nsISupports.h" #include "js/GCAnnotations.h" /* For IDL files that don't want to include root IDL files. */ #ifndef NS_NO_VTABLE #define NS_NO_VTABLE #endif class nsIEventTarget; /* forward declaration */ class nsIRunnable; /* forward declaration */ class nsIThread; /* forward declaration */ // %{C++:15-15 #include "mozilla/Maybe.h" // %} /* starting interface: nsINestedEventLoopCondition */ #define NS_INESTEDEVENTLOOPCONDITION_IID_STR "039a227d-0cb7-44a5-a8f9-dbb7071979f2" #define NS_INESTEDEVENTLOOPCONDITION_IID \ {0x039a227d, 0x0cb7, 0x44a5, \ { 0xa8, 0xf9, 0xdb, 0xb7, 0x07, 0x19, 0x79, 0xf2 }} class NS_NO_VTABLE MOZ_BINDING(binding_to, idl, class, XPIDL_nsINestedEventLoopCondition) nsINestedEventLoopCondition : public nsISupports { public: NS_INLINE_DECL_STATIC_IID(NS_INESTEDEVENTLOOPCONDITION_IID) /* Used by ToJSValue to check which scriptable interface is implemented. */ using ScriptableInterfaceType = nsINestedEventLoopCondition; /* boolean isDone (); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsINestedEventLoopCondition_isDone) JS_HAZ_CAN_RUN_SCRIPT NS_IMETHOD IsDone(bool *_retval) = 0; }; /* Use this macro when declaring classes that implement this interface. */ #define NS_DECL_NSINESTEDEVENTLOOPCONDITION \ NS_IMETHOD IsDone(bool *_retval) override; /* Use this macro when declaring the members of this interface when the class doesn't implement the interface. This is useful for forwarding. */ #define NS_DECL_NON_VIRTUAL_NSINESTEDEVENTLOOPCONDITION \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsINestedEventLoopCondition_isDone)\ nsresult IsDone(bool *_retval); /* Use this macro to declare functions that forward the behavior of this interface to another object. */ #define NS_FORWARD_NSINESTEDEVENTLOOPCONDITION(_to) \ NS_IMETHOD IsDone(bool *_retval) override { return _to IsDone(_retval); } /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */ #define NS_FORWARD_SAFE_NSINESTEDEVENTLOOPCONDITION(_to) \ NS_IMETHOD IsDone(bool *_retval) override { return !_to ? NS_ERROR_NULL_POINTER : _to->IsDone(_retval); } /* starting interface: nsIThreadManager */ #define NS_ITHREADMANAGER_IID_STR "1be89eca-e2f7-453b-8d38-c11ba247f6f3" #define NS_ITHREADMANAGER_IID \ {0x1be89eca, 0xe2f7, 0x453b, \ { 0x8d, 0x38, 0xc1, 0x1b, 0xa2, 0x47, 0xf6, 0xf3 }} class MOZ_BINDING(binding_to, idl, class, XPIDL_nsIThreadManager) nsIThreadManager : public nsISupports { public: NS_INLINE_DECL_STATIC_IID(NS_ITHREADMANAGER_IID) /* Used by ToJSValue to check which scriptable interface is implemented. */ using ScriptableInterfaceType = nsIThreadManager; // %{C++:52-93 #if defined(MOZ_ASAN) || defined(MOZ_TSAN) || !defined(__OPTIMIZE__) static constexpr uint32_t DEFAULT_STACK_SIZE = 0; #else static constexpr uint32_t DEFAULT_STACK_SIZE = 256 * 1024; #endif /** * Threads which may need large stacks (such as those running JS or JS helper * tasks), can instead specify nsIThreadManager::LargeStackSize(). This is * just short of 2MB to avoid the Linux kernel allocating an entire 2MB huge * page for the stack on first access. * * ASan and TSan builds are given a larger stack size due to extra data and * red-zones which consume stack space. */ static uint32_t LargeStackSize(); static const uint32_t kThreadPoolStackSize = DEFAULT_STACK_SIZE; struct ThreadCreationOptions { // The size in bytes to reserve for the thread's stack. A value of `0` means // to use the platform default. uint32_t stackSize = nsIThreadManager::DEFAULT_STACK_SIZE; // If set to `true`, any attempts to dispatch runnables to this thread // without `DISPATCH_IGNORE_BLOCK_DISPATCH` will fail. // // This is intended to be used for threads which are expected to generally // only service a single runnable (other than thread lifecycle runnables), // and perform their own event dispatching internaly, such as thread pool // threads or the timer thread. bool blockDispatch = false; // (Windows-only) Whether the thread should have a MessageLoop capable of // processing native UI events. Defaults to false. bool isUiThread = false; // If set, long task markers will be collected for tasks // longer than longTaskLength ms when profiling is enabled. // See https://www.w3.org/TR/longtasks mozilla::Maybe longTaskLength; }; // %} /* [noscript] nsIThread newNamedThread (in ACString name, in ThreadCreationOptions options); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_newNamedThread) NS_IMETHOD NewNamedThread(const nsACString& name, nsIThreadManager::ThreadCreationOptions options, nsIThread **_retval) = 0; /* readonly attribute nsIThread mainThread; */ MOZ_BINDING(binding_to, idl, getter, XPIDL_nsIThreadManager_mainThread) NS_IMETHOD GetMainThread(nsIThread **aMainThread) = 0; /* readonly attribute nsIThread currentThread; */ MOZ_BINDING(binding_to, idl, getter, XPIDL_nsIThreadManager_currentThread) NS_IMETHOD GetCurrentThread(nsIThread **aCurrentThread) = 0; /* [optional_argc] void dispatchToMainThread (in nsIRunnable event, [optional] in uint32_t priority); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_dispatchToMainThread) NS_IMETHOD DispatchToMainThread(nsIRunnable *event, uint32_t priority, uint8_t _argc) = 0; /* [optional_argc] void dispatchToMainThreadWithMicroTask (in nsIRunnable event, [optional] in uint32_t priority); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_dispatchToMainThreadWithMicroTask) NS_IMETHOD DispatchToMainThreadWithMicroTask(nsIRunnable *event, uint32_t priority, uint8_t _argc) = 0; /* void idleDispatchToMainThread (in nsIRunnable event, [optional] in uint32_t timeout); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_idleDispatchToMainThread) NS_IMETHOD IdleDispatchToMainThread(nsIRunnable *event, uint32_t timeout) = 0; /* void dispatchDirectTaskToCurrentThread (in nsIRunnable event); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_dispatchDirectTaskToCurrentThread) NS_IMETHOD DispatchDirectTaskToCurrentThread(nsIRunnable *event) = 0; /* void spinEventLoopUntil (in ACString aVeryGoodReasonToDoThis, in nsINestedEventLoopCondition condition); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_spinEventLoopUntil) NS_IMETHOD SpinEventLoopUntil(const nsACString& aVeryGoodReasonToDoThis, nsINestedEventLoopCondition *condition) = 0; /* void spinEventLoopUntilOrQuit (in ACString aVeryGoodReasonToDoThis, in nsINestedEventLoopCondition condition); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_spinEventLoopUntilOrQuit) NS_IMETHOD SpinEventLoopUntilOrQuit(const nsACString& aVeryGoodReasonToDoThis, nsINestedEventLoopCondition *condition) = 0; /* void spinEventLoopUntilEmpty (); */ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_spinEventLoopUntilEmpty) NS_IMETHOD SpinEventLoopUntilEmpty(void) = 0; /* readonly attribute nsIEventTarget mainThreadEventTarget; */ MOZ_BINDING(binding_to, idl, getter, XPIDL_nsIThreadManager_mainThreadEventTarget) NS_IMETHOD GetMainThreadEventTarget(nsIEventTarget **aMainThreadEventTarget) = 0; }; /* Use this macro when declaring classes that implement this interface. */ #define NS_DECL_NSITHREADMANAGER \ NS_IMETHOD NewNamedThread(const nsACString& name, nsIThreadManager::ThreadCreationOptions options, nsIThread **_retval) override; \ NS_IMETHOD GetMainThread(nsIThread **aMainThread) override; \ NS_IMETHOD GetCurrentThread(nsIThread **aCurrentThread) override; \ NS_IMETHOD DispatchToMainThread(nsIRunnable *event, uint32_t priority, uint8_t _argc) override; \ NS_IMETHOD DispatchToMainThreadWithMicroTask(nsIRunnable *event, uint32_t priority, uint8_t _argc) override; \ NS_IMETHOD IdleDispatchToMainThread(nsIRunnable *event, uint32_t timeout) override; \ NS_IMETHOD DispatchDirectTaskToCurrentThread(nsIRunnable *event) override; \ NS_IMETHOD SpinEventLoopUntil(const nsACString& aVeryGoodReasonToDoThis, nsINestedEventLoopCondition *condition) override; \ NS_IMETHOD SpinEventLoopUntilOrQuit(const nsACString& aVeryGoodReasonToDoThis, nsINestedEventLoopCondition *condition) override; \ NS_IMETHOD SpinEventLoopUntilEmpty(void) override; \ NS_IMETHOD GetMainThreadEventTarget(nsIEventTarget **aMainThreadEventTarget) override; /* Use this macro when declaring the members of this interface when the class doesn't implement the interface. This is useful for forwarding. */ #define NS_DECL_NON_VIRTUAL_NSITHREADMANAGER \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_newNamedThread)\ nsresult NewNamedThread(const nsACString& name, nsIThreadManager::ThreadCreationOptions options, nsIThread **_retval); \ MOZ_BINDING(binding_to, idl, getter, XPIDL_nsIThreadManager_mainThread)\ nsresult GetMainThread(nsIThread **aMainThread); \ MOZ_BINDING(binding_to, idl, getter, XPIDL_nsIThreadManager_currentThread)\ nsresult GetCurrentThread(nsIThread **aCurrentThread); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_dispatchToMainThread)\ nsresult DispatchToMainThread(nsIRunnable *event, uint32_t priority, uint8_t _argc); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_dispatchToMainThreadWithMicroTask)\ nsresult DispatchToMainThreadWithMicroTask(nsIRunnable *event, uint32_t priority, uint8_t _argc); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_idleDispatchToMainThread)\ nsresult IdleDispatchToMainThread(nsIRunnable *event, uint32_t timeout); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_dispatchDirectTaskToCurrentThread)\ nsresult DispatchDirectTaskToCurrentThread(nsIRunnable *event); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_spinEventLoopUntil)\ nsresult SpinEventLoopUntil(const nsACString& aVeryGoodReasonToDoThis, nsINestedEventLoopCondition *condition); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_spinEventLoopUntilOrQuit)\ nsresult SpinEventLoopUntilOrQuit(const nsACString& aVeryGoodReasonToDoThis, nsINestedEventLoopCondition *condition); \ MOZ_BINDING(binding_to, idl, method, XPIDL_nsIThreadManager_spinEventLoopUntilEmpty)\ nsresult SpinEventLoopUntilEmpty(void); \ MOZ_BINDING(binding_to, idl, getter, XPIDL_nsIThreadManager_mainThreadEventTarget)\ nsresult GetMainThreadEventTarget(nsIEventTarget **aMainThreadEventTarget); /* Use this macro to declare functions that forward the behavior of this interface to another object. */ #define NS_FORWARD_NSITHREADMANAGER(_to) \ NS_IMETHOD NewNamedThread(const nsACString& name, nsIThreadManager::ThreadCreationOptions options, nsIThread **_retval) override { return _to NewNamedThread(name, options, _retval); } \ NS_IMETHOD GetMainThread(nsIThread **aMainThread) override { return _to GetMainThread(aMainThread); } \ NS_IMETHOD GetCurrentThread(nsIThread **aCurrentThread) override { return _to GetCurrentThread(aCurrentThread); } \ NS_IMETHOD DispatchToMainThread(nsIRunnable *event, uint32_t priority, uint8_t _argc) override { return _to DispatchToMainThread(event, priority, _argc); } \ NS_IMETHOD DispatchToMainThreadWithMicroTask(nsIRunnable *event, uint32_t priority, uint8_t _argc) override { return _to DispatchToMainThreadWithMicroTask(event, priority, _argc); } \ NS_IMETHOD IdleDispatchToMainThread(nsIRunnable *event, uint32_t timeout) override { return _to IdleDispatchToMainThread(event, timeout); } \ NS_IMETHOD DispatchDirectTaskToCurrentThread(nsIRunnable *event) override { return _to DispatchDirectTaskToCurrentThread(event); } \ NS_IMETHOD SpinEventLoopUntil(const nsACString& aVeryGoodReasonToDoThis, nsINestedEventLoopCondition *condition) override { return _to SpinEventLoopUntil(aVeryGoodReasonToDoThis, condition); } \ NS_IMETHOD SpinEventLoopUntilOrQuit(const nsACString& aVeryGoodReasonToDoThis, nsINestedEventLoopCondition *condition) override { return _to SpinEventLoopUntilOrQuit(aVeryGoodReasonToDoThis, condition); } \ NS_IMETHOD SpinEventLoopUntilEmpty(void) override { return _to SpinEventLoopUntilEmpty(); } \ NS_IMETHOD GetMainThreadEventTarget(nsIEventTarget **aMainThreadEventTarget) override { return _to GetMainThreadEventTarget(aMainThreadEventTarget); } /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */ #define NS_FORWARD_SAFE_NSITHREADMANAGER(_to) \ NS_IMETHOD NewNamedThread(const nsACString& name, nsIThreadManager::ThreadCreationOptions options, nsIThread **_retval) override { return !_to ? NS_ERROR_NULL_POINTER : _to->NewNamedThread(name, options, _retval); } \ NS_IMETHOD GetMainThread(nsIThread **aMainThread) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetMainThread(aMainThread); } \ NS_IMETHOD GetCurrentThread(nsIThread **aCurrentThread) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetCurrentThread(aCurrentThread); } \ NS_IMETHOD DispatchToMainThread(nsIRunnable *event, uint32_t priority, uint8_t _argc) override { return !_to ? NS_ERROR_NULL_POINTER : _to->DispatchToMainThread(event, priority, _argc); } \ NS_IMETHOD DispatchToMainThreadWithMicroTask(nsIRunnable *event, uint32_t priority, uint8_t _argc) override { return !_to ? NS_ERROR_NULL_POINTER : _to->DispatchToMainThreadWithMicroTask(event, priority, _argc); } \ NS_IMETHOD IdleDispatchToMainThread(nsIRunnable *event, uint32_t timeout) override { return !_to ? NS_ERROR_NULL_POINTER : _to->IdleDispatchToMainThread(event, timeout); } \ NS_IMETHOD DispatchDirectTaskToCurrentThread(nsIRunnable *event) override { return !_to ? NS_ERROR_NULL_POINTER : _to->DispatchDirectTaskToCurrentThread(event); } \ NS_IMETHOD SpinEventLoopUntil(const nsACString& aVeryGoodReasonToDoThis, nsINestedEventLoopCondition *condition) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SpinEventLoopUntil(aVeryGoodReasonToDoThis, condition); } \ NS_IMETHOD SpinEventLoopUntilOrQuit(const nsACString& aVeryGoodReasonToDoThis, nsINestedEventLoopCondition *condition) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SpinEventLoopUntilOrQuit(aVeryGoodReasonToDoThis, condition); } \ NS_IMETHOD SpinEventLoopUntilEmpty(void) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SpinEventLoopUntilEmpty(); } \ NS_IMETHOD GetMainThreadEventTarget(nsIEventTarget **aMainThreadEventTarget) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetMainThreadEventTarget(aMainThreadEventTarget); } #endif /* __gen_nsIThreadManager_h__ */