diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-06-17 16:38:51 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-06-17 16:38:51 -0700 |
commit | ff8347a4b16f000be628c5e10d03a1e1c17537eb (patch) | |
tree | 1d46e77a1ef6b28def6af3ffdd576017a6cfe229 /core/include | |
parent | c4d9f6ad2dc922b574862cd2f6f0a899d7e169e3 (diff) | |
download | pdfium-ff8347a4b16f000be628c5e10d03a1e1c17537eb.tar.xz |
Replace some Release() calls with virtual destructors.
A virtual method that does |delete this| is an anti-pattern.
Some classes can be de-virtualized instead.
Throw in some unique_ptrs and delete dead code for good measure.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1192013002.
Diffstat (limited to 'core/include')
-rw-r--r-- | core/include/fxcodec/fx_codec.h | 70 | ||||
-rw-r--r-- | core/include/fxcrt/fx_arb.h | 16 | ||||
-rw-r--r-- | core/include/fxge/fx_font.h | 7 |
3 files changed, 27 insertions, 66 deletions
diff --git a/core/include/fxcodec/fx_codec.h b/core/include/fxcodec/fx_codec.h index e8faf3f78f..e3d69e5dc9 100644 --- a/core/include/fxcodec/fx_codec.h +++ b/core/include/fxcodec/fx_codec.h @@ -7,6 +7,7 @@ #ifndef CORE_INCLUDE_FXCODEC_FX_CODEC_H_ #define CORE_INCLUDE_FXCODEC_FX_CODEC_H_ +#include "../../../third_party/base/nonstd_unique_ptr.h" #include "../fxcrt/fx_basic.h" #include "fx_codec_def.h" #include "fx_codec_provider.h" @@ -22,63 +23,28 @@ class ICodec_IccModule; class ICodec_FlateModule; class ICodec_Jbig2Encoder; class ICodec_ScanlineDecoder; + class CCodec_ModuleMgr { public: - - static CCodec_ModuleMgr* Create(); - - void Destroy(); - - void InitJbig2Decoder(); - - void InitJpxDecoder(); - - - void InitIccDecoder(); - - ICodec_Jbig2Encoder* CreateJbig2Encoder(); -protected: CCodec_ModuleMgr(); - ~CCodec_ModuleMgr(); -public: - ICodec_BasicModule* GetBasicModule() - { - return m_pBasicModule; - } - ICodec_FaxModule* GetFaxModule() - { - return m_pFaxModule; - } - ICodec_JpegModule* GetJpegModule() - { - return m_pJpegModule; - } - ICodec_JpxModule* GetJpxModule() - { - return m_pJpxModule; - } - ICodec_Jbig2Module* GetJbig2Module() - { - return m_pJbig2Module; - } - ICodec_IccModule* GetIccModule() - { - return m_pIccModule; - } - ICodec_FlateModule* GetFlateModule() - { - return m_pFlateModule; - } -protected: - ICodec_BasicModule* m_pBasicModule; - ICodec_FaxModule* m_pFaxModule; - ICodec_JpegModule* m_pJpegModule; - ICodec_JpxModule* m_pJpxModule; - ICodec_Jbig2Module* m_pJbig2Module; - ICodec_IccModule* m_pIccModule; - ICodec_FlateModule* m_pFlateModule; + ICodec_Jbig2Encoder* CreateJbig2Encoder(); + ICodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); } + ICodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); } + ICodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); } + ICodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); } + ICodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); } + ICodec_IccModule* GetIccModule() const { return m_pIccModule.get(); } + ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); } +protected: + nonstd::unique_ptr<ICodec_BasicModule> m_pBasicModule; + nonstd::unique_ptr<ICodec_FaxModule> m_pFaxModule; + nonstd::unique_ptr<ICodec_JpegModule> m_pJpegModule; + nonstd::unique_ptr<ICodec_JpxModule> m_pJpxModule; + nonstd::unique_ptr<ICodec_Jbig2Module> m_pJbig2Module; + nonstd::unique_ptr<ICodec_IccModule> m_pIccModule; + nonstd::unique_ptr<ICodec_FlateModule> m_pFlateModule; }; class ICodec_BasicModule { diff --git a/core/include/fxcrt/fx_arb.h b/core/include/fxcrt/fx_arb.h index 3485ce27bb..7ce21e5086 100644 --- a/core/include/fxcrt/fx_arb.h +++ b/core/include/fxcrt/fx_arb.h @@ -12,16 +12,14 @@ class IFX_BidiChar { public: - static IFX_BidiChar* Create(); - virtual void Release() = 0; - virtual void SetPolicy(FX_BOOL bSeparateNeutral = TRUE) = 0; - virtual FX_BOOL AppendChar(FX_WCHAR wch) = 0; - virtual FX_BOOL EndChar() = 0; - virtual int32_t GetBidiInfo(int32_t &iStart, int32_t &iCount) = 0; - virtual void Reset() = 0; + static IFX_BidiChar* Create(); + virtual ~IFX_BidiChar() {} -protected: - ~IFX_BidiChar() { } + virtual void SetPolicy(FX_BOOL bSeparateNeutral = TRUE) = 0; + virtual FX_BOOL AppendChar(FX_WCHAR wch) = 0; + virtual FX_BOOL EndChar() = 0; + virtual int32_t GetBidiInfo(int32_t &iStart, int32_t &iCount) = 0; + virtual void Reset() = 0; }; #endif // CORE_INCLUDE_FXCRT_FX_ARB_H_ diff --git a/core/include/fxge/fx_font.h b/core/include/fxge/fx_font.h index 49b8f9a974..31794d6743 100644 --- a/core/include/fxge/fx_font.h +++ b/core/include/fxge/fx_font.h @@ -424,12 +424,9 @@ FX_BOOL OutputText(void* dib, int x, int y, CFX_Font* pFont, double font_size, class IFX_GSUBTable { public: - virtual void Release() = 0; + static IFX_GSUBTable* Create(CFX_Font* pFont); + virtual ~IFX_GSUBTable() { } virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) = 0; - -protected: - ~IFX_GSUBTable() { } }; -IFX_GSUBTable* FXGE_CreateGSUBTable(CFX_Font* pFont); #endif // CORE_INCLUDE_FXGE_FX_FONT_H_ |