tor-browser

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

MessagePortService.h (1788B)


      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_MessagePortService_h
      8 #define mozilla_dom_MessagePortService_h
      9 
     10 #include "nsClassHashtable.h"
     11 #include "nsHashKeys.h"
     12 #include "nsISupportsImpl.h"
     13 
     14 namespace mozilla::dom {
     15 
     16 class MessagePortParent;
     17 class SharedMessageBody;
     18 
     19 class MessagePortService final {
     20 public:
     21  NS_INLINE_DECL_REFCOUNTING(MessagePortService)
     22 
     23  // Needs to be public for the MOZ_DECLARE_RELOCATE_USING_MOVE_CONSTRUCTOR
     24  // macro.
     25  struct NextParent;
     26 
     27  static MessagePortService* Get();
     28  static MessagePortService* GetOrCreate();
     29 
     30  bool RequestEntangling(MessagePortParent* aParent,
     31                         const nsID& aDestinationUUID,
     32                         const uint32_t& aSequenceID);
     33 
     34  bool DisentanglePort(MessagePortParent* aParent,
     35                       FallibleTArray<RefPtr<SharedMessageBody>> aMessages);
     36 
     37  bool ClosePort(MessagePortParent* aParent);
     38 
     39  bool PostMessages(MessagePortParent* aParent,
     40                    FallibleTArray<RefPtr<SharedMessageBody>> aMessages);
     41 
     42  void ParentDestroy(MessagePortParent* aParent);
     43 
     44  bool ForceClose(const nsID& aUUID, const nsID& aDestinationUUID,
     45                  const uint32_t& aSequenceID);
     46 
     47 private:
     48  ~MessagePortService() = default;
     49 
     50  void CloseAll(const nsID& aUUID, bool aForced = false);
     51  void MaybeShutdown();
     52 
     53  class MessagePortServiceData;
     54 
     55  nsClassHashtable<nsIDHashKey, MessagePortServiceData> mPorts;
     56 };
     57 
     58 }  // namespace mozilla::dom
     59 
     60 #endif  // mozilla_dom_MessagePortService_h