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

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 1636413003: PDF: Load linearized files with FPDFAvail_GetDocument(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_engine.cc
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index 10f11d126bab753e53a370d020b9b6767b8e47c5..378e90492f0bf2454b0eab592c846c8c2da53e46 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -1113,8 +1113,10 @@ std::string PDFiumEngine::GetMetadata(const std::string& key) {
void PDFiumEngine::OnPartialDocumentLoaded() {
file_access_.m_FileLen = doc_loader_.document_size();
- fpdf_availability_ = FPDFAvail_Create(&file_availability_, &file_access_);
- DCHECK(fpdf_availability_);
+ if (!fpdf_availability_) {
Lei Zhang 2016/01/28 23:17:58 I haven't checked the possible call orders between
+ fpdf_availability_ = FPDFAvail_Create(&file_availability_, &file_access_);
+ DCHECK(fpdf_availability_);
+ }
// Currently engine does not deal efficiently with some non-linearized files.
// See http://code.google.com/p/chromium/issues/detail?id=59400
@@ -1157,6 +1159,10 @@ void PDFiumEngine::OnNewDataAvailable() {
void PDFiumEngine::OnDocumentComplete() {
if (!doc_ || !form_) {
file_access_.m_FileLen = doc_loader_.document_size();
+ if (!fpdf_availability_) {
+ fpdf_availability_ = FPDFAvail_Create(&file_availability_, &file_access_);
+ DCHECK(fpdf_availability_);
+ }
LoadDocument();
return;
}
@@ -2501,10 +2507,12 @@ bool PDFiumEngine::TryLoadingDoc(bool with_password,
password_cstr = password.c_str();
password_tries_remaining_--;
}
- if (doc_loader_.IsDocumentComplete())
+ if (doc_loader_.IsDocumentComplete() &&
+ !FPDFAvail_IsLinearized(fpdf_availability_)) {
doc_ = FPDF_LoadCustomDocument(&file_access_, password_cstr);
- else
+ } else {
doc_ = FPDFAvail_GetDocument(fpdf_availability_, password_cstr);
+ }
if (!doc_ && FPDF_GetLastError() == FPDF_ERR_PASSWORD)
*needs_password = true;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698