From ad2441ef675866eb84c7392eeda03391a5a5d474 Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 24 Oct 2016 10:19:11 -0700 Subject: Rename IFX_ stream names 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 --- core/fpdfapi/edit/cpdf_creator.h | 2 +- core/fpdfapi/edit/fpdf_edit_create.cpp | 6 +++--- core/fpdfapi/page/cpdf_image.cpp | 2 +- core/fpdfapi/page/cpdf_image.h | 8 ++++---- core/fpdfapi/parser/cfdf_document.cpp | 6 ++++-- core/fpdfapi/parser/cfdf_document.h | 6 +++--- core/fpdfapi/parser/cpdf_data_avail.cpp | 2 +- core/fpdfapi/parser/cpdf_data_avail.h | 6 +++--- core/fpdfapi/parser/cpdf_parser.cpp | 11 ++++++----- core/fpdfapi/parser/cpdf_parser.h | 12 +++++++----- core/fpdfapi/parser/cpdf_parser_unittest.cpp | 6 +++--- core/fpdfapi/parser/cpdf_stream.cpp | 2 +- core/fpdfapi/parser/cpdf_stream.h | 5 +++-- core/fpdfapi/parser/cpdf_syntax_parser.cpp | 2 +- core/fpdfapi/parser/cpdf_syntax_parser.h | 6 +++--- core/fpdfapi/parser/fpdf_parser_utility.cpp | 2 +- core/fpdfapi/parser/fpdf_parser_utility.h | 4 ++-- 17 files changed, 47 insertions(+), 41 deletions(-) (limited to 'core/fpdfapi') diff --git a/core/fpdfapi/edit/cpdf_creator.h b/core/fpdfapi/edit/cpdf_creator.h index 5de3793eb5..8b0efdd309 100644 --- a/core/fpdfapi/edit/cpdf_creator.h +++ b/core/fpdfapi/edit/cpdf_creator.h @@ -32,7 +32,7 @@ class CPDF_Creator { ~CPDF_Creator(); void RemoveSecurity(); - bool Create(IFX_StreamWrite* pFile, uint32_t flags = 0); + bool Create(IFX_WriteStream* pFile, uint32_t flags = 0); int32_t Continue(IFX_Pause* pPause = nullptr); FX_BOOL SetFileVersion(int32_t fileVersion = 17); diff --git a/core/fpdfapi/edit/fpdf_edit_create.cpp b/core/fpdfapi/edit/fpdf_edit_create.cpp index e5b1fe1bb0..b4e1157d9e 100644 --- a/core/fpdfapi/edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/edit/fpdf_edit_create.cpp @@ -1482,7 +1482,7 @@ int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) { InitOldObjNumOffsets(); m_iStage = 20; } else { - IFX_FileRead* pSrcFile = m_pParser->GetFileAccess(); + IFX_SeekableReadStream* pSrcFile = m_pParser->GetFileAccess(); m_Offset = pSrcFile->GetSize(); m_Pos = (void*)(uintptr_t)m_Offset; m_iStage = 15; @@ -1490,7 +1490,7 @@ int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) { } if (m_iStage == 15) { if ((m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0 && m_Pos) { - IFX_FileRead* pSrcFile = m_pParser->GetFileAccess(); + IFX_SeekableReadStream* pSrcFile = m_pParser->GetFileAccess(); uint8_t buffer[4096]; uint32_t src_size = (uint32_t)(uintptr_t)m_Pos; while (src_size) { @@ -1907,7 +1907,7 @@ void CPDF_Creator::Clear() { m_pIDArray.reset(); } -bool CPDF_Creator::Create(IFX_StreamWrite* pFile, uint32_t flags) { +bool CPDF_Creator::Create(IFX_WriteStream* pFile, uint32_t flags) { m_File.AttachFile(pFile); return Create(flags); } diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp index 50768c5058..b40bc3ca8e 100644 --- a/core/fpdfapi/page/cpdf_image.cpp +++ b/core/fpdfapi/page/cpdf_image.cpp @@ -123,7 +123,7 @@ CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, uint32_t size) { return pDict; } -void CPDF_Image::SetJpegImage(IFX_FileRead* pFile) { +void CPDF_Image::SetJpegImage(IFX_SeekableReadStream* pFile) { uint32_t size = (uint32_t)pFile->GetSize(); if (!size) return; diff --git a/core/fpdfapi/page/cpdf_image.h b/core/fpdfapi/page/cpdf_image.h index 72de0d8cef..1e6f70fa33 100644 --- a/core/fpdfapi/page/cpdf_image.h +++ b/core/fpdfapi/page/cpdf_image.h @@ -16,14 +16,14 @@ #define PDF_IMAGE_MASK_LOSSY_COMPRESS 0x0004 #define PDF_IMAGE_MASK_LOSSLESS_COMPRESS 0x0008 -class CFX_DIBitmap; class CFX_DIBSource; +class CFX_DIBitmap; class CPDF_Dictionay; class CPDF_Document; class CPDF_Page; -class IFX_FileRead; -class IFX_FileWrite; class IFX_Pause; +class IFX_SeekableReadStream; +class IFX_SeekableWriteStream; class CPDF_Image { public: @@ -56,7 +56,7 @@ class CPDF_Image { FX_BOOL bLoadMask = FALSE) const; void SetImage(const CFX_DIBitmap* pDIBitmap, int32_t iCompress); - void SetJpegImage(IFX_FileRead* pFile); + void SetJpegImage(IFX_SeekableReadStream* pFile); void ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pDIBitmap); diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp index a1518dfed0..3bafdda9f2 100644 --- a/core/fpdfapi/parser/cfdf_document.cpp +++ b/core/fpdfapi/parser/cfdf_document.cpp @@ -33,7 +33,8 @@ CFDF_Document* CFDF_Document::CreateNewDoc() { return pDoc; } -CFDF_Document* CFDF_Document::ParseFile(IFX_FileRead* pFile, FX_BOOL bOwnFile) { +CFDF_Document* CFDF_Document::ParseFile(IFX_SeekableReadStream* pFile, + FX_BOOL bOwnFile) { if (!pFile) return nullptr; @@ -47,7 +48,8 @@ CFDF_Document* CFDF_Document::ParseMemory(const uint8_t* pData, uint32_t size) { TRUE); } -void CFDF_Document::ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile) { +void CFDF_Document::ParseStream(IFX_SeekableReadStream* pFile, + FX_BOOL bOwnFile) { m_pFile = pFile; m_bOwnFile = bOwnFile; CPDF_SyntaxParser parser; diff --git a/core/fpdfapi/parser/cfdf_document.h b/core/fpdfapi/parser/cfdf_document.h index 21ac62d11c..32d0aab422 100644 --- a/core/fpdfapi/parser/cfdf_document.h +++ b/core/fpdfapi/parser/cfdf_document.h @@ -18,7 +18,7 @@ class CPDF_Dictionary; class CFDF_Document : public CPDF_IndirectObjectHolder { public: static CFDF_Document* CreateNewDoc(); - static CFDF_Document* ParseFile(IFX_FileRead* pFile, + static CFDF_Document* ParseFile(IFX_SeekableReadStream* pFile, FX_BOOL bOwnFile = FALSE); static CFDF_Document* ParseMemory(const uint8_t* pData, uint32_t size); ~CFDF_Document() override; @@ -31,10 +31,10 @@ class CFDF_Document : public CPDF_IndirectObjectHolder { protected: CFDF_Document(); - void ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile); + void ParseStream(IFX_SeekableReadStream* pFile, FX_BOOL bOwnFile); CPDF_Dictionary* m_pRootDict; - IFX_FileRead* m_pFile; + IFX_SeekableReadStream* m_pFile; FX_BOOL m_bOwnFile; CFX_WeakPtr m_pByteStringPool; }; diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index e23aa8ecfb..c6a434be5d 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -32,7 +32,7 @@ CPDF_DataAvail::DownloadHints::~DownloadHints() {} int CPDF_DataAvail::s_CurrentDataAvailRecursionDepth = 0; CPDF_DataAvail::CPDF_DataAvail(FileAvail* pFileAvail, - IFX_FileRead* pFileRead, + IFX_SeekableReadStream* pFileRead, FX_BOOL bSupportHintTable) : m_pFileAvail(pFileAvail), m_pFileRead(pFileRead) { m_Pos = 0; diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h index fe5c481af2..138fe1e3d8 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.h +++ b/core/fpdfapi/parser/cpdf_data_avail.h @@ -93,7 +93,7 @@ class CPDF_DataAvail final { }; CPDF_DataAvail(FileAvail* pFileAvail, - IFX_FileRead* pFileRead, + IFX_SeekableReadStream* pFileRead, FX_BOOL bSupportHintTable); ~CPDF_DataAvail(); @@ -104,7 +104,7 @@ class CPDF_DataAvail final { DocLinearizationStatus IsLinearizedPDF(); FX_BOOL IsLinearized(); void GetLinearizedMainXRefInfo(FX_FILESIZE* pPos, uint32_t* pSize); - IFX_FileRead* GetFileRead() const { return m_pFileRead; } + IFX_SeekableReadStream* GetFileRead() const { return m_pFileRead; } int GetPageCount() const; CPDF_Dictionary* GetPage(int index); @@ -193,7 +193,7 @@ class CPDF_DataAvail final { FX_BOOL IsDataAvail(FX_FILESIZE offset, uint32_t size, DownloadHints* pHints); FileAvail* const m_pFileAvail; - IFX_FileRead* const m_pFileRead; + IFX_SeekableReadStream* const m_pFileRead; CPDF_Parser m_parser; CPDF_SyntaxParser m_syntaxParser; CPDF_Object* m_pRoot; diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index c29ae18da2..c2748882cf 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -119,7 +119,7 @@ CPDF_CryptoHandler* CPDF_Parser::GetCryptoHandler() { return m_pSyntax->m_pCryptoHandler.get(); } -IFX_FileRead* CPDF_Parser::GetFileAccess() const { +IFX_SeekableReadStream* CPDF_Parser::GetFileAccess() const { return m_pSyntax->m_pFileAccess; } @@ -139,7 +139,7 @@ void CPDF_Parser::ShrinkObjectMap(uint32_t objnum) { m_ObjectInfo[objnum - 1].pos = 0; } -CPDF_Parser::Error CPDF_Parser::StartParse(IFX_FileRead* pFileAccess, +CPDF_Parser::Error CPDF_Parser::StartParse(IFX_SeekableReadStream* pFileAccess, CPDF_Document* pDocument) { ASSERT(!m_bHasParsed); m_bHasParsed = true; @@ -1438,7 +1438,7 @@ uint32_t CPDF_Parser::GetPermissions() const { return dwPermission; } -FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, +FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess, uint32_t offset) { m_pSyntax->InitParser(pFileAccess, offset); m_pSyntax->RestorePos(m_pSyntax->m_HeaderOffset + 9); @@ -1491,8 +1491,9 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, return FALSE; } -CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(IFX_FileRead* pFileAccess, - CPDF_Document* pDocument) { +CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( + IFX_SeekableReadStream* pFileAccess, + CPDF_Document* pDocument) { ASSERT(!m_bHasParsed); m_bXRefStream = FALSE; diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h index 83b591f3b2..887857628a 100644 --- a/core/fpdfapi/parser/cpdf_parser.h +++ b/core/fpdfapi/parser/cpdf_parser.h @@ -23,7 +23,7 @@ class CPDF_Object; class CPDF_SecurityHandler; class CPDF_StreamAcc; class CPDF_SyntaxParser; -class IFX_FileRead; +class IFX_SeekableReadStream; class CPDF_Parser { public: @@ -42,8 +42,9 @@ class CPDF_Parser { CPDF_Parser(); ~CPDF_Parser(); - Error StartParse(IFX_FileRead* pFile, CPDF_Document* pDocument); - Error StartLinearizedParse(IFX_FileRead* pFile, CPDF_Document* pDocument); + Error StartParse(IFX_SeekableReadStream* pFile, CPDF_Document* pDocument); + Error StartLinearizedParse(IFX_SeekableReadStream* pFile, + CPDF_Document* pDocument); void SetPassword(const FX_CHAR* password) { m_Password = password; } CFX_ByteString GetPassword() { return m_Password; } @@ -68,7 +69,7 @@ class CPDF_Parser { bool IsVersionUpdated() const { return m_bVersionUpdated; } bool IsObjectFreeOrNull(uint32_t objnum) const; CPDF_CryptoHandler* GetCryptoHandler(); - IFX_FileRead* GetFileAccess() const; + IFX_SeekableReadStream* GetFileAccess() const; FX_FILESIZE GetObjectOffset(uint32_t objnum) const; FX_FILESIZE GetObjectSize(uint32_t objnum) const; @@ -136,7 +137,8 @@ class CPDF_Parser { FX_BOOL LoadLinearizedAllCrossRefV5(FX_FILESIZE pos); Error LoadLinearizedMainXRefTable(); CPDF_StreamAcc* GetObjectStream(uint32_t number); - FX_BOOL IsLinearizedFile(IFX_FileRead* pFileAccess, uint32_t offset); + FX_BOOL IsLinearizedFile(IFX_SeekableReadStream* pFileAccess, + uint32_t offset); void SetEncryptDictionary(CPDF_Dictionary* pDict); void ShrinkObjectMap(uint32_t size); // A simple check whether the cross reference table matches with diff --git a/core/fpdfapi/parser/cpdf_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_parser_unittest.cpp index c97b88e6d1..6c6fb213f4 100644 --- a/core/fpdfapi/parser/cpdf_parser_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_parser_unittest.cpp @@ -13,7 +13,7 @@ #include "testing/utils/path_service.h" // Provide a way to read test data from a buffer instead of a file. -class CFX_TestBufferRead : public IFX_FileRead { +class CFX_TestBufferRead : public IFX_SeekableReadStream { public: CFX_TestBufferRead(const unsigned char* buffer_in, size_t buf_size) : buffer_(buffer_in), total_size_(buf_size) {} @@ -21,7 +21,7 @@ class CFX_TestBufferRead : public IFX_FileRead { // IFX_Stream void Release() override { delete this; } - // IFX_FileRead + // IFX_SeekableReadStream FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { if (offset < 0 || offset + size > total_size_) { return FALSE; @@ -45,7 +45,7 @@ class CPDF_TestParser : public CPDF_Parser { // Setup reading from a file and initial states. bool InitTestFromFile(const FX_CHAR* path) { - IFX_FileRead* pFileAccess = FX_CreateFileRead(path); + IFX_SeekableReadStream* pFileAccess = FX_CreateFileRead(path); if (!pFileAccess) return false; diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp index 935c80c5c8..93899db24e 100644 --- a/core/fpdfapi/parser/cpdf_stream.cpp +++ b/core/fpdfapi/parser/cpdf_stream.cpp @@ -57,7 +57,7 @@ void CPDF_Stream::InitStream(const uint8_t* pData, m_pDict->SetIntegerFor("Length", m_dwSize); } -void CPDF_Stream::InitStreamFromFile(IFX_FileRead* pFile, +void CPDF_Stream::InitStreamFromFile(IFX_SeekableReadStream* pFile, CPDF_Dictionary* pDict) { m_pDict.reset(pDict); m_bMemoryBased = false; diff --git a/core/fpdfapi/parser/cpdf_stream.h b/core/fpdfapi/parser/cpdf_stream.h index 756eccfba1..588714eadc 100644 --- a/core/fpdfapi/parser/cpdf_stream.h +++ b/core/fpdfapi/parser/cpdf_stream.h @@ -37,7 +37,8 @@ class CPDF_Stream : public CPDF_Object { void SetData(const uint8_t* pData, uint32_t size); void InitStream(const uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict); - void InitStreamFromFile(IFX_FileRead* pFile, CPDF_Dictionary* pDict); + void InitStreamFromFile(IFX_SeekableReadStream* pFile, + CPDF_Dictionary* pDict); FX_BOOL ReadRawData(FX_FILESIZE start_pos, uint8_t* pBuf, @@ -55,7 +56,7 @@ class CPDF_Stream : public CPDF_Object { bool m_bMemoryBased = true; uint32_t m_dwSize = 0; std::unique_ptr m_pDataBuf; - IFX_FileRead* m_pFile = nullptr; + IFX_SeekableReadStream* m_pFile = nullptr; }; using UniqueStream = std::unique_ptr>; diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index e7f25d15c2..3b1df94503 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -782,7 +782,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, return pStream; } -void CPDF_SyntaxParser::InitParser(IFX_FileRead* pFileAccess, +void CPDF_SyntaxParser::InitParser(IFX_SeekableReadStream* pFileAccess, uint32_t HeaderOffset) { FX_Free(m_pFileBuf); diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h index 444a94bde1..5694d233e1 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.h +++ b/core/fpdfapi/parser/cpdf_syntax_parser.h @@ -18,7 +18,7 @@ class CPDF_Dictionary; class CPDF_IndirectObjectHolder; class CPDF_Object; class CPDF_Stream; -class IFX_FileRead; +class IFX_SeekableReadStream; class CPDF_SyntaxParser { public: @@ -26,7 +26,7 @@ class CPDF_SyntaxParser { explicit CPDF_SyntaxParser(const CFX_WeakPtr& pPool); ~CPDF_SyntaxParser(); - void InitParser(IFX_FileRead* pFileAccess, uint32_t HeaderOffset); + void InitParser(IFX_SeekableReadStream* pFileAccess, uint32_t HeaderOffset); FX_FILESIZE SavePos() const { return m_Pos; } void RestorePos(FX_FILESIZE pos) { m_Pos = pos; } @@ -86,7 +86,7 @@ class CPDF_SyntaxParser { FX_FILESIZE m_Pos; int m_MetadataObjnum; - IFX_FileRead* m_pFileAccess; + IFX_SeekableReadStream* m_pFileAccess; FX_FILESIZE m_HeaderOffset; FX_FILESIZE m_FileLen; uint8_t* m_pFileBuf; diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp index 7b9ead4005..8fdef1eb11 100644 --- a/core/fpdfapi/parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp @@ -68,7 +68,7 @@ const char PDF_CharType[256] = { 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'W'}; -int32_t GetHeaderOffset(IFX_FileRead* pFile) { +int32_t GetHeaderOffset(IFX_SeekableReadStream* pFile) { const size_t kBufSize = 4; uint8_t buf[kBufSize]; for (int32_t offset = 0; offset <= 1024; ++offset) { diff --git a/core/fpdfapi/parser/fpdf_parser_utility.h b/core/fpdfapi/parser/fpdf_parser_utility.h index 4c0187ed4a..589171f1a4 100644 --- a/core/fpdfapi/parser/fpdf_parser_utility.h +++ b/core/fpdfapi/parser/fpdf_parser_utility.h @@ -10,7 +10,7 @@ #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" -class IFX_FileRead; +class IFX_SeekableReadStream; class CPDF_Dictionary; // Use the accessors below instead of directly accessing PDF_CharType. @@ -33,7 +33,7 @@ inline bool PDFCharIsLineEnding(uint8_t c) { return c == '\r' || c == '\n'; } -int32_t GetHeaderOffset(IFX_FileRead* pFile); +int32_t GetHeaderOffset(IFX_SeekableReadStream* pFile); int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteString& key); #endif // CORE_FPDFAPI_PARSER_FPDF_PARSER_UTILITY_H_ -- cgit v1.2.3