Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cfx_timer.cpp
Go to the documentation of this file.
1
// Copyright 2017 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7
#
include
"core/fxcrt/cfx_timer.h"
8
9
#
include
<
map
>
10
11
#
include
"core/fxcrt/check.h"
12
13
namespace
{
14
15
using
TimerMap = std::map<int32_t, CFX_Timer*>;
16
TimerMap* g_pwl_timer_map =
nullptr
;
17
18
}
// namespace
19
20
// static
21
void
CFX_Timer
::
InitializeGlobals
() {
22
CHECK
(!g_pwl_timer_map);
23
g_pwl_timer_map =
new
TimerMap();
24
}
25
26
// static
27
void
CFX_Timer
::
DestroyGlobals
() {
28
delete
g_pwl_timer_map;
29
g_pwl_timer_map =
nullptr
;
30
}
31
32
CFX_Timer
::
CFX_Timer
(
HandlerIface
* pHandlerIface,
33
CallbackIface
* pCallbackIface,
34
int32_t nInterval)
35
:
m_pHandlerIface
(
pHandlerIface
),
m_pCallbackIface
(
pCallbackIface
) {
36
DCHECK
(m_pCallbackIface);
37
if
(m_pHandlerIface) {
38
m_nTimerID = m_pHandlerIface->SetTimer(nInterval, TimerProc);
39
if
(
HasValidID
(
)
)
40
(*g_pwl_timer_map)[m_nTimerID] =
this
;
41
}
42
}
43
44
CFX_Timer
::~
CFX_Timer
() {
45
if
(
HasValidID
(
)
) {
46
g_pwl_timer_map->erase(m_nTimerID);
47
if
(m_pHandlerIface)
48
m_pHandlerIface->KillTimer(m_nTimerID);
49
}
50
}
51
52
// static
53
void
CFX_Timer
::TimerProc(int32_t idEvent) {
54
auto
it = g_pwl_timer_map->find(idEvent);
55
if
(it != g_pwl_timer_map->end()) {
56
it->second->m_pCallbackIface->OnTimerFired();
57
}
58
}
DCHECK
#define DCHECK
Definition
check.h:33
CFX_Timer::CallbackIface
Definition
cfx_timer.h:32
CFX_Timer::HandlerIface
Definition
cfx_timer.h:19
CFX_Timer
Definition
cfx_timer.h:15
CFX_Timer::HasValidID
bool HasValidID() const
Definition
cfx_timer.h:46
CFX_Timer::DestroyGlobals
static void DestroyGlobals()
Definition
cfx_timer.cpp:27
CFX_Timer::CFX_Timer
CFX_Timer(HandlerIface *pHandlerIface, CallbackIface *pCallbackIface, int32_t nInterval)
Definition
cfx_timer.cpp:32
CFX_Timer::~CFX_Timer
~CFX_Timer()
Definition
cfx_timer.cpp:44
CFX_Timer::InitializeGlobals
static void InitializeGlobals()
Definition
cfx_timer.cpp:21
CHECK
#define CHECK(cvref)
Definition
q23utility.cpp:15
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fxcrt
cfx_timer.cpp
Generated on
for Qt by
1.18.0