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

Unified Diff: fpdfsdk/include/javascript/JS_Runtime.h

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/include/javascript/JS_Runtime.h
diff --git a/fpdfsdk/include/javascript/JS_Runtime.h b/fpdfsdk/include/javascript/JS_Runtime.h
index dd21e6d2f14e21525f38378faabc832efe53cb26..6fdc4b0708797a629d97f8fb4232cd03a27713b8 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<CFX_WideString, JS_EVENT_T>;
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<v8::Context> 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<v8::Context> m_context;
+ std::set<Observer*> m_observers;
};
#endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_RUNTIME_H_

Powered by Google App Engine
This is Rietveld 408576698