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

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

Issue 1763983002: Change scoped_ptr to a type alias for std::unique_ptr on OS_WIN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « base/memory/scoped_ptr.h ('k') | remoting/host/input_injector_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 "base/memory/scoped_ptr.h"
13 #include "printing/printing_export.h" 13 #include "printing/printing_export.h"
14 14
15 namespace printing { 15 namespace printing {
16 16
17 namespace internal { 17 namespace internal {
18 18
19 PRINTING_EXPORT uint8_t* GetDriverInfo(HANDLE printer, int level); 19 PRINTING_EXPORT uint8_t* GetDriverInfo(HANDLE printer, int level);
20 PRINTING_EXPORT uint8_t* GetPrinterInfo(HANDLE printer, int level); 20 PRINTING_EXPORT uint8_t* GetPrinterInfo(HANDLE printer, int level);
21 21
22 // This class is designed to work with PRINTER_INFO_X structures 22 // This class is designed to work with PRINTER_INFO_X structures
23 // and calls GetPrinter internally with correctly allocated buffer. 23 // and calls GetPrinter internally with correctly allocated buffer.
24 template <typename PrinterInfoType, int level> 24 template <typename PrinterInfoType, int level>
25 class PrinterInfo { 25 class PrinterInfo {
26 public: 26 public:
27 bool Init(HANDLE printer) { 27 bool Init(HANDLE printer) {
28 buffer_.reset(GetPrinterInfo(printer, level)); 28 buffer_.reset(GetPrinterInfo(printer, level));
29 return buffer_; 29 return buffer_ != nullptr;
Vitaly Buka (NO REVIEWS) 2016/03/04 18:25:17 is any warning without this? I thought Chromium pr
dcheng 2016/03/04 18:28:59 It depends on the reviewer =P With C++11 and expl
Vitaly Buka (NO REVIEWS) 2016/03/04 18:34:39 Thanks. I like !! too, but current one is lgtm too
joedow 2016/03/04 20:46:19 I like !! as well to boolify but I have seen feedb
30 } 30 }
31 31
32 const PrinterInfoType* get() const { 32 const PrinterInfoType* get() const {
33 return reinterpret_cast<const PrinterInfoType*>(buffer_.get()); 33 return reinterpret_cast<const PrinterInfoType*>(buffer_.get());
34 } 34 }
35 35
36 private: 36 private:
37 scoped_ptr<uint8_t[]> buffer_; 37 scoped_ptr<uint8_t[]> buffer_;
38 }; 38 };
39 39
40 // This class is designed to work with DRIVER_INFO_X structures 40 // This class is designed to work with DRIVER_INFO_X structures
41 // and calls GetDriverInfo internally with correctly allocated buffer. 41 // and calls GetDriverInfo internally with correctly allocated buffer.
42 template <typename DriverInfoType, int level> 42 template <typename DriverInfoType, int level>
43 class DriverInfo { 43 class DriverInfo {
44 public: 44 public:
45 bool Init(HANDLE printer) { 45 bool Init(HANDLE printer) {
46 buffer_.reset(GetDriverInfo(printer, level)); 46 buffer_.reset(GetDriverInfo(printer, level));
47 return buffer_; 47 return buffer_ != nullptr;
48 } 48 }
49 49
50 const DriverInfoType* get() const { 50 const DriverInfoType* get() const {
51 return reinterpret_cast<const DriverInfoType*>(buffer_.get()); 51 return reinterpret_cast<const DriverInfoType*>(buffer_.get());
52 } 52 }
53 53
54 private: 54 private:
55 scoped_ptr<uint8_t[]> buffer_; 55 scoped_ptr<uint8_t[]> buffer_;
56 }; 56 };
57 57
58 } // namespace internal 58 } // namespace internal
59 59
60 typedef internal::PrinterInfo<PRINTER_INFO_2, 2> PrinterInfo2; 60 typedef internal::PrinterInfo<PRINTER_INFO_2, 2> PrinterInfo2;
61 typedef internal::PrinterInfo<PRINTER_INFO_5, 5> PrinterInfo5; 61 typedef internal::PrinterInfo<PRINTER_INFO_5, 5> PrinterInfo5;
62 62
63 typedef internal::DriverInfo<DRIVER_INFO_6, 6> DriverInfo6; 63 typedef internal::DriverInfo<DRIVER_INFO_6, 6> DriverInfo6;
64 64
65 } // namespace printing 65 } // namespace printing
66 66
67 #endif // PRINTING_BACKEND_PRINTING_INFO_WIN_H_ 67 #endif // PRINTING_BACKEND_PRINTING_INFO_WIN_H_
OLDNEW
« no previous file with comments | « base/memory/scoped_ptr.h ('k') | remoting/host/input_injector_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698