1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "printing/metafile.h"
9 #include "base/files/file.h"
10 #include "base/numerics/safe_conversions.h"
14 MetafilePlayer::MetafilePlayer() {
17 MetafilePlayer::~MetafilePlayer() {
20 Metafile::Metafile() {
23 Metafile::~Metafile() {
26 bool Metafile::GetDataAsVector(std::vector
<char>* buffer
) const {
27 buffer
->resize(GetDataSize());
30 return GetData(&buffer
->front(),
31 base::checked_cast
<uint32_t>(buffer
->size()));
34 bool Metafile::SaveTo(base::File
* file
) const {
38 std::vector
<char> buffer
;
39 if (!GetDataAsVector(&buffer
))
42 int size
= base::checked_cast
<int>(buffer
.size());
43 if (file
->WriteAtCurrentPos(&buffer
[0], size
) != size
) {
44 DLOG(ERROR
) << "Failed to save file.";
50 } // namespace printing