From ddffb57cf9763e2612e9f6f5730f334691adb692 Mon Sep 17 00:00:00 2001 From: tsepez Date: Tue, 24 May 2016 16:20:29 -0700 Subject: Remove CFX_PrivateData from CPDF_ModuleMgr Its only used to store one object, so replace it with a unique_ptr to a class with a virtual dtor. Rename the prototypical class with virtual dtor from CFX_DestructObject to CFX_Deletable. Rename the fx_basic_module.cpp to cfx_modulemgr.cpp to match the one class in it. Review-Url: https://codereview.chromium.org/2013483003 --- fpdfsdk/fpdf_ext.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/fpdf_ext.cpp b/fpdfsdk/fpdf_ext.cpp index 350945e328..0a76a0d4be 100644 --- a/fpdfsdk/fpdf_ext.cpp +++ b/fpdfsdk/fpdf_ext.cpp @@ -11,6 +11,7 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" +#include "core/fxcrt/include/fx_basic.h" #include "core/fxcrt/include/fx_xml.h" #include "fpdfsdk/include/fsdk_define.h" @@ -20,7 +21,7 @@ #define FPDFSDK_UNSUPPORT_CALL 100 -class CFSDK_UnsupportInfo_Adapter { +class CFSDK_UnsupportInfo_Adapter : public CFX_Deletable { public: explicit CFSDK_UnsupportInfo_Adapter(UNSUPPORT_INFO* unsp_info) : m_unsp_info(unsp_info) {} @@ -37,18 +38,13 @@ void CFSDK_UnsupportInfo_Adapter::ReportError(int nErrorType) { } } -void FreeUnsupportInfo(void* pData) { - CFSDK_UnsupportInfo_Adapter* pAdapter = (CFSDK_UnsupportInfo_Adapter*)pData; - delete pAdapter; -} - FX_BOOL FPDF_UnSupportError(int nError) { CFSDK_UnsupportInfo_Adapter* pAdapter = - (CFSDK_UnsupportInfo_Adapter*)CPDF_ModuleMgr::Get()->GetPrivateData( - (void*)FPDFSDK_UNSUPPORT_CALL); - + static_cast( + CPDF_ModuleMgr::Get()->GetUnsupportInfoAdapter()); if (!pAdapter) return FALSE; + pAdapter->ReportError(nError); return TRUE; } @@ -57,12 +53,9 @@ DLLEXPORT FPDF_BOOL STDCALL FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info) { if (!unsp_info || unsp_info->version != 1) return FALSE; - CFSDK_UnsupportInfo_Adapter* pAdapter = - new CFSDK_UnsupportInfo_Adapter(unsp_info); - - CPDF_ModuleMgr::Get()->SetPrivateData((void*)FPDFSDK_UNSUPPORT_CALL, pAdapter, - &FreeUnsupportInfo); + CPDF_ModuleMgr::Get()->SetUnsupportInfoAdapter(std::unique_ptr( + new CFSDK_UnsupportInfo_Adapter(unsp_info))); return TRUE; } -- cgit v1.2.3