Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: printing/backend/printing_info_win.h

Issue 1863223002: Convert //printing to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « printing/backend/print_backend_win.cc ('k') | printing/backend/printing_info_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PRINTING_BACKEND_PRINTING_INFO_WIN_H_ 5 #ifndef PRINTING_BACKEND_PRINTING_INFO_WIN_H_
6 #define PRINTING_BACKEND_PRINTING_INFO_WIN_H_ 6 #define PRINTING_BACKEND_PRINTING_INFO_WIN_H_
7 7
8 #include <objidl.h> 8 #include <objidl.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <winspool.h> 10 #include <winspool.h>
11 11
12 #include "base/memory/scoped_ptr.h" 12 #include <memory>
13
13 #include "printing/printing_export.h" 14 #include "printing/printing_export.h"
14 15
15 namespace printing { 16 namespace printing {
16 17
17 namespace internal { 18 namespace internal {
18 19
19 PRINTING_EXPORT uint8_t* GetDriverInfo(HANDLE printer, int level); 20 PRINTING_EXPORT uint8_t* GetDriverInfo(HANDLE printer, int level);
20 PRINTING_EXPORT uint8_t* GetPrinterInfo(HANDLE printer, int level); 21 PRINTING_EXPORT uint8_t* GetPrinterInfo(HANDLE printer, int level);
21 22
22 // This class is designed to work with PRINTER_INFO_X structures 23 // This class is designed to work with PRINTER_INFO_X structures
23 // and calls GetPrinter internally with correctly allocated buffer. 24 // and calls GetPrinter internally with correctly allocated buffer.
24 template <typename PrinterInfoType, int level> 25 template <typename PrinterInfoType, int level>
25 class PrinterInfo { 26 class PrinterInfo {
26 public: 27 public:
27 bool Init(HANDLE printer) { 28 bool Init(HANDLE printer) {
28 buffer_.reset(GetPrinterInfo(printer, level)); 29 buffer_.reset(GetPrinterInfo(printer, level));
29 return buffer_ != nullptr; 30 return buffer_ != nullptr;
30 } 31 }
31 32
32 const PrinterInfoType* get() const { 33 const PrinterInfoType* get() const {
33 return reinterpret_cast<const PrinterInfoType*>(buffer_.get()); 34 return reinterpret_cast<const PrinterInfoType*>(buffer_.get());
34 } 35 }
35 36
36 private: 37 private:
37 scoped_ptr<uint8_t[]> buffer_; 38 std::unique_ptr<uint8_t[]> buffer_;
38 }; 39 };
39 40
40 // This class is designed to work with DRIVER_INFO_X structures 41 // This class is designed to work with DRIVER_INFO_X structures
41 // and calls GetDriverInfo internally with correctly allocated buffer. 42 // and calls GetDriverInfo internally with correctly allocated buffer.
42 template <typename DriverInfoType, int level> 43 template <typename DriverInfoType, int level>
43 class DriverInfo { 44 class DriverInfo {
44 public: 45 public:
45 bool Init(HANDLE printer) { 46 bool Init(HANDLE printer) {
46 buffer_.reset(GetDriverInfo(printer, level)); 47 buffer_.reset(GetDriverInfo(printer, level));
47 return buffer_ != nullptr; 48 return buffer_ != nullptr;
48 } 49 }
49 50
50 const DriverInfoType* get() const { 51 const DriverInfoType* get() const {
51 return reinterpret_cast<const DriverInfoType*>(buffer_.get()); 52 return reinterpret_cast<const DriverInfoType*>(buffer_.get());
52 } 53 }
53 54
54 private: 55 private:
55 scoped_ptr<uint8_t[]> buffer_; 56 std::unique_ptr<uint8_t[]> buffer_;
56 }; 57 };
57 58
58 } // namespace internal 59 } // namespace internal
59 60
60 typedef internal::PrinterInfo<PRINTER_INFO_2, 2> PrinterInfo2; 61 typedef internal::PrinterInfo<PRINTER_INFO_2, 2> PrinterInfo2;
61 typedef internal::PrinterInfo<PRINTER_INFO_5, 5> PrinterInfo5; 62 typedef internal::PrinterInfo<PRINTER_INFO_5, 5> PrinterInfo5;
62 63
63 typedef internal::DriverInfo<DRIVER_INFO_6, 6> DriverInfo6; 64 typedef internal::DriverInfo<DRIVER_INFO_6, 6> DriverInfo6;
64 65
65 } // namespace printing 66 } // namespace printing
66 67
67 #endif // PRINTING_BACKEND_PRINTING_INFO_WIN_H_ 68 #endif // PRINTING_BACKEND_PRINTING_INFO_WIN_H_
OLDNEW
« no previous file with comments | « printing/backend/print_backend_win.cc ('k') | printing/backend/printing_info_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698