summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/JS_Runtime.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-04 16:01:52 -0700
committerLei Zhang <thestig@chromium.org>2015-10-04 16:01:52 -0700
commit794c9b67d3d519342aa7e15052766f7d4a99f551 (patch)
treee21fdbf59ce171b978126b9f94e69085ff30d211 /fpdfsdk/src/javascript/JS_Runtime.cpp
parent4f277fc8d41303cbf007335dfbbff60b81fffde0 (diff)
downloadpdfium-794c9b67d3d519342aa7e15052766f7d4a99f551.tar.xz
CJS_Timer should observe CJS_Runtime destruction.
Also remove dead CJS_EmbedObj::{Begin,End}Timer code. BUG=539107 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1384883002 .
Diffstat (limited to 'fpdfsdk/src/javascript/JS_Runtime.cpp')
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index 5c463ce498..4c502a7b75 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,16 @@ v8::Local<v8::Context> CJS_Runtime::NewJSContext() {
return v8::Local<v8::Context>::New(m_isolate, m_context);
}
+void CJS_Runtime::AddObserver(Observer* observer) {
+ ASSERT(m_observers.find(observer) == m_observers.end());
+ m_observers.insert(observer);
+}
+
+void CJS_Runtime::RemoveObserver(Observer* observer) {
+ ASSERT(m_observers.find(observer) != m_observers.end());
+ m_observers.erase(observer);
+}
+
CFX_WideString ChangeObjName(const CFX_WideString& str) {
CFX_WideString sRet = str;
sRet.Replace(L"_", L".");