tor-browser

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

BroadcastChannelService.h (1451B)


      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 file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_BroadcastChannelService_h
      8 #define mozilla_dom_BroadcastChannelService_h
      9 
     10 #include "nsClassHashtable.h"
     11 #include "nsHashKeys.h"
     12 #include "nsISupportsImpl.h"
     13 
     14 #ifdef XP_WIN
     15 #  undef PostMessage
     16 #endif
     17 
     18 namespace mozilla::dom {
     19 
     20 class BroadcastChannelParent;
     21 class MessageData;
     22 
     23 class BroadcastChannelService final {
     24 public:
     25  NS_INLINE_DECL_REFCOUNTING(BroadcastChannelService)
     26 
     27  static already_AddRefed<BroadcastChannelService> GetOrCreate();
     28 
     29  void RegisterActor(BroadcastChannelParent* aParent,
     30                     const nsAString& aOriginChannelKey);
     31  void UnregisterActor(BroadcastChannelParent* aParent,
     32                       const nsAString& aOriginChannelKey);
     33 
     34  void PostMessage(BroadcastChannelParent* aParent, const MessageData& aData,
     35                   const nsAString& aOriginChannelKey);
     36 
     37 private:
     38  BroadcastChannelService();
     39  ~BroadcastChannelService();
     40 
     41  // Raw Pointers because the actors keep alive this service.
     42  nsClassHashtable<nsStringHashKey, nsTArray<BroadcastChannelParent*>> mAgents;
     43 };
     44 
     45 }  // namespace mozilla::dom
     46 
     47 #endif  // mozilla_dom_BroadcastChannelService_h