MessageChannel.h 943 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageChannel>> construct_impl(JS::Realm&);
  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(JS::Realm&);
  22. virtual void initialize(JS::Realm&) override;
  23. virtual void visit_edges(Cell::Visitor&) override;
  24. JS::GCPtr<MessagePort> m_port1;
  25. JS::GCPtr<MessagePort> m_port2;
  26. };
  27. }