blob: 9abe9b91d146aa625e85a52e722df0451d03e30b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/RefCounted.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/DOM/Window.h>
#include <LibWeb/Forward.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/web-messaging.html#message-channels
class MessageChannel final
: public RefCounted<MessageChannel>
, public Bindings::Wrappable {
public:
using WrapperType = Bindings::MessageChannelWrapper;
using RefCounted::ref;
using RefCounted::unref;
static NonnullRefPtr<MessageChannel> create_with_global_object(Bindings::WindowObject& global_object)
{
return adopt_ref(*new MessageChannel(global_object));
}
virtual ~MessageChannel() override;
MessagePort* port1() { return m_port1; }
MessagePort const* port1() const { return m_port1; }
MessagePort* port2() { return m_port2; }
MessagePort const* port2() const { return m_port2; }
private:
explicit MessageChannel(Bindings::WindowObject&);
RefPtr<MessagePort> m_port1;
RefPtr<MessagePort> m_port2;
};
}
|