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

Unified Diff: components/printing/service/pdf_compositor_impl.cc

Issue 2919823004: Add error handling and unit test for pdf compositor service (Closed)
Patch Set: rebase Created 3 years, 5 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
Index: components/printing/service/pdf_compositor_impl.cc
diff --git a/components/printing/service/pdf_compositor_impl.cc b/components/printing/service/pdf_compositor_impl.cc
index c27e466ddd83cdf8339537b69efa8bfd27af38d9..c22998a7bc9792df6aef936ed2357f052955e7fb 100644
--- a/components/printing/service/pdf_compositor_impl.cc
+++ b/components/printing/service/pdf_compositor_impl.cc
@@ -43,7 +43,8 @@ void PdfCompositorImpl::CompositePdf(
base::MakeUnique<base::SharedMemory>(memory_handle, true);
if (!shm->Map(memory_size)) {
DLOG(ERROR) << "CompositePdf: Shared memory map failed.";
- std::move(callback).Run(mojo::ScopedSharedBufferHandle());
+ std::move(callback).Run(mojom::PdfCompositor::Status::HANDLE_MAP_ERROR,
+ mojo::ScopedSharedBufferHandle());
return;
}
@@ -51,14 +52,16 @@ void PdfCompositorImpl::CompositePdf(
int page_count = SkMultiPictureDocumentReadPageCount(&stream);
if (!page_count) {
DLOG(ERROR) << "CompositePdf: No page is read.";
- std::move(callback).Run(mojo::ScopedSharedBufferHandle());
+ std::move(callback).Run(mojom::PdfCompositor::Status::CONTENT_FORMAT_ERROR,
+ mojo::ScopedSharedBufferHandle());
return;
}
std::vector<SkDocumentPage> pages(page_count);
if (!SkMultiPictureDocumentRead(&stream, pages.data(), page_count)) {
DLOG(ERROR) << "CompositePdf: Page reading failed.";
- std::move(callback).Run(mojo::ScopedSharedBufferHandle());
+ std::move(callback).Run(mojom::PdfCompositor::Status::CONTENT_FORMAT_ERROR,
+ mojo::ScopedSharedBufferHandle());
return;
}
@@ -80,7 +83,8 @@ void PdfCompositorImpl::CompositePdf(
DCHECK(mapping);
wstream.copyToAndReset(mapping.get());
- std::move(callback).Run(std::move(buffer));
+ std::move(callback).Run(mojom::PdfCompositor::Status::SUCCESS,
+ std::move(buffer));
}
} // namespace printing

Powered by Google App Engine
This is Rietveld 408576698