diff options
author | Lei Zhang <thestig@chromium.org> | 2015-10-05 17:00:03 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-10-05 17:00:03 -0700 |
commit | 2d5a0e173f3bb8335cf302f1194305c2f9e65bed (patch) | |
tree | 9e82cf609b817dfc153a1506ed2b2188663275d5 /fpdfsdk/src/javascript/JS_Runtime.cpp | |
parent | ca70a69f4b5ac05eb7e054cfa014d219b915f632 (diff) | |
download | pdfium-2d5a0e173f3bb8335cf302f1194305c2f9e65bed.tar.xz |
Merge to XFA: 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 .
(cherry picked from commit 794c9b67d3d519342aa7e15052766f7d4a99f551)
Review URL: https://codereview.chromium.org/1386053002 .
Diffstat (limited to 'fpdfsdk/src/javascript/JS_Runtime.cpp')
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp index 998f45ff10..49d235cbee 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -11,7 +11,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" @@ -77,6 +76,9 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) } CJS_Runtime::~CJS_Runtime() { + for (auto* obs : m_observers) + obs->OnDestroyed(); + int size = m_ContextArray.GetSize(); for (int i = 0; i < size; i++) delete m_ContextArray.GetAt(i); @@ -256,3 +258,13 @@ FX_BOOL CJS_Runtime::SetHValueByName(const CFX_ByteStringC& utf8Name, return TRUE; } + +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); +} |