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

Side by Side Diff: pdf/pdfium/pdfium_engine.cc

Issue 2516453003: PDF: Fix progress bar for files of unknown size. (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "pdf/pdfium/pdfium_engine.h" 5 #include "pdf/pdfium/pdfium_engine.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 if (IsPageVisible(pending_page)) 1207 if (IsPageVisible(pending_page))
1208 client_->Invalidate(GetPageScreenRect(pending_page)); 1208 client_->Invalidate(GetPageScreenRect(pending_page));
1209 } 1209 }
1210 } 1210 }
1211 pending_pages_.swap(still_pending); 1211 pending_pages_.swap(still_pending);
1212 if (update_pages) 1212 if (update_pages)
1213 LoadPageInfo(true); 1213 LoadPageInfo(true);
1214 } 1214 }
1215 1215
1216 void PDFiumEngine::OnNewDataAvailable() { 1216 void PDFiumEngine::OnNewDataAvailable() {
1217 if (!doc_loader_->GetDocumentSize()) {
1218 client_->DocumentLoadProgress(doc_loader_->count_of_bytes_received(), 0);
1219 return;
1220 }
1221
1217 const float progress = doc_loader_->GetProgress(); 1222 const float progress = doc_loader_->GetProgress();
1218 if (progress < 0.001) { 1223 DCHECK_GE(progress, 0.0);
1219 client_->DocumentLoadProgress(0, 0); 1224 DCHECK_LE(progress, 1.0);
1220 } else { 1225 client_->DocumentLoadProgress(progress * 10000, 10000);
1221 client_->DocumentLoadProgress(progress * 10000, 10000);
1222 }
1223 } 1226 }
1224 1227
1225 void PDFiumEngine::OnDocumentComplete() { 1228 void PDFiumEngine::OnDocumentComplete() {
1226 if (doc_) { 1229 if (doc_) {
1227 return FinishLoadingDocument(); 1230 return FinishLoadingDocument();
1228 } 1231 }
1229 file_access_.m_FileLen = doc_loader_->GetDocumentSize(); 1232 file_access_.m_FileLen = doc_loader_->GetDocumentSize();
1230 if (!fpdf_availability_) { 1233 if (!fpdf_availability_) {
1231 fpdf_availability_ = FPDFAvail_Create(&file_availability_, &file_access_); 1234 fpdf_availability_ = FPDFAvail_Create(&file_availability_, &file_access_);
1232 DCHECK(fpdf_availability_); 1235 DCHECK(fpdf_availability_);
(...skipping 2917 matching lines...) Expand 10 before | Expand all | Expand 10 after
4150 4153
4151 bool PDFiumEngineExports::GetPDFPageSizeByIndex(void* pdf_handle, 4154 bool PDFiumEngineExports::GetPDFPageSizeByIndex(void* pdf_handle,
4152 int page_number, 4155 int page_number,
4153 double* width, 4156 double* width,
4154 double* height) { 4157 double* height) {
4155 FPDF_DOCUMENT doc = pdf_handle; 4158 FPDF_DOCUMENT doc = pdf_handle;
4156 return doc && FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 4159 return doc && FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
4157 } 4160 }
4158 4161
4159 } // namespace chrome_pdf 4162 } // namespace chrome_pdf
OLDNEW
« 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