summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h
blob: 3ceda83407c57406f34c8b717da6a9cc4df637e1 (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
/*
 * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 * Copyright (c) 2022, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/StdLibExtras.h>
#include <LibWeb/Bindings/Wrappable.h>

namespace Web::RequestIdleCallback {

class IdleDeadline final
    : public RefCounted<IdleDeadline>
    , public Bindings::Wrappable {
public:
    using WrapperType = Bindings::IdleDeadlineWrapper;
    using AllowOwnPtr = TrueType;

    static NonnullRefPtr<IdleDeadline> create(bool did_timeout = false);
    virtual ~IdleDeadline() override;

    double time_remaining() const;
    bool did_timeout() const { return m_did_timeout; }

private:
    IdleDeadline(bool did_timeout);

    bool m_did_timeout { false };
};

}