Bug 1835710 - Cancel off-thread JIT compilation before changing nursery allocation...
[gecko.git] / dom / base / MessageBroadcaster.h
blob8ee5cab870826fa17f511bb532e052406b1b3b59
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_MessageBroadcaster_h
8 #define mozilla_dom_MessageBroadcaster_h
10 #include "mozilla/dom/MessageListenerManager.h"
11 #include "nsContentUtils.h"
13 namespace mozilla::dom {
15 /**
16 * Implementation for the WebIDL MessageBroadcaster interface. Base class for
17 * window and process broadcaster message managers.
19 class MessageBroadcaster : public MessageListenerManager {
20 public:
21 static MessageBroadcaster* From(MessageListenerManager* aManager) {
22 if (aManager->IsBroadcaster()) {
23 return static_cast<MessageBroadcaster*>(aManager);
25 return nullptr;
28 void BroadcastAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
29 JS::Handle<JS::Value> aObj,
30 mozilla::ErrorResult& aError) {
31 DispatchAsyncMessage(aCx, aMessageName, aObj, JS::UndefinedHandleValue,
32 aError);
34 uint32_t ChildCount() { return mChildManagers.Length(); }
35 MessageListenerManager* GetChildAt(uint32_t aIndex) {
36 return mChildManagers.SafeElementAt(aIndex);
38 void ReleaseCachedProcesses();
40 void AddChildManager(MessageListenerManager* aManager);
41 void RemoveChildManager(MessageListenerManager* aManager);
43 protected:
44 MessageBroadcaster(MessageBroadcaster* aParentManager,
45 MessageManagerFlags aFlags);
48 } // namespace mozilla::dom
50 #endif // mozilla_dom_MessageBroadcaster_h