summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-02-04 13:13:05 -0800
committerTom Sepez <tsepez@chromium.org>2016-02-04 13:13:05 -0800
commitf6488cdb6633cd4b32fe08fb124f19c20b3afb59 (patch)
treee5eff7d9fdc9d43c0ce90a16db6d5b6849715a0f /fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
parentcdac3446f26751ff5db4123d87710f8b4e15d11c (diff)
downloadpdfium-f6488cdb6633cd4b32fe08fb124f19c20b3afb59.tar.xz
Kill CFX_PtryArray in CXFA_FWLAdapterTimerMgr.
R=thestig@chromium.org Review URL: https://codereview.chromium.org/1664543005 .
Diffstat (limited to 'fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp')
-rw-r--r--fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp56
1 files changed, 19 insertions, 37 deletions
diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
index 5f8a9f01c5..bd817a45df 100644
--- a/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
+++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
@@ -8,58 +8,40 @@
#include "fpdfsdk/include/fsdk_mgr.h"
#include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
-CFX_PtrArray CXFA_FWLAdapterTimerMgr::ms_timerArray;
+std::vector<CFWL_TimerInfo*> CXFA_FWLAdapterTimerMgr::s_TimerArray;
FWL_ERR CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer* pTimer,
FX_DWORD dwElapse,
FWL_HTIMER& hTimer,
- FX_BOOL bImmediately /* = TRUE */) {
- if (m_pEnv) {
- uint32_t uIDEvent = m_pEnv->FFI_SetTimer(dwElapse, TimerProc);
- CFWL_TimerInfo* pInfo = new CFWL_TimerInfo;
- pInfo->uIDEvent = uIDEvent;
- pInfo->pTimer = pTimer;
- ms_timerArray.Add(pInfo);
-
- hTimer = (FWL_HTIMER)pInfo;
- return FWL_ERR_Succeeded;
- }
+ FX_BOOL bImmediately) {
+ if (!m_pEnv)
+ return FWL_ERR_Indefinite;
- return FWL_ERR_Indefinite;
+ uint32_t uIDEvent = m_pEnv->FFI_SetTimer(dwElapse, TimerProc);
+ s_TimerArray.push_back(new CFWL_TimerInfo(uIDEvent, pTimer));
+ hTimer = reinterpret_cast<FWL_HTIMER>(s_TimerArray.back());
+ return FWL_ERR_Succeeded;
}
FWL_ERR CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer) {
- if (!hTimer)
+ if (!hTimer || !m_pEnv)
return FWL_ERR_Indefinite;
- if (m_pEnv) {
- CFWL_TimerInfo* pInfo = (CFWL_TimerInfo*)hTimer;
-
- m_pEnv->FFI_KillTimer(pInfo->uIDEvent);
-
- int32_t index = ms_timerArray.Find(pInfo);
- if (index >= 0) {
- ms_timerArray.RemoveAt(index);
- delete pInfo;
- }
- return FWL_ERR_Succeeded;
+ CFWL_TimerInfo* pInfo = reinterpret_cast<CFWL_TimerInfo*>(hTimer);
+ m_pEnv->FFI_KillTimer(pInfo->uIDEvent);
+ auto it = std::find(s_TimerArray.begin(), s_TimerArray.end(), pInfo);
+ if (it != s_TimerArray.end()) {
+ s_TimerArray.erase(it);
+ delete pInfo;
}
-
- return FWL_ERR_Indefinite;
+ return FWL_ERR_Succeeded;
}
void CXFA_FWLAdapterTimerMgr::TimerProc(int32_t idEvent) {
- CFWL_TimerInfo* pInfo = NULL;
- int32_t iCount = CXFA_FWLAdapterTimerMgr::ms_timerArray.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- CFWL_TimerInfo* pTemp =
- (CFWL_TimerInfo*)CXFA_FWLAdapterTimerMgr::ms_timerArray.GetAt(i);
- if (pTemp->uIDEvent == idEvent) {
- pInfo = pTemp;
+ for (CFWL_TimerInfo* pInfo : s_TimerArray) {
+ if (pInfo->uIDEvent == idEvent) {
+ pInfo->pTimer->Run(reinterpret_cast<FWL_HTIMER>(pInfo));
break;
}
}
- if (pInfo) {
- pInfo->pTimer->Run((FWL_HTIMER)pInfo);
- }
}