Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(880)

Unified Diff: fpdfsdk/javascript/JS_Object.cpp

Issue 2222043002: Rename CJS_Timer to GlobalTimer and make private to app.cpp (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix comment in app.h Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/javascript/JS_Object.h ('k') | fpdfsdk/javascript/app.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/javascript/JS_Object.cpp
diff --git a/fpdfsdk/javascript/JS_Object.cpp b/fpdfsdk/javascript/JS_Object.cpp
index b65699a18bffd43c8ff59b5af42e6fc64f1a131e..e72d0f3872b769a372b70fa8ab7041d694ce4be8 100644
--- a/fpdfsdk/javascript/JS_Object.cpp
+++ b/fpdfsdk/javascript/JS_Object.cpp
@@ -72,85 +72,3 @@ void CJS_Object::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg) {
if (pApp)
pApp->JS_appAlert(swMsg, nullptr, 0, 3);
}
-
-CJS_Timer::CJS_Timer(CJS_EmbedObj* pObj,
- CPDFDoc_Environment* pApp,
- CJS_Runtime* pRuntime,
- int nType,
- const CFX_WideString& script,
- uint32_t dwElapse,
- uint32_t dwTimeOut)
- : m_nTimerID(0),
- m_pEmbedObj(pObj),
- m_bProcessing(false),
- m_bValid(true),
- m_nType(nType),
- m_dwTimeOut(dwTimeOut),
- m_swJScript(script),
- m_pRuntime(pRuntime),
- m_pApp(pApp) {
- CFX_SystemHandler* pHandler = m_pApp->GetSysHandler();
- m_nTimerID = pHandler->SetTimer(dwElapse, Trigger);
- (*GetGlobalTimerMap())[m_nTimerID] = this;
- m_pRuntime->AddObserver(this);
-}
-
-CJS_Timer::~CJS_Timer() {
- CJS_Runtime* pRuntime = GetRuntime();
- if (pRuntime)
- pRuntime->RemoveObserver(this);
-
- if (!m_nTimerID)
- return;
-
- if (m_bValid)
- m_pApp->GetSysHandler()->KillTimer(m_nTimerID);
-
- GetGlobalTimerMap()->erase(m_nTimerID);
-}
-
-// static
-void CJS_Timer::Trigger(int nTimerID) {
- auto it = GetGlobalTimerMap()->find(nTimerID);
- if (it == GetGlobalTimerMap()->end())
- return;
-
- CJS_Timer* pTimer = it->second;
- if (pTimer->m_bProcessing)
- return;
-
- pTimer->m_bProcessing = true;
- if (pTimer->m_pEmbedObj)
- pTimer->m_pEmbedObj->TimerProc(pTimer);
-
- // Timer proc may have destroyed timer, find it again.
- it = GetGlobalTimerMap()->find(nTimerID);
- if (it == GetGlobalTimerMap()->end())
- return;
-
- pTimer = it->second;
- pTimer->m_bProcessing = false;
- if (pTimer->IsOneShot())
- pTimer->m_pEmbedObj->CancelProc(pTimer);
-}
-
-// static
-void CJS_Timer::Cancel(int nTimerID) {
- auto it = GetGlobalTimerMap()->find(nTimerID);
- if (it == GetGlobalTimerMap()->end())
- return;
-
- CJS_Timer* pTimer = it->second;
- pTimer->m_pEmbedObj->CancelProc(pTimer);
-}
-
-// static
-CJS_Timer::TimerMap* CJS_Timer::GetGlobalTimerMap() {
- // Leak the timer array at shutdown.
- static auto* s_TimerMap = new TimerMap;
- return s_TimerMap;
-}
-
-void CJS_Timer::OnDestroyed() {
- m_bValid = false;
-}
« no previous file with comments | « fpdfsdk/javascript/JS_Object.h ('k') | fpdfsdk/javascript/app.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698