diff options
author | Lei Zhang <thestig@chromium.org> | 2015-08-14 21:49:19 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-08-14 21:49:19 -0700 |
commit | 62b2e912dc2a508972fbf01b25f7449c39ff1543 (patch) | |
tree | 47a244dc5891b2a338ca529b796e12994e642cbc /core/src/fxcrt/extension.h | |
parent | bdf72c353af5b8a34ef5efdeddfff36d2089a158 (diff) | |
download | pdfium-62b2e912dc2a508972fbf01b25f7449c39ff1543.tar.xz |
Merge to XFA: Use override in more classes in core/
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1292613003 .
(cherry picked from commit c2c3f7b5f0396409451a9d344f35ec1929a76e9f)
Review URL: https://codereview.chromium.org/1296043002 .
Diffstat (limited to 'core/src/fxcrt/extension.h')
-rw-r--r-- | core/src/fxcrt/extension.h | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index 0fdf8ab7bf..9960c03349 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -30,40 +30,43 @@ class IFXCRT_FileAccess { virtual FX_BOOL Truncate(FX_FILESIZE szFile) = 0; }; IFXCRT_FileAccess* FXCRT_FileAccess_Create(); + class CFX_CRTFileAccess : public IFX_FileAccess { public: CFX_CRTFileAccess() : m_RefCount(0) {} - virtual void Release() { + // IFX_FileAccess + void Release() override { if (--m_RefCount == 0) delete this; } - IFX_FileAccess* Retain() { + IFX_FileAccess* Retain() override { m_RefCount++; return (IFX_FileAccess*)this; } - virtual FX_BOOL Init(const CFX_WideStringC& wsPath) { + void GetPath(CFX_WideString& wsPath) override { wsPath = m_path; } + + IFX_FileStream* CreateFileStream(FX_DWORD dwModes) override { + return FX_CreateFileStream(m_path, dwModes); + } + + FX_BOOL Init(const CFX_WideStringC& wsPath) { m_path = wsPath; m_RefCount = 1; return TRUE; } - virtual void GetPath(CFX_WideString& wsPath) { wsPath = m_path; } - - virtual IFX_FileStream* CreateFileStream(FX_DWORD dwModes) { - return FX_CreateFileStream(m_path, dwModes); - } - protected: CFX_WideString m_path; FX_DWORD m_RefCount; }; + class CFX_CRTFileStream final : public IFX_FileStream { public: CFX_CRTFileStream(IFXCRT_FileAccess* pFA) : m_pFile(pFA), m_dwCount(1) {} - ~CFX_CRTFileStream() { + ~CFX_CRTFileStream() override { if (m_pFile) { m_pFile->Release(); } @@ -100,6 +103,7 @@ class CFX_CRTFileStream final : public IFX_FileStream { IFXCRT_FileAccess* m_pFile; FX_DWORD m_dwCount; }; + #define FX_MEMSTREAM_BlockSize (64 * 1024) #define FX_MEMSTREAM_Consecutive 0x01 #define FX_MEMSTREAM_TakeOver 0x02 @@ -124,7 +128,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { m_dwFlags = FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOver : 0); } - ~CFX_MemoryStream() { + ~CFX_MemoryStream() override { if (m_dwFlags & FX_MEMSTREAM_TakeOver) { for (int32_t i = 0; i < m_Blocks.GetSize(); i++) { FX_Free((uint8_t*)m_Blocks[i]); @@ -317,6 +321,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { return TRUE; } }; + #ifdef __cplusplus extern "C" { #endif |