summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-24 16:20:29 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-24 16:20:29 -0700
commitddffb57cf9763e2612e9f6f5730f334691adb692 (patch)
tree9f7798eb5eb71fb5cb40aadc1da940891c71aa0b /core
parent5aaa9bc9193d74bb188dd1f890140cf38fb06605 (diff)
downloadpdfium-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 'core')
-rw-r--r--core/fpdfapi/cpdf_modulemgr.cpp (renamed from core/fpdfapi/fpdf_basic_module.cpp)10
-rw-r--r--core/fpdfapi/include/cpdf_modulemgr.h19
-rw-r--r--core/fxcodec/codec/fx_codec_jbig.cpp8
-rw-r--r--core/fxcrt/fx_basic_util.cpp4
-rw-r--r--core/fxcrt/include/fx_basic.h2
-rw-r--r--core/fxcrt/include/fx_memory.h4
6 files changed, 18 insertions, 29 deletions
diff --git a/core/fpdfapi/fpdf_basic_module.cpp b/core/fpdfapi/cpdf_modulemgr.cpp
index 75450bf975..fe5368d3f7 100644
--- a/core/fpdfapi/fpdf_basic_module.cpp
+++ b/core/fpdfapi/cpdf_modulemgr.cpp
@@ -36,16 +36,6 @@ CPDF_ModuleMgr::CPDF_ModuleMgr() : m_pCodecModule(nullptr) {}
CPDF_ModuleMgr::~CPDF_ModuleMgr() {}
-void CPDF_ModuleMgr::SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback) {
- m_privateData.SetPrivateData(module_id, pData, callback);
-}
-
-void* CPDF_ModuleMgr::GetPrivateData(void* module_id) {
- return m_privateData.GetPrivateData(module_id);
-}
-
CCodec_FaxModule* CPDF_ModuleMgr::GetFaxModule() {
return m_pCodecModule ? m_pCodecModule->GetFaxModule() : nullptr;
}
diff --git a/core/fpdfapi/include/cpdf_modulemgr.h b/core/fpdfapi/include/cpdf_modulemgr.h
index e54bd07a90..95c5385e64 100644
--- a/core/fpdfapi/include/cpdf_modulemgr.h
+++ b/core/fpdfapi/include/cpdf_modulemgr.h
@@ -11,14 +11,13 @@
#include "core/fxcrt/include/fx_basic.h"
-class CCodec_ModuleMgr;
class CCodec_FaxModule;
class CCodec_FlateModule;
class CCodec_IccModule;
class CCodec_Jbig2Module;
class CCodec_JpegModule;
class CCodec_JpxModule;
-
+class CCodec_ModuleMgr;
class CPDF_PageModule;
class CPDF_ModuleMgr {
@@ -32,9 +31,15 @@ class CPDF_ModuleMgr {
CCodec_ModuleMgr* GetCodecModule() { return m_pCodecModule; }
void InitPageModule();
-
CPDF_PageModule* GetPageModule() const { return m_pPageModule.get(); }
+ void SetUnsupportInfoAdapter(std::unique_ptr<CFX_Deletable> pAdapter) {
+ m_pUnsupportInfoAdapter = std::move(pAdapter);
+ }
+ CFX_Deletable* GetUnsupportInfoAdapter() const {
+ return m_pUnsupportInfoAdapter.get();
+ }
+
void LoadEmbeddedGB1CMaps();
void LoadEmbeddedCNS1CMaps();
void LoadEmbeddedJapan1CMaps();
@@ -47,19 +52,13 @@ class CPDF_ModuleMgr {
CCodec_IccModule* GetIccModule();
CCodec_FlateModule* GetFlateModule();
- void SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback);
-
- void* GetPrivateData(void* module_id);
-
private:
CPDF_ModuleMgr();
~CPDF_ModuleMgr();
CCodec_ModuleMgr* m_pCodecModule;
std::unique_ptr<CPDF_PageModule> m_pPageModule;
- CFX_PrivateData m_privateData;
+ std::unique_ptr<CFX_Deletable> m_pUnsupportInfoAdapter;
};
#endif // CORE_FPDFAPI_INCLUDE_CPDF_MODULEMGR_H_
diff --git a/core/fxcodec/codec/fx_codec_jbig.cpp b/core/fxcodec/codec/fx_codec_jbig.cpp
index b5e32f130d..99cf2ec82f 100644
--- a/core/fxcodec/codec/fx_codec_jbig.cpp
+++ b/core/fxcodec/codec/fx_codec_jbig.cpp
@@ -30,7 +30,7 @@ class CCodec_Jbig2Context {
} // namespace
// Holds per-document JBig2 related data.
-class JBig2DocumentContext : public CFX_DestructObject {
+class JBig2DocumentContext : public CFX_Deletable {
public:
std::list<CJBig2_CachePair>* GetSymbolDictCache() {
return &m_SymbolDictCache;
@@ -50,9 +50,9 @@ JBig2DocumentContext* GetJBig2DocumentContext(CCodec_Jbig2Module* pModule,
CFX_PrivateData* pPrivateData) {
void* pModulePrivateData = pPrivateData->GetPrivateData(pModule);
if (pModulePrivateData) {
- CFX_DestructObject* pDestructObject =
- reinterpret_cast<CFX_DestructObject*>(pModulePrivateData);
- return static_cast<JBig2DocumentContext*>(pDestructObject);
+ CFX_Deletable* pDeletable =
+ reinterpret_cast<CFX_Deletable*>(pModulePrivateData);
+ return static_cast<JBig2DocumentContext*>(pDeletable);
}
JBig2DocumentContext* pJBig2DocumentContext = new JBig2DocumentContext();
pPrivateData->SetPrivateObj(pModule, pJBig2DocumentContext);
diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp
index 2d3483e9b3..b073ea8f17 100644
--- a/core/fxcrt/fx_basic_util.cpp
+++ b/core/fxcrt/fx_basic_util.cpp
@@ -27,7 +27,7 @@ void FX_PRIVATEDATA::FreeData() {
return;
}
if (m_bSelfDestruct) {
- delete (CFX_DestructObject*)m_pData;
+ delete static_cast<CFX_Deletable*>(m_pData);
} else if (m_pCallback) {
m_pCallback(m_pData);
}
@@ -57,7 +57,7 @@ void CFX_PrivateData::SetPrivateData(void* pModuleId,
PD_CALLBACK_FREEDATA callback) {
AddData(pModuleId, pData, callback, FALSE);
}
-void CFX_PrivateData::SetPrivateObj(void* pModuleId, CFX_DestructObject* pObj) {
+void CFX_PrivateData::SetPrivateObj(void* pModuleId, CFX_Deletable* pObj) {
AddData(pModuleId, pObj, NULL, TRUE);
}
FX_BOOL CFX_PrivateData::RemovePrivateData(void* pModuleId) {
diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h
index 848429e8f3..0f517e7217 100644
--- a/core/fxcrt/include/fx_basic.h
+++ b/core/fxcrt/include/fx_basic.h
@@ -639,7 +639,7 @@ class CFX_PrivateData {
void SetPrivateData(void* module_id,
void* pData,
PD_CALLBACK_FREEDATA callback);
- void SetPrivateObj(void* module_id, CFX_DestructObject* pObj);
+ void SetPrivateObj(void* module_id, CFX_Deletable* pObj);
void* GetPrivateData(void* module_id);
FX_BOOL LookupPrivateData(void* module_id, void*& pData) const {
diff --git a/core/fxcrt/include/fx_memory.h b/core/fxcrt/include/fx_memory.h
index 2614016550..3048897d76 100644
--- a/core/fxcrt/include/fx_memory.h
+++ b/core/fxcrt/include/fx_memory.h
@@ -100,9 +100,9 @@ struct ReleaseDeleter {
inline void operator()(T* ptr) const { ptr->Release(); }
};
-class CFX_DestructObject {
+class CFX_Deletable {
public:
- virtual ~CFX_DestructObject() {}
+ virtual ~CFX_Deletable() {}
};
#endif // __cplusplus