chore: wrap cb with default invocation (#22013)

This commit is contained in:
Shelley Vohr 2020-02-04 19:06:03 +00:00 committed by GitHub
parent 6f1f4d3f2f
commit f14fc4b041
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,6 +23,7 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "shell/common/gin_helper/locker.h" #include "shell/common/gin_helper/locker.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
@ -99,10 +100,16 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
auto* client = auto* client =
printing::PrintCompositeClient::FromWebContents(web_contents()); printing::PrintCompositeClient::FromWebContents(web_contents());
DCHECK(client); DCHECK(client);
auto callback =
base::BindOnce(&PrintPreviewMessageHandler::OnCompositePdfDocumentDone,
weak_ptr_factory_.GetWeakPtr(), ids);
client->DoCompositeDocumentToPdf( client->DoCompositeDocumentToPdf(
params.document_cookie, render_frame_host, content, params.document_cookie, render_frame_host, content,
base::BindOnce(&PrintPreviewMessageHandler::OnCompositePdfDocumentDone, mojo::WrapCallbackWithDefaultInvokeIfNotRun(
weak_ptr_factory_.GetWeakPtr(), ids)); std::move(callback),
printing::mojom::PrintCompositor::Status::kCompositingFailure,
base::ReadOnlySharedMemoryRegion()));
} else { } else {
ResolvePromise(ids.request_id, ResolvePromise(ids.request_id,
base::RefCountedSharedMemoryMapping::CreateFromWholeRegion( base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(