MessagePortChild.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_MessagePortChild_h
  5. #define mozilla_dom_MessagePortChild_h
  6. #include "mozilla/Assertions.h"
  7. #include "mozilla/dom/PMessagePortChild.h"
  8. #include "nsISupportsImpl.h"
  9. namespace mozilla {
  10. namespace dom {
  11. class MessagePort;
  12. class MessagePortChild final : public PMessagePortChild
  13. {
  14. public:
  15. NS_INLINE_DECL_REFCOUNTING(MessagePortChild)
  16. MessagePortChild() : mPort(nullptr) {}
  17. void SetPort(MessagePort* aPort)
  18. {
  19. mPort = aPort;
  20. }
  21. private:
  22. ~MessagePortChild()
  23. {
  24. MOZ_ASSERT(!mPort);
  25. }
  26. virtual bool
  27. RecvEntangled(nsTArray<MessagePortMessage>&& aMessages) override;
  28. virtual bool
  29. RecvReceiveData(nsTArray<MessagePortMessage>&& aMessages) override;
  30. virtual bool RecvStopSendingDataConfirmed() override;
  31. virtual void ActorDestroy(ActorDestroyReason aWhy) override;
  32. // This is a raw pointer because this child is owned by this MessagePort.
  33. MessagePort* mPort;
  34. };
  35. } // namespace dom
  36. } // namespace mozilla
  37. #endif // mozilla_dom_MessagePortChild_h