From 794c9b67d3d519342aa7e15052766f7d4a99f551 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Sun, 4 Oct 2015 16:01:52 -0700 Subject: 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 . --- fpdfsdk/include/javascript/JS_Runtime.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'fpdfsdk/include/javascript/JS_Runtime.h') diff --git a/fpdfsdk/include/javascript/JS_Runtime.h b/fpdfsdk/include/javascript/JS_Runtime.h index dd21e6d2f1..6fdc4b0708 100644 --- a/fpdfsdk/include/javascript/JS_Runtime.h +++ b/fpdfsdk/include/javascript/JS_Runtime.h @@ -19,6 +19,14 @@ class CJS_Context; class CJS_Runtime : public IFXJS_Runtime { public: + class Observer { + public: + virtual void OnDestroyed() = 0; + + protected: + virtual ~Observer() {} + }; + using FieldEvent = std::pair; explicit CJS_Runtime(CPDFDoc_Environment* pApp); @@ -44,6 +52,9 @@ class CJS_Runtime : public IFXJS_Runtime { v8::Isolate* GetIsolate() const { return m_isolate; } v8::Local NewJSContext(); + void AddObserver(Observer* observer); + void RemoveObserver(Observer* observer); + private: void DefineJSObjects(); @@ -55,6 +66,7 @@ class CJS_Runtime : public IFXJS_Runtime { v8::Isolate* m_isolate; bool m_isolateManaged; v8::Global m_context; + std::set m_observers; }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_RUNTIME_H_ -- cgit v1.2.3