tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

MessageBroadcaster.h (1742B)


      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/. */
      6 
      7 #ifndef mozilla_dom_MessageBroadcaster_h
      8 #define mozilla_dom_MessageBroadcaster_h
      9 
     10 #include "mozilla/dom/MessageListenerManager.h"
     11 #include "nsContentUtils.h"
     12 
     13 namespace mozilla::dom {
     14 
     15 /**
     16 * Implementation for the WebIDL MessageBroadcaster interface. Base class for
     17 * window and process broadcaster message managers.
     18 */
     19 class MessageBroadcaster : public MessageListenerManager {
     20 public:
     21  static MessageBroadcaster* From(MessageListenerManager* aManager) {
     22    if (aManager->IsBroadcaster()) {
     23      return static_cast<MessageBroadcaster*>(aManager);
     24    }
     25    return nullptr;
     26  }
     27 
     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);
     33  }
     34  uint32_t ChildCount() { return mChildManagers.Length(); }
     35  MessageListenerManager* GetChildAt(uint32_t aIndex) {
     36    return mChildManagers.SafeElementAt(aIndex);
     37  }
     38  void ReleaseCachedProcesses();
     39 
     40  void AddChildManager(MessageListenerManager* aManager);
     41  void RemoveChildManager(MessageListenerManager* aManager);
     42 
     43 protected:
     44  MessageBroadcaster(MessageBroadcaster* aParentManager,
     45                     MessageManagerFlags aFlags);
     46 };
     47 
     48 }  // namespace mozilla::dom
     49 
     50 #endif  // mozilla_dom_MessageBroadcaster_h