Bug 1665252 - remove allowpaymentrequest attribute from HTMLIFrameElement r=dom-worke...
[gecko.git] / dom / base / MessageBroadcaster.h
blob41f9402ecf7f4eac11e51e231b31cbf1e24166d1
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 {
14 namespace dom {
16 /**
17 * Implementation for the WebIDL MessageBroadcaster interface. Base class for
18 * window and process broadcaster message managers.
20 class MessageBroadcaster : public MessageListenerManager {
21 public:
22 static MessageBroadcaster* From(MessageListenerManager* aManager) {
23 if (aManager->IsBroadcaster()) {
24 return static_cast<MessageBroadcaster*>(aManager);
26 return nullptr;
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,
33 aError);
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);
44 protected:
45 MessageBroadcaster(MessageBroadcaster* aParentManager,
46 MessageManagerFlags aFlags);
49 } // namespace dom
50 } // namespace mozilla
52 #endif // mozilla_dom_MessageBroadcaster_h