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

Side by Side Diff: components/printing/service/public/cpp/pdf_compositor_client.cc

Issue 2919823004: Add error handling and unit test for pdf compositor service (Closed)
Patch Set: rebase Created 3 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "components/printing/service/public/cpp/pdf_compositor_client.h" 5 #include "components/printing/service/public/cpp/pdf_compositor_client.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "mojo/public/cpp/system/platform_handle.h" 9 #include "mojo/public/cpp/system/platform_handle.h"
10 10
11 namespace printing { 11 namespace printing {
12 12
13 namespace { 13 namespace {
14 14
15 // Helper callback which owns an PdfCompositorPtr until invoked. This keeps the 15 // Helper callback which owns an PdfCompositorPtr until invoked. This keeps the
16 // PdfCompositor pipe open just long enough to dispatch a reply, at which point 16 // PdfCompositor pipe open just long enough to dispatch a reply, at which point
17 // the reply is forwarded to the wrapped |callback|. 17 // the reply is forwarded to the wrapped |callback|.
18 void OnCompositePdf( 18 void OnCompositePdf(
19 printing::mojom::PdfCompositorPtr compositor, 19 printing::mojom::PdfCompositorPtr compositor,
20 printing::mojom::PdfCompositor::CompositePdfCallback callback, 20 printing::mojom::PdfCompositor::CompositePdfCallback callback,
21 scoped_refptr<base::SequencedTaskRunner> task_runner, 21 scoped_refptr<base::SequencedTaskRunner> task_runner,
22 mojom::PdfCompositor::Status status,
22 mojo::ScopedSharedBufferHandle pdf_handle) { 23 mojo::ScopedSharedBufferHandle pdf_handle) {
23 task_runner->PostTask(FROM_HERE, base::BindOnce(std::move(callback), 24 task_runner->PostTask(FROM_HERE, base::BindOnce(std::move(callback), status,
24 base::Passed(&pdf_handle))); 25 base::Passed(&pdf_handle)));
25 } 26 }
26 27
27 } // namespace 28 } // namespace
28 29
29 PdfCompositorClient::PdfCompositorClient() : compositor_(nullptr) {} 30 PdfCompositorClient::PdfCompositorClient() : compositor_(nullptr) {}
30 31
31 PdfCompositorClient::~PdfCompositorClient() {} 32 PdfCompositorClient::~PdfCompositorClient() {}
32 33
33 void PdfCompositorClient::Connect(service_manager::Connector* connector) { 34 void PdfCompositorClient::Connect(service_manager::Connector* connector) {
(...skipping 15 matching lines...) Expand all
49 mojo::ScopedSharedBufferHandle buffer_handle = 50 mojo::ScopedSharedBufferHandle buffer_handle =
50 mojo::WrapSharedMemoryHandle(handle, data_size, true); 51 mojo::WrapSharedMemoryHandle(handle, data_size, true);
51 52
52 compositor_->CompositePdf( 53 compositor_->CompositePdf(
53 std::move(buffer_handle), 54 std::move(buffer_handle),
54 base::BindOnce(&OnCompositePdf, base::Passed(&compositor_), 55 base::BindOnce(&OnCompositePdf, base::Passed(&compositor_),
55 std::move(callback), callback_task_runner)); 56 std::move(callback), callback_task_runner));
56 } 57 }
57 58
58 } // namespace printing 59 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698