7#include "fxjs/global_timer.h"
11#include "core/fxcrt/cfx_timer.h"
12#include "fxjs/cjs_app.h"
13#include "third_party/base/check.h"
14#include "third_party/base/containers/contains.h"
18using TimerMap = std::map<int32_t, GlobalTimer*>;
19TimerMap* g_global_timer_map =
nullptr;
25 CHECK(!g_global_timer_map);
26 g_global_timer_map =
new TimerMap();
31 delete g_global_timer_map;
32 g_global_timer_map =
nullptr;
36 CJS_Runtime* pRuntime,
38 const WideString& script,
43 m_dwTimeOut(dwTimeOut),
48 DCHECK(!pdfium::Contains((*g_global_timer_map), m_nTimerID));
49 (*g_global_timer_map)[m_nTimerID] =
this;
57 if (m_pRuntime && m_pRuntime->GetTimerHandler())
58 m_pRuntime->GetTimerHandler()->KillTimer(m_nTimerID);
60 DCHECK(pdfium::Contains((*g_global_timer_map), m_nTimerID));
61 g_global_timer_map->erase(m_nTimerID);
66 auto it = g_global_timer_map->find(nTimerID);
67 if (it == g_global_timer_map->end()) {
72 if (pTimer->m_bProcessing)
75 pTimer->m_bProcessing =
true;
76 if (pTimer->m_pEmbedApp)
77 pTimer->m_pEmbedApp->TimerProc(pTimer);
80 it = g_global_timer_map->find(nTimerID);
81 if (it == g_global_timer_map->end()) {
86 pTimer->m_bProcessing =
false;
88 pTimer->m_pEmbedApp->CancelProc(pTimer);
93 auto it = g_global_timer_map->find(nTimerID);
94 if (it == g_global_timer_map->end()) {
99 pTimer->m_pEmbedApp->CancelProc(pTimer);
static constexpr int32_t kInvalidTimerID
virtual int32_t SetTimer(int32_t uElapse, TimerCallback lpTimerFunc)=0
CFX_Timer::HandlerIface * GetTimerHandler() const
static void DestroyGlobals()
static void InitializeGlobals()
GlobalTimer(CJS_App *pObj, CJS_Runtime *pRuntime, Type nType, const WideString &script, uint32_t dwElapse, uint32_t dwTimeOut)
static void Trigger(int32_t nTimerID)
static void Cancel(int32_t nTimerID)