summaryrefslogtreecommitdiff
path: root/Userland/Services/WebContent/TimerSerenity.cpp
blob: a702ba2eca76b6ed90b8e4dceb9d9a6f8012e953 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include "TimerSerenity.h"
#include <AK/NonnullRefPtr.h>
#include <LibCore/Timer.h>

namespace WebContent {

NonnullRefPtr<TimerSerenity> TimerSerenity::create()
{
    return adopt_ref(*new TimerSerenity);
}

TimerSerenity::TimerSerenity()
    : m_timer(Core::Timer::construct())
{
    m_timer->on_timeout = [this] {
        if (on_timeout)
            on_timeout();
    };
}

TimerSerenity::~TimerSerenity() = default;

void TimerSerenity::start()
{
    m_timer->start();
}

void TimerSerenity::start(int interval_ms)
{
    m_timer->start(interval_ms);
}

void TimerSerenity::restart()
{
    m_timer->restart();
}

void TimerSerenity::restart(int interval_ms)
{
    m_timer->restart(interval_ms);
}

void TimerSerenity::stop()
{
    m_timer->stop();
}

void TimerSerenity::set_active(bool active)
{
    m_timer->set_active(active);
}

bool TimerSerenity::is_active() const
{
    return m_timer->is_active();
}

int TimerSerenity::interval() const
{
    return m_timer->interval();
}

void TimerSerenity::set_interval(int interval_ms)
{
    m_timer->set_interval(interval_ms);
}

bool TimerSerenity::is_single_shot() const
{
    return m_timer->is_single_shot();
}

void TimerSerenity::set_single_shot(bool single_shot)
{
    m_timer->set_single_shot(single_shot);
}

}