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

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

Issue 92173002: Merge 237541 "Revert of https://codereview.chromium.org/71013004/" (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1721/src/
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « net/base/net_util_win.cc ('k') | remoting/host/desktop_session_proxy.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_WIN_HELPER_H_ 5 #ifndef PRINTING_BACKEND_WIN_HELPER_H_
6 #define PRINTING_BACKEND_WIN_HELPER_H_ 6 #define PRINTING_BACKEND_WIN_HELPER_H_
7 7
8 #include <objidl.h> 8 #include <objidl.h>
9 #include <winspool.h> 9 #include <winspool.h>
10 #include <prntvpt.h> 10 #include <prntvpt.h>
(...skipping 28 matching lines...) Expand all
39 39
40 private: 40 private:
41 DISALLOW_IMPLICIT_CONSTRUCTORS(PrinterHandleTraits); 41 DISALLOW_IMPLICIT_CONSTRUCTORS(PrinterHandleTraits);
42 }; 42 };
43 43
44 class ScopedPrinterHandle 44 class ScopedPrinterHandle
45 : public base::win::GenericScopedHandle<PrinterHandleTraits, 45 : public base::win::GenericScopedHandle<PrinterHandleTraits,
46 base::win::VerifierTraits> { 46 base::win::VerifierTraits> {
47 public: 47 public:
48 bool OpenPrinter(const wchar_t* printer) { 48 bool OpenPrinter(const wchar_t* printer) {
49 HANDLE temp_handle;
50 // ::OpenPrinter may return error but assign some value into handle. 49 // ::OpenPrinter may return error but assign some value into handle.
51 if (::OpenPrinter(const_cast<LPTSTR>(printer), &temp_handle, NULL)) { 50 if (!::OpenPrinter(const_cast<LPTSTR>(printer), Receive(), NULL)) {
52 Set(temp_handle); 51 Take();
53 } 52 }
54 return IsValid(); 53 return IsValid();
55 } 54 }
56 55
57 private: 56 private:
58 typedef base::win::GenericScopedHandle<PrinterHandleTraits, 57 typedef base::win::GenericScopedHandle<PrinterHandleTraits,
59 base::win::VerifierTraits> Base; 58 base::win::VerifierTraits> Base;
59 // Hide Receive to avoid assigning handle when ::OpenPrinter returned error.
60 Base::Receiver Receive() {
61 return Base::Receive();
62 }
60 }; 63 };
61 64
62 class PrinterChangeHandleTraits { 65 class PrinterChangeHandleTraits {
63 public: 66 public:
64 typedef HANDLE Handle; 67 typedef HANDLE Handle;
65 68
66 static bool CloseHandle(HANDLE handle) { 69 static bool CloseHandle(HANDLE handle) {
67 ::FindClosePrinterChangeNotification(handle); 70 ::FindClosePrinterChangeNotification(handle);
68 return true; 71 return true;
69 } 72 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 }; 168 };
166 169
167 PRINTING_EXPORT bool InitBasicPrinterInfo(HANDLE printer, 170 PRINTING_EXPORT bool InitBasicPrinterInfo(HANDLE printer,
168 PrinterBasicInfo* printer_info); 171 PrinterBasicInfo* printer_info);
169 172
170 PRINTING_EXPORT std::string GetDriverInfo(HANDLE printer); 173 PRINTING_EXPORT std::string GetDriverInfo(HANDLE printer);
171 174
172 } // namespace printing 175 } // namespace printing
173 176
174 #endif // PRINTING_BACKEND_WIN_HELPER_H_ 177 #endif // PRINTING_BACKEND_WIN_HELPER_H_
OLDNEW
« no previous file with comments | « net/base/net_util_win.cc ('k') | remoting/host/desktop_session_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698