aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/BunWorkerGlobalScope.h
blob: 7672897168195b90c050d76a06da9a7dd5f1e575 (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
34
35
36
37
38
#include "root.h"

#include "EventTarget.h"
#include "ContextDestructionObserver.h"
#include "ExceptionOr.h"
#include <wtf/URL.h>
#include <wtf/HashSet.h>
#include <wtf/Lock.h>

namespace Bun {
class GlobalScope final : public RefCounted<GlobalScope>, public EventTargetWithInlineData {
    WTF_MAKE_ISO_ALLOCATED(GlobalScope);

public:
    GlobalScope(ScriptExecutionContext* context)
        : EventTargetWithInlineData()
        , m_context(context)
    {
    }
    using RefCounted::deref;
    using RefCounted::ref;

    static Ref<GlobalScope> create(ScriptExecutionContext* context)
    {
        return adoptRef(*new GlobalScope(context));
    }

    ~GlobalScope() = default;

    EventTargetInterface eventTargetInterface() const final { return EventTargetInterface::DOMWindowEventTargetInterfaceType; }
    ScriptExecutionContext* scriptExecutionContext() const final { return m_context; }
    void refEventTarget() final { ref(); }
    void derefEventTarget() final { deref(); }
    void eventListenersDidChange() final {}

    ScriptExecutionContext* m_context;
};
}