Commit 5d496802 authored by Vladislav Kuzkokov's avatar Vladislav Kuzkokov Committed by Commit Bot

Simplify HeadlessPrintManager::OnDidPrintPage

Considering that PdfMetafileSkia doesn't make any sanity checks here,
creating it from bytes and then pulling those bytes back looks like an
overly complicated no-op

Change-Id: Ie564453318a606d7f71167d0596d44f2a69f589c
Reviewed-on: https://chromium-review.googlesource.com/696202Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Commit-Queue: Vladislav Kuzkokov <vkuzkokov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506381}
parent 908d7abe
......@@ -16,7 +16,6 @@
#include "components/printing/browser/print_manager_utils.h"
#include "components/printing/common/print_messages.h"
#include "content/public/browser/render_view_host.h"
#include "printing/pdf_metafile_skia.h"
#include "printing/print_job_constants.h"
#include "printing/units.h"
......@@ -312,18 +311,8 @@ void HeadlessPrintManager::OnDidPrintPage(
ReleaseJob(METAFILE_MAP_ERROR);
return;
}
auto metafile = base::MakeUnique<printing::PdfMetafileSkia>(
printing::SkiaDocumentType::PDF);
if (!metafile->InitFromData(shared_buf->memory(), params.data_size)) {
ReleaseJob(METAFILE_INVALID_HEADER);
return;
}
std::vector<char> buffer;
if (!metafile->GetDataAsVector(&buffer)) {
ReleaseJob(METAFILE_GET_DATA_ERROR);
return;
}
data_ = std::string(buffer.data(), buffer.size());
data_ = std::string(static_cast<const char*>(shared_buf->memory()),
params.data_size);
} else {
if (base::SharedMemory::IsHandleValid(params.metafile_data_handle)) {
base::SharedMemory::CloseHandle(params.metafile_data_handle);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment