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

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

Issue 2275773003: Flip document and parser ownership (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@private_parser
Patch Set: Rebase to master 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 | « core/fpdfapi/fpdf_parser/cpdf_document.cpp ('k') | core/fpdfapi/fpdf_parser/include/cpdf_document.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 ffd3f79a621955629271fa7935d667a109021d72..e2bab450bee351722c5792c953cff38ecd380bce 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
@@ -126,7 +126,7 @@ void CPDF_Parser::ShrinkObjectMap(uint32_t objnum) {
void CPDF_Parser::CloseParser() {
m_bVersionUpdated = false;
- m_pDocument.reset();
+ m_pDocument = nullptr;
if (m_pTrailer) {
m_pTrailer->Release();
@@ -158,9 +158,8 @@ void CPDF_Parser::CloseParser() {
}
}
-CPDF_Parser::Error CPDF_Parser::StartParse(
- IFX_FileRead* pFileAccess,
- std::unique_ptr<CPDF_Document> pDocument) {
+CPDF_Parser::Error CPDF_Parser::StartParse(IFX_FileRead* pFileAccess,
+ CPDF_Document* pDocument) {
CloseParser();
m_bXRefStream = FALSE;
@@ -190,7 +189,7 @@ CPDF_Parser::Error CPDF_Parser::StartParse(
return FORMAT_ERROR;
m_pSyntax->RestorePos(m_pSyntax->m_FileLen - m_pSyntax->m_HeaderOffset - 9);
- m_pDocument = std::move(pDocument);
+ m_pDocument = pDocument;
FX_BOOL bXRefRebuilt = FALSE;
if (m_pSyntax->SearchWord("startxref", TRUE, FALSE, 4096)) {
@@ -765,7 +764,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
last_obj = start_pos;
FX_FILESIZE obj_end = 0;
CPDF_Object* pObject = ParseIndirectObjectAtByStrict(
- m_pDocument.get(), obj_pos, objnum, &obj_end);
+ m_pDocument, obj_pos, objnum, &obj_end);
if (CPDF_Stream* pStream = ToStream(pObject)) {
if (CPDF_Dictionary* pDict = pStream->GetDict()) {
if ((pDict->KeyExist("Type")) &&
@@ -828,8 +827,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
last_trailer = pos + i - 7;
m_pSyntax->RestorePos(pos + i - m_pSyntax->m_HeaderOffset);
- CPDF_Object* pObj =
- m_pSyntax->GetObject(m_pDocument.get(), 0, 0, true);
+ CPDF_Object* pObj = m_pSyntax->GetObject(m_pDocument, 0, 0, true);
if (pObj) {
if (!pObj->IsDictionary() && !pObj->AsStream()) {
pObj->Release();
@@ -851,7 +849,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
uint32_t dwObjNum =
pElement ? pElement->GetObjNum() : 0;
if (dwObjNum) {
- m_pTrailer->SetAtReference(key, m_pDocument.get(),
+ m_pTrailer->SetAtReference(key, m_pDocument,
dwObjNum);
} else {
m_pTrailer->SetAt(key, pElement->Clone());
@@ -975,7 +973,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
}
FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
- CPDF_Object* pObject = ParseIndirectObjectAt(m_pDocument.get(), *pos, 0);
+ CPDF_Object* pObject = ParseIndirectObjectAt(m_pDocument, *pos, 0);
if (!pObject)
return FALSE;
@@ -1478,7 +1476,7 @@ CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() {
return nullptr;
std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj(
- m_pSyntax->GetObject(m_pDocument.get(), 0, 0, true));
+ m_pSyntax->GetObject(m_pDocument, 0, 0, true));
if (!ToDictionary(pObj.get()))
return nullptr;
return pObj.release()->AsDictionary();
@@ -1550,9 +1548,8 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess,
return FALSE;
}
-CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
- IFX_FileRead* pFileAccess,
- std::unique_ptr<CPDF_Document> pDocument) {
+CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(IFX_FileRead* pFileAccess,
+ CPDF_Document* pDocument) {
CloseParser();
m_bXRefStream = FALSE;
m_LastXRefOffset = 0;
@@ -1567,7 +1564,7 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
return StartParse(pFileAccess, std::move(pDocument));
}
- m_pDocument = std::move(pDocument);
+ m_pDocument = pDocument;
FX_FILESIZE dwFirstXRefOffset = m_pSyntax->SavePos();
FX_BOOL bXRefRebuilt = FALSE;
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_document.cpp ('k') | core/fpdfapi/fpdf_parser/include/cpdf_document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698