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

Unified Diff: fpdfsdk/javascript/app.cpp

Issue 2322743002: Replace CJS_Runtime::Observer with CFX_Runtime<CJS_Runtime>::Observer (Closed)
Patch Set: Order matters Created 4 years, 3 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 | « core/fxcrt/include/cfx_observable.h ('k') | fpdfsdk/javascript/cjs_runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/javascript/app.cpp
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index f95ec0b09b9eaeed40f3b08e9e483485235286e2..89e8b563daa99b877470386723a936f84f30fc52 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -30,7 +30,7 @@ class GlobalTimer : public CJS_Runtime::Observer {
const CFX_WideString& script,
uint32_t dwElapse,
uint32_t dwTimeOut);
- ~GlobalTimer() override;
+ ~GlobalTimer();
static void Trigger(int nTimerID);
static void Cancel(int nTimerID);
@@ -38,26 +38,22 @@ class GlobalTimer : public CJS_Runtime::Observer {
bool IsOneShot() const { return m_nType == 1; }
uint32_t GetTimeOut() const { return m_dwTimeOut; }
int GetTimerID() const { return m_nTimerID; }
- CJS_Runtime* GetRuntime() const { return m_bValid ? m_pRuntime : nullptr; }
+ CJS_Runtime* GetRuntime() const { return m_pRuntime; }
CFX_WideString GetJScript() const { return m_swJScript; }
private:
using TimerMap = std::map<FX_UINT, GlobalTimer*>;
static TimerMap* GetGlobalTimerMap();
- // CJS_Runtime::Observer
- void OnDestroyed() override;
-
uint32_t m_nTimerID;
app* const m_pEmbedObj;
bool m_bProcessing;
- bool m_bValid;
// data
const int m_nType; // 0:Interval; 1:TimeOut
const uint32_t m_dwTimeOut;
const CFX_WideString m_swJScript;
- CJS_Runtime* const m_pRuntime;
+ CJS_Runtime* m_pRuntime;
CPDFDoc_Environment* const m_pApp;
};
@@ -71,7 +67,6 @@ GlobalTimer::GlobalTimer(app* pObj,
: m_nTimerID(0),
m_pEmbedObj(pObj),
m_bProcessing(false),
- m_bValid(true),
m_nType(nType),
m_dwTimeOut(dwTimeOut),
m_swJScript(script),
@@ -80,18 +75,14 @@ GlobalTimer::GlobalTimer(app* pObj,
CFX_SystemHandler* pHandler = m_pApp->GetSysHandler();
m_nTimerID = pHandler->SetTimer(dwElapse, Trigger);
(*GetGlobalTimerMap())[m_nTimerID] = this;
- m_pRuntime->AddObserver(this);
+ SetWatchedPtr(&m_pRuntime);
}
GlobalTimer::~GlobalTimer() {
- CJS_Runtime* pRuntime = GetRuntime();
- if (pRuntime)
- pRuntime->RemoveObserver(this);
-
if (!m_nTimerID)
return;
- if (m_bValid)
+ if (GetRuntime())
m_pApp->GetSysHandler()->KillTimer(m_nTimerID);
GetGlobalTimerMap()->erase(m_nTimerID);
@@ -139,10 +130,6 @@ GlobalTimer::TimerMap* GlobalTimer::GetGlobalTimerMap() {
return s_TimerMap;
}
-void GlobalTimer::OnDestroyed() {
- m_bValid = false;
-}
-
BEGIN_JS_STATIC_CONST(CJS_TimerObj)
END_JS_STATIC_CONST()
« no previous file with comments | « core/fxcrt/include/cfx_observable.h ('k') | fpdfsdk/javascript/cjs_runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698