From 9a817f092e6800e9338b41acf4ea0416b6ad4467 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 14 Sep 2015 14:32:33 -0700 Subject: Get CJS_RuntimeFactory out of the CJS_GlobalData management business. First part of getting rid of CJS_RuntimeFactory. The factory design pattern isn't appropriate here since we only ever make one kind of object. CJS_GlobalData is now perfectly capable of managing itself through internal ref counts. I'm philosophically opposed to keeping ref-counts outside the object (do you hear me std::shared_ptr, you're bad!) R=thestig@chromium.org Review URL: https://codereview.chromium.org/1338993005 . --- fpdfsdk/include/javascript/JS_GlobalData.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'fpdfsdk/include/javascript/JS_GlobalData.h') diff --git a/fpdfsdk/include/javascript/JS_GlobalData.h b/fpdfsdk/include/javascript/JS_GlobalData.h index 607eec79bd..98a963d87b 100644 --- a/fpdfsdk/include/javascript/JS_GlobalData.h +++ b/fpdfsdk/include/javascript/JS_GlobalData.h @@ -58,10 +58,9 @@ class CJS_GlobalData_Element { class CJS_GlobalData { public: - CJS_GlobalData(CPDFDoc_Environment* pApp); - virtual ~CJS_GlobalData(); + static CJS_GlobalData* GetRetainedInstance(CPDFDoc_Environment* pApp); + void Release(); - public: void SetGlobalVariableNumber(const FX_CHAR* propname, double dData); void SetGlobalVariableBoolean(const FX_CHAR* propname, bool bData); void SetGlobalVariableString(const FX_CHAR* propname, @@ -78,6 +77,11 @@ class CJS_GlobalData { CJS_GlobalData_Element* GetAt(int index) const; private: + static CJS_GlobalData* g_Instance; + + CJS_GlobalData(CPDFDoc_Environment* pApp); + ~CJS_GlobalData(); + void LoadGlobalPersistentVariables(); void SaveGlobalPersisitentVariables(); @@ -95,6 +99,7 @@ class CJS_GlobalData { CFX_BinaryBuf& sData); private: + size_t m_RefCount; CFX_ArrayTemplate m_arrayGlobalData; CFX_WideString m_sFilePath; }; -- cgit v1.2.3