From 6f4f2335cfd22d26db154fbd51ab553fb9902918 Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 6 Jun 2016 13:23:55 -0700 Subject: Remove FWL_HTIMER in favor of IWFL_TimerInfo Review-Url: https://codereview.chromium.org/2037573003 --- fpdfsdk/fpdfxfa/fpdfxfa_util.cpp | 15 ++++++++------- fpdfsdk/fpdfxfa/include/fpdfxfa_util.h | 13 +++++++------ 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'fpdfsdk/fpdfxfa') diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp index b6deaef17b..9971f5d165 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp @@ -15,24 +15,25 @@ std::vector* CXFA_FWLAdapterTimerMgr::s_TimerArray = nullptr; FWL_Error CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer* pTimer, uint32_t dwElapse, - FWL_HTIMER& hTimer, - FX_BOOL bImmediately) { + bool bImmediately, + IFWL_TimerInfo** pTimerInfo) { if (!m_pEnv) return FWL_Error::Indefinite; int32_t id_event = m_pEnv->FFI_SetTimer(dwElapse, TimerProc); if (!s_TimerArray) s_TimerArray = new std::vector; + s_TimerArray->push_back(new CFWL_TimerInfo(id_event, pTimer)); - hTimer = reinterpret_cast(s_TimerArray->back()); + *pTimerInfo = s_TimerArray->back(); return FWL_Error::Succeeded; } -FWL_Error CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer) { - if (!hTimer || !m_pEnv) +FWL_Error CXFA_FWLAdapterTimerMgr::Stop(IFWL_TimerInfo* pTimerInfo) { + if (!pTimerInfo || !m_pEnv) return FWL_Error::Indefinite; - CFWL_TimerInfo* pInfo = reinterpret_cast(hTimer); + CFWL_TimerInfo* pInfo = static_cast(pTimerInfo); m_pEnv->FFI_KillTimer(pInfo->idEvent); if (s_TimerArray) { auto it = std::find(s_TimerArray->begin(), s_TimerArray->end(), pInfo); @@ -51,7 +52,7 @@ void CXFA_FWLAdapterTimerMgr::TimerProc(int32_t idEvent) { for (CFWL_TimerInfo* pInfo : *s_TimerArray) { if (pInfo->idEvent == idEvent) { - pInfo->pTimer->Run(reinterpret_cast(pInfo)); + pInfo->pTimer->Run(pInfo); break; } } diff --git a/fpdfsdk/fpdfxfa/include/fpdfxfa_util.h b/fpdfsdk/fpdfxfa/include/fpdfxfa_util.h index dce9a74229..fb5bd0d1b7 100644 --- a/fpdfsdk/fpdfxfa/include/fpdfxfa_util.h +++ b/fpdfsdk/fpdfxfa/include/fpdfxfa_util.h @@ -22,11 +22,12 @@ struct CFWL_TimerInfo; class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr { public: CXFA_FWLAdapterTimerMgr(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv) {} - virtual FWL_Error Start(IFWL_Timer* pTimer, - uint32_t dwElapse, - FWL_HTIMER& hTimer, - FX_BOOL bImmediately = TRUE); - virtual FWL_Error Stop(FWL_HTIMER hTimer); + + FWL_Error Start(IFWL_Timer* pTimer, + uint32_t dwElapse, + bool bImmediately, + IFWL_TimerInfo** pTimerInfo) override; + FWL_Error Stop(IFWL_TimerInfo* pTimerInfo) override; protected: static void TimerProc(int32_t idEvent); @@ -35,7 +36,7 @@ class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr { CPDFDoc_Environment* const m_pEnv; }; -struct CFWL_TimerInfo { +struct CFWL_TimerInfo : public IFWL_TimerInfo { CFWL_TimerInfo() : pTimer(nullptr) {} CFWL_TimerInfo(int32_t event, IFWL_Timer* timer) : idEvent(event), pTimer(timer) {} -- cgit v1.2.3