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

Unified Diff: chrome/browser/printing/print_preview_pdf_generated_browsertest.cc

Issue 2541843005: Revert "Printing: Load the source PDF only once." (Closed)
Patch Set: Created 4 years 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 | « chrome/browser/printing/pdf_to_emf_converter.cc ('k') | chrome/common/chrome_utility_printing_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/printing/print_preview_pdf_generated_browsertest.cc
diff --git a/chrome/browser/printing/print_preview_pdf_generated_browsertest.cc b/chrome/browser/printing/print_preview_pdf_generated_browsertest.cc
index 034580aa0bf97b1b5403fcba48c04583b22cba5e..3260bb9c2a8fc868ad72cefc1093962894bdf265 100644
--- a/chrome/browser/printing/print_preview_pdf_generated_browsertest.cc
+++ b/chrome/browser/printing/print_preview_pdf_generated_browsertest.cc
@@ -335,25 +335,25 @@ class PrintPreviewPdfGeneratedBrowserTest : public InProcessBrowserTest {
// Converts the PDF to a PNG file so that the layout test can do an image
// diff on this image and a reference image.
void PdfToPng() {
- std::string pdf_data;
- ASSERT_TRUE(base::ReadFileToString(pdf_file_save_path_, &pdf_data));
-
int num_pages;
double max_width_in_points = 0;
- void* pdf_handle = nullptr;
+ std::vector<uint8_t> bitmap_data;
+ double total_height_in_pixels = 0;
+ std::string pdf_data;
+
+ ASSERT_TRUE(base::ReadFileToString(pdf_file_save_path_, &pdf_data));
ASSERT_TRUE(chrome_pdf::GetPDFDocInfo(pdf_data.data(), pdf_data.size(),
- &num_pages, &max_width_in_points,
- &pdf_handle));
+ &num_pages, &max_width_in_points));
+
ASSERT_GT(num_pages, 0);
double max_width_in_pixels =
ConvertUnitDouble(max_width_in_points, kPointsPerInch, kDpi);
- std::vector<uint8_t> bitmap_data;
- double total_height_in_pixels = 0;
for (int i = 0; i < num_pages; ++i) {
double width_in_points, height_in_points;
ASSERT_TRUE(chrome_pdf::GetPDFPageSizeByIndex(
- pdf_handle, i, &width_in_points, &height_in_points));
+ pdf_data.data(), pdf_data.size(), i, &width_in_points,
+ &height_in_points));
double width_in_pixels = ConvertUnitDouble(
width_in_points, kPointsPerInch, kDpi);
@@ -384,8 +384,9 @@ class PrintPreviewPdfGeneratedBrowserTest : public InProcessBrowserTest {
settings.area.size().GetArea());
ASSERT_TRUE(chrome_pdf::RenderPDFPageToBitmap(
- pdf_handle, i, page_bitmap_data.data(), settings.area.size().width(),
- settings.area.size().height(), settings.dpi, settings.autorotate));
+ pdf_data.data(), pdf_data.size(), i, page_bitmap_data.data(),
+ settings.area.size().width(), settings.area.size().height(),
+ settings.dpi, settings.autorotate));
FillPng(&page_bitmap_data, width_in_pixels, max_width_in_pixels,
settings.area.size().height());
bitmap_data.insert(bitmap_data.end(),
@@ -393,7 +394,6 @@ class PrintPreviewPdfGeneratedBrowserTest : public InProcessBrowserTest {
page_bitmap_data.end());
}
- chrome_pdf::ReleasePDFHandle(pdf_handle);
CreatePng(bitmap_data, max_width_in_pixels, total_height_in_pixels);
}
« no previous file with comments | « chrome/browser/printing/pdf_to_emf_converter.cc ('k') | chrome/common/chrome_utility_printing_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698