Skip to content

Commit

Permalink
chore: wrap cb with default invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Feb 5, 2020
1 parent f263a3f commit 3599831
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions shell/browser/printing/print_preview_message_handler.cc
Expand Up @@ -23,6 +23,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "shell/common/api/locker.h"

#include "shell/common/node_includes.h"
Expand Down Expand Up @@ -98,10 +99,16 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
auto* client =
printing::PrintCompositeClient::FromWebContents(web_contents());
DCHECK(client);

auto callback =
base::BindOnce(&PrintPreviewMessageHandler::OnCompositePdfDocumentDone,
weak_ptr_factory_.GetWeakPtr(), ids);
client->DoCompositeDocumentToPdf(
params.document_cookie, render_frame_host, content,
base::BindOnce(&PrintPreviewMessageHandler::OnCompositePdfDocumentDone,
weak_ptr_factory_.GetWeakPtr(), ids));
mojo::WrapCallbackWithDefaultInvokeIfNotRun(
std::move(callback),
printing::mojom::PdfCompositor::Status::kCompositingFailure,
base::ReadOnlySharedMemoryRegion()));
} else {
ResolvePromise(ids.request_id,
base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(
Expand Down

0 comments on commit 3599831

Please sign in to comment.