summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM/AbortController.h
blob: 040ed58a2e3438eeb1d932f65e2a40005eae6b9b (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
/*
 * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/AbortSignal.h>

namespace Web::DOM {

// https://dom.spec.whatwg.org/#abortcontroller
class AbortController final : public Bindings::PlatformObject {
    WEB_PLATFORM_OBJECT(AbortController, Bindings::PlatformObject);

public:
    static JS::NonnullGCPtr<AbortController> construct_impl(JS::Realm&);

    virtual ~AbortController() override;

    // https://dom.spec.whatwg.org/#dom-abortcontroller-signal
    JS::NonnullGCPtr<AbortSignal> signal() const { return *m_signal; }

    void abort(JS::Value reason);

private:
    AbortController(JS::Realm&, JS::NonnullGCPtr<AbortSignal>);

    virtual void visit_edges(Cell::Visitor&) override;

    // https://dom.spec.whatwg.org/#abortcontroller-signal
    JS::NonnullGCPtr<AbortSignal> m_signal;
};

}