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

Unified Diff: fpdfsdk/fpdf_dataavail.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/include/cpdf_parser.h ('k') | fpdfsdk/fpdfdoc_unittest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/fpdf_dataavail.cpp
diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp
index 5dd42402eda7b1084be2694f0612a0f03105d826..7b9ba32fb0cc2ea5f64e06ad6943b73241473239 100644
--- a/fpdfsdk/fpdf_dataavail.cpp
+++ b/fpdfsdk/fpdf_dataavail.cpp
@@ -139,16 +139,17 @@ FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) {
std::unique_ptr<CPDF_Parser> pParser(new CPDF_Parser);
pParser->SetPassword(password);
- std::unique_ptr<CPDF_Document> pDocument(new CPDF_Document(pParser.get()));
- CPDF_Parser::Error error = pParser->StartLinearizedParse(
- pDataAvail->m_pDataAvail->GetFileRead(), std::move(pDocument));
+ std::unique_ptr<CPDF_Document> pDocument(
+ new CPDF_Document(std::move(pParser)));
+ CPDF_Parser::Error error = pDocument->GetParser()->StartLinearizedParse(
+ pDataAvail->m_pDataAvail->GetFileRead(), pDocument.get());
if (error != CPDF_Parser::SUCCESS) {
ProcessParseError(error);
return nullptr;
}
- pDataAvail->m_pDataAvail->SetDocument(pParser->GetDocument());
- CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS);
- return FPDFDocumentFromCPDFDocument(pParser.release()->GetDocument());
+ pDataAvail->m_pDataAvail->SetDocument(pDocument.get());
+ CheckUnSupportError(pDocument.get(), FPDF_ERR_SUCCESS);
+ return FPDFDocumentFromCPDFDocument(pDocument.release());
}
DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) {
« no previous file with comments | « core/fpdfapi/fpdf_parser/include/cpdf_parser.h ('k') | fpdfsdk/fpdfdoc_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698