MessagePortService.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  3. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef mozilla_dom_MessagePortService_h
  5. #define mozilla_dom_MessagePortService_h
  6. #include "nsClassHashtable.h"
  7. #include "nsHashKeys.h"
  8. #include "nsISupportsImpl.h"
  9. namespace mozilla {
  10. namespace dom {
  11. class MessagePortParent;
  12. class SharedMessagePortMessage;
  13. class MessagePortService final
  14. {
  15. public:
  16. NS_INLINE_DECL_REFCOUNTING(MessagePortService)
  17. static MessagePortService* Get();
  18. static MessagePortService* GetOrCreate();
  19. bool RequestEntangling(MessagePortParent* aParent,
  20. const nsID& aDestinationUUID,
  21. const uint32_t& aSequenceID);
  22. bool DisentanglePort(
  23. MessagePortParent* aParent,
  24. FallibleTArray<RefPtr<SharedMessagePortMessage>>& aMessages);
  25. bool ClosePort(MessagePortParent* aParent);
  26. bool PostMessages(
  27. MessagePortParent* aParent,
  28. FallibleTArray<RefPtr<SharedMessagePortMessage>>& aMessages);
  29. void ParentDestroy(MessagePortParent* aParent);
  30. bool ForceClose(const nsID& aUUID,
  31. const nsID& aDestinationUUID,
  32. const uint32_t& aSequenceID);
  33. private:
  34. ~MessagePortService() {}
  35. void CloseAll(const nsID& aUUID, bool aForced = false);
  36. void MaybeShutdown();
  37. class MessagePortServiceData;
  38. nsClassHashtable<nsIDHashKey, MessagePortServiceData> mPorts;
  39. };
  40. } // namespace dom
  41. } // namespace mozilla
  42. #endif // mozilla_dom_MessagePortService_h