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"
17 * Implementation for the WebIDL MessageBroadcaster interface. Base class for
18 * window and process broadcaster message managers.
20 class MessageBroadcaster
: public MessageListenerManager
{
22 static MessageBroadcaster
* From(MessageListenerManager
* aManager
) {
23 if (aManager
->IsBroadcaster()) {
24 return static_cast<MessageBroadcaster
*>(aManager
);
29 void BroadcastAsyncMessage(JSContext
* aCx
, const nsAString
& aMessageName
,
30 JS::Handle
<JS::Value
> aObj
,
31 mozilla::ErrorResult
& aError
) {
32 DispatchAsyncMessage(aCx
, aMessageName
, aObj
, JS::UndefinedHandleValue
,
35 uint32_t ChildCount() { return mChildManagers
.Length(); }
36 MessageListenerManager
* GetChildAt(uint32_t aIndex
) {
37 return mChildManagers
.SafeElementAt(aIndex
);
39 void ReleaseCachedProcesses();
41 void AddChildManager(MessageListenerManager
* aManager
);
42 void RemoveChildManager(MessageListenerManager
* aManager
);
45 MessageBroadcaster(MessageBroadcaster
* aParentManager
,
46 MessageManagerFlags aFlags
);
50 } // namespace mozilla
52 #endif // mozilla_dom_MessageBroadcaster_h