Commit 16ab87b0 authored by Bo Majewski's avatar Bo Majewski Committed by Commit Bot

PDF Thumbnails: address comments from cl/2417790

Part 2 of 2:
Clean up mojo bound and call flow. reset() the pdf_thumbnailer_ when
the server replies with a Bitmap to make the code robust to server
errors (ignore disconnects) during post-processing of the Bitmap.

Bug: 1129607
No-try: true
Change-Id: I7dbbdecc667116c4d2a56e630b9f54162fb47279
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2426628
Commit-Queue: Bo Majewski <majewski@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810462}
parent 55e88398
...@@ -1229,14 +1229,12 @@ void FileManagerPrivateInternalGetThumbnailFunction::FetchPdfThumbnail( ...@@ -1229,14 +1229,12 @@ void FileManagerPrivateInternalGetThumbnailFunction::FetchPdfThumbnail(
return; return;
} }
memcpy(pdf_region.mapping.memory(), content.data(), content.size()); memcpy(pdf_region.mapping.memory(), content.data(), content.size());
if (!pdf_thumbnailer_.is_bound()) { DCHECK(!pdf_thumbnailer_.is_bound());
GetPrintingService()->BindPdfThumbnailer( GetPrintingService()->BindPdfThumbnailer(
pdf_thumbnailer_.BindNewPipeAndPassReceiver()); pdf_thumbnailer_.BindNewPipeAndPassReceiver());
pdf_thumbnailer_.set_disconnect_handler( pdf_thumbnailer_.set_disconnect_handler(base::BindOnce(
base::BindOnce(&FileManagerPrivateInternalGetThumbnailFunction:: &FileManagerPrivateInternalGetThumbnailFunction::PdfThumbnailDisconected,
PdfThumbnailDisconected,
base::Unretained(this))); base::Unretained(this)));
}
gfx::Size thumb_size = gfx::Size thumb_size =
crop_to_square crop_to_square
? gfx::Size(FileManagerPrivateInternalGetThumbnailFunction::kSize, ? gfx::Size(FileManagerPrivateInternalGetThumbnailFunction::kSize,
...@@ -1263,6 +1261,7 @@ void FileManagerPrivateInternalGetThumbnailFunction::PdfThumbnailDisconected() { ...@@ -1263,6 +1261,7 @@ void FileManagerPrivateInternalGetThumbnailFunction::PdfThumbnailDisconected() {
void FileManagerPrivateInternalGetThumbnailFunction::GotPdfThumbnail( void FileManagerPrivateInternalGetThumbnailFunction::GotPdfThumbnail(
const SkBitmap& bitmap) { const SkBitmap& bitmap) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
pdf_thumbnailer_.reset();
base::ThreadPool::PostTaskAndReplyWithResult( base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, base::BindOnce(&ConvertAndEncode, bitmap), FROM_HERE, base::BindOnce(&ConvertAndEncode, bitmap),
base::BindOnce( base::BindOnce(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment