diff options
author | tsepez <tsepez@chromium.org> | 2016-05-24 16:20:29 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-24 16:20:29 -0700 |
commit | ddffb57cf9763e2612e9f6f5730f334691adb692 (patch) | |
tree | 9f7798eb5eb71fb5cb40aadc1da940891c71aa0b /fpdfsdk/fpdf_ext.cpp | |
parent | 5aaa9bc9193d74bb188dd1f890140cf38fb06605 (diff) | |
download | pdfium-ddffb57cf9763e2612e9f6f5730f334691adb692.tar.xz |
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
Diffstat (limited to 'fpdfsdk/fpdf_ext.cpp')
-rw-r--r-- | fpdfsdk/fpdf_ext.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
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<CFSDK_UnsupportInfo_Adapter*>( + 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<CFX_Deletable>( + new CFSDK_UnsupportInfo_Adapter(unsp_info))); return TRUE; } |