diff options
author | tsepez <tsepez@chromium.org> | 2016-12-07 09:21:17 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-12-07 09:21:18 -0800 |
commit | 833619b4441915c7c55085d44b3221eaef0d9800 (patch) | |
tree | 68bf76e83078223ba03f490c2c13f484e40154d4 /core/fxcrt/fx_stream.h | |
parent | 8f875507a986d10335e40a5f7c1679aff9770d0a (diff) | |
download | pdfium-833619b4441915c7c55085d44b3221eaef0d9800.tar.xz |
Refcount all the IFX_ stream classes all the time.
We can remove a lot of "bOwnsStream" logic in the process.
Always pass these by const reference, in case the called method
wants to hang on to the stream (one exception is where we stick
a raw pointer into a void* slot in a context from another layer).
Review-Url: https://codereview.chromium.org/2451493002
Diffstat (limited to 'core/fxcrt/fx_stream.h')
-rw-r--r-- | core/fxcrt/fx_stream.h | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/core/fxcrt/fx_stream.h b/core/fxcrt/fx_stream.h index 711b66472b..b998761742 100644 --- a/core/fxcrt/fx_stream.h +++ b/core/fxcrt/fx_stream.h @@ -7,6 +7,7 @@ #ifndef CORE_FXCRT_FX_STREAM_H_ #define CORE_FXCRT_FX_STREAM_H_ +#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" @@ -48,18 +49,13 @@ FX_WCHAR FX_GetFolderSeparator(); #define FX_FILEMODE_ReadOnly 1 #define FX_FILEMODE_Truncate 2 -class IFX_WriteStream { +class IFX_WriteStream : virtual public CFX_Retainable { public: - virtual ~IFX_WriteStream() {} - virtual void Release() = 0; virtual bool WriteBlock(const void* pData, size_t size) = 0; }; -class IFX_ReadStream { +class IFX_ReadStream : virtual public CFX_Retainable { public: - virtual ~IFX_ReadStream() {} - - virtual void Release() = 0; virtual bool IsEOF() = 0; virtual FX_FILESIZE GetPosition() = 0; virtual size_t ReadBlock(void* buffer, size_t size) = 0; @@ -69,6 +65,7 @@ class IFX_SeekableWriteStream : public IFX_WriteStream { public: // IFX_WriteStream: bool WriteBlock(const void* pData, size_t size) override; + virtual FX_FILESIZE GetSize() = 0; virtual bool Flush() = 0; virtual bool WriteBlock(const void* pData, @@ -78,10 +75,10 @@ class IFX_SeekableWriteStream : public IFX_WriteStream { class IFX_SeekableReadStream : public IFX_ReadStream { public: - static IFX_SeekableReadStream* CreateFromFilename(const FX_CHAR* filename); + static CFX_RetainPtr<IFX_SeekableReadStream> CreateFromFilename( + const FX_CHAR* filename); // IFX_ReadStream: - void Release() override = 0; bool IsEOF() override; FX_FILESIZE GetPosition() override; size_t ReadBlock(void* buffer, size_t size) override; @@ -93,15 +90,15 @@ class IFX_SeekableReadStream : public IFX_ReadStream { class IFX_SeekableStream : public IFX_SeekableReadStream, public IFX_SeekableWriteStream { public: - static IFX_SeekableStream* CreateFromFilename(const FX_CHAR* filename, - uint32_t dwModes); - static IFX_SeekableStream* CreateFromFilename(const FX_WCHAR* filename, - uint32_t dwModes); + static CFX_RetainPtr<IFX_SeekableStream> CreateFromFilename( + const FX_CHAR* filename, + uint32_t dwModes); - virtual IFX_SeekableStream* Retain() = 0; + static CFX_RetainPtr<IFX_SeekableStream> CreateFromFilename( + const FX_WCHAR* filename, + uint32_t dwModes); // IFX_SeekableReadStream: - void Release() override = 0; bool IsEOF() override = 0; FX_FILESIZE GetPosition() override = 0; size_t ReadBlock(void* buffer, size_t size) override = 0; @@ -118,10 +115,10 @@ class IFX_SeekableStream : public IFX_SeekableReadStream, class IFX_MemoryStream : public IFX_SeekableStream { public: - static IFX_MemoryStream* Create(uint8_t* pBuffer, - size_t nSize, - bool bTakeOver = false); - static IFX_MemoryStream* Create(bool bConsecutive = false); + static CFX_RetainPtr<IFX_MemoryStream> Create(uint8_t* pBuffer, + size_t nSize, + bool bTakeOver = false); + static CFX_RetainPtr<IFX_MemoryStream> Create(bool bConsecutive = false); virtual bool IsConsecutive() const = 0; virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0; @@ -135,7 +132,6 @@ class IFX_MemoryStream : public IFX_SeekableStream { class IFX_BufferedReadStream : public IFX_ReadStream { public: // IFX_ReadStream: - void Release() override = 0; bool IsEOF() override = 0; FX_FILESIZE GetPosition() override = 0; size_t ReadBlock(void* buffer, size_t size) override = 0; @@ -155,7 +151,8 @@ class IFX_FileAccess { virtual void Release() = 0; virtual IFX_FileAccess* Retain() = 0; virtual void GetPath(CFX_WideString& wsPath) = 0; - virtual IFX_SeekableStream* CreateFileStream(uint32_t dwModes) = 0; + virtual CFX_RetainPtr<IFX_SeekableStream> CreateFileStream( + uint32_t dwModes) = 0; }; #endif // PDF_ENABLE_XFA |