MessageChannel.h 930 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2021-2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Bindings/PlatformObject.h>
  8. #include <LibWeb/Forward.h>
  9. namespace Web::HTML {
  10. // https://html.spec.whatwg.org/multipage/web-messaging.html#message-channels
  11. class MessageChannel final : public Bindings::PlatformObject {
  12. WEB_PLATFORM_OBJECT(MessageChannel, Bindings::PlatformObject);
  13. public:
  14. static JS::NonnullGCPtr<MessageChannel> create_with_global_object(HTML::Window&);
  15. virtual ~MessageChannel() override;
  16. MessagePort* port1();
  17. MessagePort const* port1() const;
  18. MessagePort* port2();
  19. MessagePort const* port2() const;
  20. private:
  21. explicit MessageChannel(HTML::Window&);
  22. virtual void visit_edges(Cell::Visitor&) override;
  23. JS::GCPtr<MessagePort> m_port1;
  24. JS::GCPtr<MessagePort> m_port2;
  25. };
  26. }
  27. WRAPPER_HACK(MessageChannel, Web::HTML)