Browse Source

chore: wrap cb with default invocation (#22036)

Shelley Vohr 5 years ago
parent
commit
9439388b7b
1 changed files with 9 additions and 2 deletions
  1. 9 2
      shell/browser/printing/print_preview_message_handler.cc

+ 9 - 2
shell/browser/printing/print_preview_message_handler.cc

@@ -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"
@@ -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(