aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/webcore/BunBroadcastChannelRegistry.h
blob: 5576b732e5c89a0e193393440d53ce9edd004313 (plain) (blame)
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
#pragma once

#include "BroadcastChannelRegistry.h"
#include "wtf/CallbackAggregator.h"
#include "wtf/Vector.h"
#include "wtf/HashMap.h"

namespace WebCore {

struct MessageWithMessagePorts;

class BunBroadcastChannelRegistry final : public BroadcastChannelRegistry {
public:
    BunBroadcastChannelRegistry() = default;
    static Ref<BunBroadcastChannelRegistry> create()
    {
        return adoptRef(*new BunBroadcastChannelRegistry);
    }

    void registerChannel(const String& name, BroadcastChannelIdentifier) final;
    void unregisterChannel(const String& name, BroadcastChannelIdentifier) final;
    void postMessage(const String& name, BroadcastChannelIdentifier source, Ref<SerializedScriptValue>&&) final;

    // void didReceivedMessage(IPC::Connection&, IPC::Decoder&);

    HashMap<String, Vector<BroadcastChannelIdentifier>> m_channelsForName;

private:
    void postMessageToRemote(const String& name, MessageWithMessagePorts&&);
    void postMessageLocally(const String& name, BroadcastChannelIdentifier sourceInProgress, Ref<SerializedScriptValue>&&);
};

}