diff options
author | tsepez <tsepez@chromium.org> | 2016-10-24 10:19:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-24 10:19:11 -0700 |
commit | ad2441ef675866eb84c7392eeda03391a5a5d474 (patch) | |
tree | 5b250139c65d5f440f3b544643b1fb85e23380dd /core/fxcrt | |
parent | b674ebe6dd13288160ad8e324d719a124caf5a83 (diff) | |
download | pdfium-ad2441ef675866eb84c7392eeda03391a5a5d474.tar.xz |
Rename IFX_ stream nameschromium/2900
It's been troubling for some time that an IFX_FileStream might
actually be an in-memory buffer with no backing file.
Review-Url: https://codereview.chromium.org/2443723002
Diffstat (limited to 'core/fxcrt')
-rw-r--r-- | core/fxcrt/extension.h | 10 | ||||
-rw-r--r-- | core/fxcrt/fx_basic.h | 4 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_buffer.cpp | 2 | ||||
-rw-r--r-- | core/fxcrt/fx_ext.h | 2 | ||||
-rw-r--r-- | core/fxcrt/fx_extension.cpp | 17 | ||||
-rw-r--r-- | core/fxcrt/fx_stream.h | 59 | ||||
-rw-r--r-- | core/fxcrt/fx_xml.h | 2 | ||||
-rw-r--r-- | core/fxcrt/fx_xml_parser.cpp | 6 | ||||
-rw-r--r-- | core/fxcrt/fxcrt_stream.cpp | 10 | ||||
-rw-r--r-- | core/fxcrt/xml_int.h | 6 |
10 files changed, 61 insertions, 57 deletions
diff --git a/core/fxcrt/extension.h b/core/fxcrt/extension.h index 6a437db574..45f6d4f2f0 100644 --- a/core/fxcrt/extension.h +++ b/core/fxcrt/extension.h @@ -44,7 +44,7 @@ class CFX_CRTFileAccess : public IFX_FileAccess { void Release() override; IFX_FileAccess* Retain() override; void GetPath(CFX_WideString& wsPath) override; - IFX_FileStream* CreateFileStream(uint32_t dwModes) override; + IFX_SeekableStream* CreateFileStream(uint32_t dwModes) override; FX_BOOL Init(const CFX_WideStringC& wsPath); @@ -54,13 +54,13 @@ class CFX_CRTFileAccess : public IFX_FileAccess { }; #endif // PDF_ENABLE_XFA -class CFX_CRTFileStream final : public IFX_FileStream { +class CFX_CRTFileStream final : public IFX_SeekableStream { public: explicit CFX_CRTFileStream(std::unique_ptr<IFXCRT_FileAccess> pFA); ~CFX_CRTFileStream() override; - // IFX_FileStream: - IFX_FileStream* Retain() override; + // IFX_SeekableStream: + IFX_SeekableStream* Retain() override; void Release() override; FX_FILESIZE GetSize() override; FX_BOOL IsEOF() override; @@ -87,7 +87,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { ~CFX_MemoryStream() override; // IFX_MemoryStream - IFX_FileStream* Retain() override; + IFX_SeekableStream* Retain() override; void Release() override; FX_FILESIZE GetSize() override; FX_BOOL IsEOF() override; diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h index 4cf69f896b..6643d33dce 100644 --- a/core/fxcrt/fx_basic.h +++ b/core/fxcrt/fx_basic.h @@ -121,14 +121,14 @@ class CFX_FileBufferArchive { int32_t AppendString(const CFX_ByteStringC& lpsz); // |pFile| must outlive the CFX_FileBufferArchive. - void AttachFile(IFX_StreamWrite* pFile); + void AttachFile(IFX_WriteStream* pFile); private: static const size_t kBufSize = 32768; size_t m_Length; std::unique_ptr<uint8_t, FxFreeDeleter> m_pBuffer; - IFX_StreamWrite* m_pFile; + IFX_WriteStream* m_pFile; }; class CFX_CharMap { diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp index d441f6c0e9..e954224d8a 100644 --- a/core/fxcrt/fx_basic_buffer.cpp +++ b/core/fxcrt/fx_basic_buffer.cpp @@ -285,7 +285,7 @@ int32_t CFX_FileBufferArchive::AppendString(const CFX_ByteStringC& lpsz) { return AppendBlock(lpsz.raw_str(), lpsz.GetLength()); } -void CFX_FileBufferArchive::AttachFile(IFX_StreamWrite* pFile) { +void CFX_FileBufferArchive::AttachFile(IFX_WriteStream* pFile) { ASSERT(pFile); m_pFile = pFile; } diff --git a/core/fxcrt/fx_ext.h b/core/fxcrt/fx_ext.h index 959a26bf44..cca80b1142 100644 --- a/core/fxcrt/fx_ext.h +++ b/core/fxcrt/fx_ext.h @@ -18,7 +18,7 @@ // Come up or wait for something better. This appears in this file rather // than fx_stream.h due to include ordering restrictions. using ScopedFileStream = - std::unique_ptr<IFX_FileStream, ReleaseDeleter<IFX_FileStream>>; + std::unique_ptr<IFX_SeekableStream, ReleaseDeleter<IFX_SeekableStream>>; FX_FLOAT FXSYS_tan(FX_FLOAT a); FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x); diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp index ca6b6d4066..5ac22bd44e 100644 --- a/core/fxcrt/fx_extension.cpp +++ b/core/fxcrt/fx_extension.cpp @@ -36,7 +36,7 @@ void CFX_CRTFileAccess::GetPath(CFX_WideString& wsPath) { wsPath = m_path; } -IFX_FileStream* CFX_CRTFileAccess::CreateFileStream(uint32_t dwModes) { +IFX_SeekableStream* CFX_CRTFileAccess::CreateFileStream(uint32_t dwModes) { return FX_CreateFileStream(m_path.c_str(), dwModes); } @@ -85,7 +85,7 @@ CFX_MemoryStream::~CFX_MemoryStream() { m_Blocks.RemoveAll(); } -IFX_FileStream* CFX_MemoryStream::Retain() { +IFX_SeekableStream* CFX_MemoryStream::Retain() { m_dwCount++; return this; } @@ -281,7 +281,7 @@ FX_BOOL CFX_MemoryStream::ExpandBlocks(size_t size) { return TRUE; } -IFX_FileStream* CFX_CRTFileStream::Retain() { +IFX_SeekableStream* CFX_CRTFileStream::Retain() { m_dwCount++; return this; } @@ -336,24 +336,25 @@ IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) { } #endif // PDF_ENABLE_XFA -IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, uint32_t dwModes) { +IFX_SeekableStream* FX_CreateFileStream(const FX_CHAR* filename, + uint32_t dwModes) { std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); if (!pFA->Open(filename, dwModes)) return nullptr; return new CFX_CRTFileStream(std::move(pFA)); } -IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, - uint32_t dwModes) { +IFX_SeekableStream* FX_CreateFileStream(const FX_WCHAR* filename, + uint32_t dwModes) { std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); if (!pFA->Open(filename, dwModes)) return nullptr; return new CFX_CRTFileStream(std::move(pFA)); } -IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename) { +IFX_SeekableReadStream* FX_CreateFileRead(const FX_CHAR* filename) { return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); } -IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename) { +IFX_SeekableReadStream* FX_CreateFileRead(const FX_WCHAR* filename) { return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); } IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, diff --git a/core/fxcrt/fx_stream.h b/core/fxcrt/fx_stream.h index 047fedf9bb..2509ec2cd7 100644 --- a/core/fxcrt/fx_stream.h +++ b/core/fxcrt/fx_stream.h @@ -55,16 +55,26 @@ FX_WCHAR FX_GetFolderSeparator(); #define FX_FILEMODE_ReadOnly 1 #define FX_FILEMODE_Truncate 2 -class IFX_StreamWrite { +class IFX_WriteStream { public: - virtual ~IFX_StreamWrite() {} + virtual ~IFX_WriteStream() {} virtual void Release() = 0; virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0; }; -class IFX_FileWrite : public IFX_StreamWrite { +class IFX_ReadStream { public: - // IFX_StreamWrite: + virtual ~IFX_ReadStream() {} + + virtual void Release() = 0; + virtual FX_BOOL IsEOF() = 0; + virtual FX_FILESIZE GetPosition() = 0; + virtual size_t ReadBlock(void* buffer, size_t size) = 0; +}; + +class IFX_SeekableWriteStream : public IFX_WriteStream { + public: + // IFX_WriteStream: FX_BOOL WriteBlock(const void* pData, size_t size) override; virtual FX_FILESIZE GetSize() = 0; virtual FX_BOOL Flush() = 0; @@ -73,19 +83,9 @@ class IFX_FileWrite : public IFX_StreamWrite { size_t size) = 0; }; -class IFX_StreamRead { - public: - virtual ~IFX_StreamRead() {} - - virtual void Release() = 0; - virtual FX_BOOL IsEOF() = 0; - virtual FX_FILESIZE GetPosition() = 0; - virtual size_t ReadBlock(void* buffer, size_t size) = 0; -}; - -class IFX_FileRead : public IFX_StreamRead { +class IFX_SeekableReadStream : public IFX_ReadStream { public: - // IFX_StreamRead: + // IFX_ReadStream: void Release() override = 0; FX_BOOL IsEOF() override; FX_FILESIZE GetPosition() override; @@ -95,14 +95,15 @@ class IFX_FileRead : public IFX_StreamRead { virtual FX_FILESIZE GetSize() = 0; }; -IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename); -IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename); +IFX_SeekableReadStream* FX_CreateFileRead(const FX_CHAR* filename); +IFX_SeekableReadStream* FX_CreateFileRead(const FX_WCHAR* filename); -class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite { +class IFX_SeekableStream : public IFX_SeekableReadStream, + public IFX_SeekableWriteStream { public: - virtual IFX_FileStream* Retain() = 0; + virtual IFX_SeekableStream* Retain() = 0; - // IFX_FileRead: + // IFX_SeekableReadStream: void Release() override = 0; FX_BOOL IsEOF() override = 0; FX_FILESIZE GetPosition() override = 0; @@ -110,7 +111,7 @@ class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite { FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override = 0; FX_FILESIZE GetSize() override = 0; - // IFX_FileWrite: + // IFX_SeekableWriteStream: FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override = 0; @@ -118,8 +119,10 @@ class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite { FX_BOOL Flush() override = 0; }; -IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, uint32_t dwModes); -IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, uint32_t dwModes); +IFX_SeekableStream* FX_CreateFileStream(const FX_CHAR* filename, + uint32_t dwModes); +IFX_SeekableStream* FX_CreateFileStream(const FX_WCHAR* filename, + uint32_t dwModes); #ifdef PDF_ENABLE_XFA class IFX_FileAccess { @@ -128,12 +131,12 @@ class IFX_FileAccess { virtual void Release() = 0; virtual IFX_FileAccess* Retain() = 0; virtual void GetPath(CFX_WideString& wsPath) = 0; - virtual IFX_FileStream* CreateFileStream(uint32_t dwModes) = 0; + virtual IFX_SeekableStream* CreateFileStream(uint32_t dwModes) = 0; }; IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath); #endif // PDF_ENABLE_XFA -class IFX_MemoryStream : public IFX_FileStream { +class IFX_MemoryStream : public IFX_SeekableStream { public: virtual FX_BOOL IsConsecutive() const = 0; virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0; @@ -149,9 +152,9 @@ IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, FX_BOOL bTakeOver = FALSE); IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE); -class IFX_BufferRead : public IFX_StreamRead { +class IFX_BufferRead : public IFX_ReadStream { public: - // IFX_StreamRead: + // IFX_ReadStream: void Release() override = 0; FX_BOOL IsEOF() override = 0; FX_FILESIZE GetPosition() override = 0; diff --git a/core/fxcrt/fx_xml.h b/core/fxcrt/fx_xml.h index 78f162597f..4ab28f66c5 100644 --- a/core/fxcrt/fx_xml.h +++ b/core/fxcrt/fx_xml.h @@ -58,7 +58,7 @@ class CXML_Element { size_t size, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = nullptr); - static CXML_Element* Parse(IFX_FileRead* pFile, + static CXML_Element* Parse(IFX_SeekableReadStream* pFile, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = nullptr); static CXML_Element* Parse(IFX_BufferRead* pBuffer, diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp index 563e1c961b..e6c3543378 100644 --- a/core/fxcrt/fx_xml_parser.cpp +++ b/core/fxcrt/fx_xml_parser.cpp @@ -57,7 +57,7 @@ FX_FILESIZE CXML_DataBufAcc::GetBlockOffset() { return 0; } -CXML_DataStmAcc::CXML_DataStmAcc(IFX_FileRead* pFileRead) +CXML_DataStmAcc::CXML_DataStmAcc(IFX_SeekableReadStream* pFileRead) : m_pFileRead(pFileRead), m_pBuffer(nullptr), m_nStart(0), m_dwSize(0) { ASSERT(m_pFileRead); } @@ -132,7 +132,7 @@ FX_BOOL CXML_Parser::Init(uint8_t* pBuffer, size_t size) { m_pDataAcc = new CXML_DataBufAcc(pBuffer, size); return Init(TRUE); } -FX_BOOL CXML_Parser::Init(IFX_FileRead* pFileRead) { +FX_BOOL CXML_Parser::Init(IFX_SeekableReadStream* pFileRead) { m_pDataAcc = new CXML_DataStmAcc(pFileRead); return Init(TRUE); } @@ -651,7 +651,7 @@ CXML_Element* CXML_Element::Parse(const void* pBuffer, } return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); } -CXML_Element* CXML_Element::Parse(IFX_FileRead* pFile, +CXML_Element* CXML_Element::Parse(IFX_SeekableReadStream* pFile, FX_BOOL bSaveSpaceChars, FX_FILESIZE* pParsedSize) { CXML_Parser parser; diff --git a/core/fxcrt/fxcrt_stream.cpp b/core/fxcrt/fxcrt_stream.cpp index a8c96bf02c..638a183177 100644 --- a/core/fxcrt/fxcrt_stream.cpp +++ b/core/fxcrt/fxcrt_stream.cpp @@ -6,22 +6,22 @@ #include "core/fxcrt/fx_stream.h" -FX_BOOL IFX_FileWrite::WriteBlock(const void* pData, size_t size) { +FX_BOOL IFX_SeekableWriteStream::WriteBlock(const void* pData, size_t size) { return WriteBlock(pData, GetSize(), size); } -FX_BOOL IFX_FileRead::IsEOF() { +FX_BOOL IFX_SeekableReadStream::IsEOF() { return FALSE; } -FX_FILESIZE IFX_FileRead::GetPosition() { +FX_FILESIZE IFX_SeekableReadStream::GetPosition() { return 0; } -size_t IFX_FileRead::ReadBlock(void* buffer, size_t size) { +size_t IFX_SeekableReadStream::ReadBlock(void* buffer, size_t size) { return 0; } -FX_BOOL IFX_FileStream::WriteBlock(const void* buffer, size_t size) { +FX_BOOL IFX_SeekableStream::WriteBlock(const void* buffer, size_t size) { return WriteBlock(buffer, GetSize(), size); } diff --git a/core/fxcrt/xml_int.h b/core/fxcrt/xml_int.h index 47997062cc..aa157c2333 100644 --- a/core/fxcrt/xml_int.h +++ b/core/fxcrt/xml_int.h @@ -37,7 +37,7 @@ class CXML_DataBufAcc : public IFX_BufferRead { class CXML_DataStmAcc : public IFX_BufferRead { public: - explicit CXML_DataStmAcc(IFX_FileRead* pFileRead); + explicit CXML_DataStmAcc(IFX_SeekableReadStream* pFileRead); ~CXML_DataStmAcc() override; // IFX_BufferRead @@ -51,7 +51,7 @@ class CXML_DataStmAcc : public IFX_BufferRead { FX_FILESIZE GetBlockOffset() override; protected: - IFX_FileRead* m_pFileRead; + IFX_SeekableReadStream* m_pFileRead; uint8_t* m_pBuffer; FX_FILESIZE m_nStart; size_t m_dwSize; @@ -63,7 +63,7 @@ class CXML_Parser { ~CXML_Parser(); FX_BOOL Init(uint8_t* pBuffer, size_t size); - FX_BOOL Init(IFX_FileRead* pFileRead); + FX_BOOL Init(IFX_SeekableReadStream* pFileRead); FX_BOOL Init(IFX_BufferRead* pBuffer); FX_BOOL Init(FX_BOOL bOwndedStream); FX_BOOL ReadNextBlock(); |