Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / printing / metafile.cc
blobece61dfa857ed87295961f9109ef168bcf2f4f3f
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"
7 #include <vector>
9 #include "base/files/file.h"
10 #include "base/numerics/safe_conversions.h"
12 namespace printing {
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());
28 if (buffer->empty())
29 return false;
30 return GetData(&buffer->front(), base::checked_cast<uint32>(buffer->size()));
33 bool Metafile::SaveTo(base::File* file) const {
34 if (!file->IsValid())
35 return false;
37 std::vector<char> buffer;
38 if (!GetDataAsVector(&buffer))
39 return false;
41 int size = base::checked_cast<int>(buffer.size());
42 if (file->WriteAtCurrentPos(&buffer[0], size) != size) {
43 DLOG(ERROR) << "Failed to save file.";
44 return false;
46 return true;
49 } // namespace printing