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

Unified Diff: fpdfsdk/src/javascript/app.cpp

Issue 1384883002: CJS_Timer should observe CJS_Runtime destruction. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 2 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/src/javascript/JS_Runtime.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/javascript/app.cpp
diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp
index 9d4fa9ca137e375095138fb40964284f54b93784..067ae108bda8cd02fbc90c114f9290f761285f8f 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -408,16 +408,10 @@ FX_BOOL app::setInterval(IFXJS_Context* cc,
CPDFDoc_Environment* pApp = pRuntime->GetReaderApp();
ASSERT(pApp);
- CJS_Timer* pTimer = new CJS_Timer(this, pApp);
+ CJS_Timer* pTimer =
+ new CJS_Timer(this, pApp, pRuntime, 0, script, dwInterval, 0);
m_aTimer.Add(pTimer);
- pTimer->SetType(0);
- pTimer->SetRuntime(pRuntime);
- pTimer->SetJScript(script);
- pTimer->SetTimeOut(0);
- // pTimer->SetStartTime(GetTickCount());
- pTimer->SetJSTimer(dwInterval);
-
v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
pRuntime->GetIsolate(), pContext,
FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj"));
@@ -462,15 +456,10 @@ FX_BOOL app::setTimeOut(IFXJS_Context* cc,
CPDFDoc_Environment* pApp = pRuntime->GetReaderApp();
ASSERT(pApp);
- CJS_Timer* pTimer = new CJS_Timer(this, pApp);
+ CJS_Timer* pTimer =
+ new CJS_Timer(this, pApp, pRuntime, 1, script, dwTimeOut, dwTimeOut);
m_aTimer.Add(pTimer);
- pTimer->SetType(1);
- pTimer->SetRuntime(pRuntime);
- pTimer->SetJScript(script);
- pTimer->SetTimeOut(dwTimeOut);
- pTimer->SetJSTimer(dwTimeOut);
-
v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
pRuntime->GetIsolate(), pContext,
FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj"));
@@ -585,13 +574,17 @@ FX_BOOL app::execMenuItem(IFXJS_Context* cc,
void app::TimerProc(CJS_Timer* pTimer) {
ASSERT(pTimer != NULL);
+ CJS_Runtime* pRuntime = pTimer->GetRuntime();
+
switch (pTimer->GetType()) {
case 0: // interval
- RunJsScript(pTimer->GetRuntime(), pTimer->GetJScript());
+ if (pRuntime)
+ RunJsScript(pRuntime, pTimer->GetJScript());
break;
case 1:
if (pTimer->GetTimeOut() > 0) {
- RunJsScript(pTimer->GetRuntime(), pTimer->GetJScript());
+ if (pRuntime)
+ RunJsScript(pRuntime, pTimer->GetJScript());
pTimer->KillJSTimer();
}
break;
« no previous file with comments | « fpdfsdk/src/javascript/JS_Runtime.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698