summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/cjs_runtime.h
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-09-08 10:25:55 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-08 10:25:55 -0700
commit8832fbf53cf71d4d4cb53986d9cfc024edd2bf1f (patch)
tree00e9dbcc91f89f95552bac3326ac828f8b495507 /fpdfsdk/javascript/cjs_runtime.h
parentd827111fb10c7d8b89bc954ab0934b4009d6643c (diff)
downloadpdfium-8832fbf53cf71d4d4cb53986d9cfc024edd2bf1f.tar.xz
Replace CJS_Runtime::Observer with CFX_Runtime<CJS_Runtime>::Observer
Previously, the observer set a flag which conditionalized a null pointer return. Now, we just clear the pointer. Destruction order matters, so add a method to trigger notifications. Review-Url: https://codereview.chromium.org/2322743002
Diffstat (limited to 'fpdfsdk/javascript/cjs_runtime.h')
-rw-r--r--fpdfsdk/javascript/cjs_runtime.h17
1 files changed, 4 insertions, 13 deletions
diff --git a/fpdfsdk/javascript/cjs_runtime.h b/fpdfsdk/javascript/cjs_runtime.h
index 33d2956ce3..5157c416ad 100644
--- a/fpdfsdk/javascript/cjs_runtime.h
+++ b/fpdfsdk/javascript/cjs_runtime.h
@@ -13,6 +13,7 @@
#include <utility>
#include <vector>
+#include "core/fxcrt/include/cfx_observable.h"
#include "core/fxcrt/include/fx_basic.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/ijs_runtime.h"
@@ -20,16 +21,10 @@
class CJS_Context;
-class CJS_Runtime : public IJS_Runtime, public CFXJS_Engine {
+class CJS_Runtime : public IJS_Runtime,
+ public CFXJS_Engine,
+ public CFX_Observable<CJS_Runtime> {
public:
- class Observer {
- public:
- virtual void OnDestroyed() = 0;
-
- protected:
- virtual ~Observer() {}
- };
-
using FieldEvent = std::pair<CFX_WideString, JS_EVENT_T>;
static CJS_Runtime* FromContext(const IJS_Context* cc);
@@ -64,9 +59,6 @@ class CJS_Runtime : public IJS_Runtime, public CFXJS_Engine {
CFXJSE_Value* pValue) override;
#endif // PDF_ENABLE_XFA
- void AddObserver(Observer* observer);
- void RemoveObserver(Observer* observer);
-
private:
void DefineJSObjects();
@@ -76,7 +68,6 @@ class CJS_Runtime : public IJS_Runtime, public CFXJS_Engine {
bool m_bBlocking;
bool m_isolateManaged;
std::set<FieldEvent> m_FieldEventSet;
- std::set<Observer*> m_observers;
};
#endif // FPDFSDK_JAVASCRIPT_CJS_RUNTIME_H_