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

Unified Diff: fpdfsdk/src/javascript/JS_Runtime.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
Index: fpdfsdk/src/javascript/JS_Runtime.cpp
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index 5c463ce498803081c76c4debacf635f775db6cc4..b28d403db8ff0cddf15367ecaa51407a55d2001c 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -12,7 +12,6 @@
#include "../../include/javascript/JS_Define.h"
#include "../../include/javascript/JS_Object.h"
#include "../../include/javascript/JS_Value.h"
-#include "../../include/javascript/Document.h"
#include "../../include/javascript/app.h"
#include "../../include/javascript/color.h"
#include "../../include/javascript/Consts.h"
@@ -54,6 +53,9 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
}
CJS_Runtime::~CJS_Runtime() {
+ for (auto* obs : m_observers)
+ obs->OnDestroyed();
+
for (int i = 0, sz = m_ContextArray.GetSize(); i < sz; i++)
delete m_ContextArray.GetAt(i);
@@ -176,6 +178,14 @@ v8::Local<v8::Context> CJS_Runtime::NewJSContext() {
return v8::Local<v8::Context>::New(m_isolate, m_context);
}
+void CJS_Runtime::AddObserver(Observer* observer) {
+ m_observers.insert(observer);
Tom Sepez 2015/10/04 22:39:38 nit: do we want to assert it isn't already in ther
Lei Zhang 2015/10/04 23:01:28 Sure. I put it as: ASSERT(m_observers.find(observ
+}
+
+void CJS_Runtime::RemoveObserver(Observer* observer) {
+ m_observers.erase(observer);
+}
+
CFX_WideString ChangeObjName(const CFX_WideString& str) {
CFX_WideString sRet = str;
sRet.Replace(L"_", L".");

Powered by Google App Engine
This is Rietveld 408576698