Update V8 to version 4.6.35.
[chromium-blink-merge.git] / printing / backend / printing_info_win.cc
blobe759639857fa1a2def920607fb6bffa69eaf8490
1 // Copyright (c) 2012 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/backend/printing_info_win.h"
7 #include "base/logging.h"
9 namespace printing {
11 namespace internal {
13 uint8* GetDriverInfo(HANDLE printer, int level) {
14 DWORD size = 0;
15 ::GetPrinterDriver(printer, NULL, level, NULL, 0, &size);
16 if (size == 0) {
17 return NULL;
19 scoped_ptr<uint8[]> buffer(new uint8[size]);
20 memset(buffer.get(), 0, size);
21 if (!::GetPrinterDriver(printer, NULL, level, buffer.get(), size, &size)) {
22 return NULL;
24 return buffer.release();
27 uint8* GetPrinterInfo(HANDLE printer, int level) {
28 DWORD size = 0;
29 ::GetPrinter(printer, level, NULL, 0, &size);
30 if (size == 0) {
31 LOG(WARNING) << "Failed to get size of PRINTER_INFO_" << level <<
32 ", error = " << GetLastError();
33 return NULL;
35 scoped_ptr<uint8[]> buffer(new uint8[size]);
36 memset(buffer.get(), 0, size);
37 if (!::GetPrinter(printer, level, buffer.get(), size, &size)) {
38 LOG(WARNING) << "Failed to get PRINTER_INFO_" << level <<
39 ", error = " << GetLastError();
40 return NULL;
42 return buffer.release();
45 } // namespace internal
47 } // namespace printing