MessagePortParent.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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_MessagePortParent_h
  5. #define mozilla_dom_MessagePortParent_h
  6. #include "mozilla/WeakPtr.h"
  7. #include "mozilla/dom/PMessagePortParent.h"
  8. namespace mozilla {
  9. namespace dom {
  10. class MessagePortService;
  11. class MessagePortParent final : public PMessagePortParent,
  12. public SupportsWeakPtr<MessagePortParent>
  13. {
  14. public:
  15. explicit MessagePortParent(const nsID& aUUID);
  16. ~MessagePortParent();
  17. bool Entangle(const nsID& aDestinationUUID,
  18. const uint32_t& aSequenceID);
  19. bool Entangled(const nsTArray<MessagePortMessage>& aMessages);
  20. void Close();
  21. void CloseAndDelete();
  22. bool CanSendData() const
  23. {
  24. return mCanSendData;
  25. }
  26. const nsID& ID() const
  27. {
  28. return mUUID;
  29. }
  30. static bool ForceClose(const nsID& aUUID,
  31. const nsID& aDestinationUUID,
  32. const uint32_t& aSequenceID);
  33. MOZ_DECLARE_WEAKREFERENCE_TYPENAME(MessagePortParent)
  34. private:
  35. virtual bool RecvPostMessages(nsTArray<MessagePortMessage>&& aMessages)
  36. override;
  37. virtual bool RecvDisentangle(nsTArray<MessagePortMessage>&& aMessages)
  38. override;
  39. virtual bool RecvStopSendingData() override;
  40. virtual bool RecvClose() override;
  41. virtual void ActorDestroy(ActorDestroyReason aWhy) override;
  42. RefPtr<MessagePortService> mService;
  43. const nsID mUUID;
  44. bool mEntangled;
  45. bool mCanSendData;
  46. };
  47. } // namespace dom
  48. } // namespace mozilla
  49. #endif // mozilla_dom_MessagePortParent_h