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/fpdfapi/parser | |
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/fpdfapi/parser')
-rw-r--r-- | core/fpdfapi/parser/cfdf_document.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/parser/cfdf_document.h | 6 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.h | 6 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.cpp | 11 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.h | 12 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser_unittest.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_stream.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_stream.h | 5 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser.h | 6 | ||||
-rw-r--r-- | core/fpdfapi/parser/fpdf_parser_utility.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/fpdf_parser_utility.h | 4 |
13 files changed, 38 insertions, 32 deletions
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<CFX_ByteStringPool> 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<uint8_t, FxFreeDeleter> m_pDataBuf; - IFX_FileRead* m_pFile = nullptr; + IFX_SeekableReadStream* m_pFile = nullptr; }; using UniqueStream = std::unique_ptr<CPDF_Stream, ReleaseDeleter<CPDF_Object>>; 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<CFX_ByteStringPool>& 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_ |