Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: core/fpdfapi/fpdf_parser/cpdf_parser.cpp

Issue 2267173005: Removing CPDF_Parser::CloseParser. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_parser/include/cpdf_parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_parser/cpdf_parser.cpp
diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
index e2bab450bee351722c5792c953cff38ecd380bce..9d26104caa4c59069293c641d09d69166d83e8db 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
@@ -51,7 +51,8 @@ int32_t GetStreamFirst(CPDF_StreamAcc* pObjStream) {
} // namespace
CPDF_Parser::CPDF_Parser()
- : m_bOwnFileRead(true),
+ : m_bHasParsed(false),
+ m_bOwnFileRead(true),
m_FileVersion(0),
m_pTrailer(nullptr),
m_pEncryptDict(nullptr),
@@ -63,7 +64,25 @@ CPDF_Parser::CPDF_Parser()
}
CPDF_Parser::~CPDF_Parser() {
- CloseParser();
+ if (m_pTrailer)
+ m_pTrailer->Release();
+
+ ReleaseEncryptHandler();
+ SetEncryptDictionary(nullptr);
+
+ if (m_bOwnFileRead && m_pSyntax->m_pFileAccess) {
+ m_pSyntax->m_pFileAccess->Release();
+ m_pSyntax->m_pFileAccess = nullptr;
+ }
+
+ int32_t iLen = m_Trailers.GetSize();
+ for (int32_t i = 0; i < iLen; ++i) {
+ if (CPDF_Dictionary* trailer = m_Trailers.GetAt(i))
+ trailer->Release();
+ }
+
+ if (m_pLinearized)
+ m_pLinearized->Release();
}
uint32_t CPDF_Parser::GetLastObjNum() const {
@@ -124,43 +143,10 @@ void CPDF_Parser::ShrinkObjectMap(uint32_t objnum) {
m_ObjectInfo[objnum - 1].pos = 0;
}
-void CPDF_Parser::CloseParser() {
- m_bVersionUpdated = false;
- m_pDocument = nullptr;
-
- if (m_pTrailer) {
- m_pTrailer->Release();
- m_pTrailer = nullptr;
- }
- ReleaseEncryptHandler();
- SetEncryptDictionary(nullptr);
-
- if (m_bOwnFileRead && m_pSyntax->m_pFileAccess) {
- m_pSyntax->m_pFileAccess->Release();
- m_pSyntax->m_pFileAccess = nullptr;
- }
-
- m_ObjectStreamMap.clear();
- m_ObjCache.clear();
- m_SortedOffset.clear();
- m_ObjectInfo.clear();
-
- int32_t iLen = m_Trailers.GetSize();
- for (int32_t i = 0; i < iLen; ++i) {
- if (CPDF_Dictionary* trailer = m_Trailers.GetAt(i))
- trailer->Release();
- }
- m_Trailers.RemoveAll();
-
- if (m_pLinearized) {
- m_pLinearized->Release();
- m_pLinearized = nullptr;
- }
-}
-
CPDF_Parser::Error CPDF_Parser::StartParse(IFX_FileRead* pFileAccess,
CPDF_Document* pDocument) {
- CloseParser();
+ ASSERT(!m_bHasParsed);
+ m_bHasParsed = true;
m_bXRefStream = FALSE;
m_LastXRefOffset = 0;
@@ -1550,7 +1536,8 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess,
CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(IFX_FileRead* pFileAccess,
CPDF_Document* pDocument) {
- CloseParser();
+ ASSERT(!m_bHasParsed);
+
m_bXRefStream = FALSE;
m_LastXRefOffset = 0;
m_bOwnFileRead = true;
@@ -1563,8 +1550,9 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(IFX_FileRead* pFileAccess,
m_pSyntax->m_pFileAccess = nullptr;
return StartParse(pFileAccess, std::move(pDocument));
}
-
+ m_bHasParsed = true;
m_pDocument = pDocument;
+
FX_FILESIZE dwFirstXRefOffset = m_pSyntax->SavePos();
FX_BOOL bXRefRebuilt = FALSE;
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_parser/include/cpdf_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698