2021-09-19 17:12:31 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2021-2022, Andreas Kling <andreas@ladybird.org>
|
2021-09-19 17:12:31 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-09-01 15:59:51 -03:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2021-09-19 17:12:31 -03:00
|
|
|
#include <LibWeb/Forward.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/web-messaging.html#message-channels
|
2022-09-01 15:59:51 -03:00
|
|
|
class MessageChannel final : public Bindings::PlatformObject {
|
|
|
|
|
WEB_PLATFORM_OBJECT(MessageChannel, Bindings::PlatformObject);
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_DECLARE_ALLOCATOR(MessageChannel);
|
2021-09-19 17:12:31 -03:00
|
|
|
|
2022-09-01 15:59:51 -03:00
|
|
|
public:
|
2024-11-14 12:01:23 -03:00
|
|
|
static WebIDL::ExceptionOr<GC::Ref<MessageChannel>> construct_impl(JS::Realm&);
|
2021-09-19 17:12:31 -03:00
|
|
|
virtual ~MessageChannel() override;
|
|
|
|
|
|
2022-08-28 08:42:07 -03:00
|
|
|
MessagePort* port1();
|
|
|
|
|
MessagePort const* port1() const;
|
2021-09-19 17:12:31 -03:00
|
|
|
|
2022-08-28 08:42:07 -03:00
|
|
|
MessagePort* port2();
|
|
|
|
|
MessagePort const* port2() const;
|
2021-09-19 17:12:31 -03:00
|
|
|
|
|
|
|
|
private:
|
2022-09-25 19:38:21 -03:00
|
|
|
explicit MessageChannel(JS::Realm&);
|
2021-09-19 17:12:31 -03:00
|
|
|
|
2023-08-07 03:41:28 -03:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-09-01 15:59:51 -03:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ptr<MessagePort> m_port1;
|
|
|
|
|
GC::Ptr<MessagePort> m_port2;
|
2021-09-19 17:12:31 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|