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

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

Issue 71013004: Base: Remove Receive() from ScopedHandle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix delegate_execute for google_chrome_build 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;
49 // ::OpenPrinter may return error but assign some value into handle. 50 // ::OpenPrinter may return error but assign some value into handle.
50 if (!::OpenPrinter(const_cast<LPTSTR>(printer), Receive(), NULL)) { 51 if (::OpenPrinter(const_cast<LPTSTR>(printer), &temp_handle, NULL)) {
51 Take(); 52 Set(temp_handle);
52 } 53 }
53 return IsValid(); 54 return IsValid();
54 } 55 }
55 56
56 private: 57 private:
57 typedef base::win::GenericScopedHandle<PrinterHandleTraits, 58 typedef base::win::GenericScopedHandle<PrinterHandleTraits,
58 base::win::VerifierTraits> Base; 59 base::win::VerifierTraits> Base;
59 // Hide Receive to avoid assigning handle when ::OpenPrinter returned error.
60 Base::Receiver Receive() {
61 return Base::Receive();
62 }
63 }; 60 };
64 61
65 class PrinterChangeHandleTraits { 62 class PrinterChangeHandleTraits {
66 public: 63 public:
67 typedef HANDLE Handle; 64 typedef HANDLE Handle;
68 65
69 static bool CloseHandle(HANDLE handle) { 66 static bool CloseHandle(HANDLE handle) {
70 ::FindClosePrinterChangeNotification(handle); 67 ::FindClosePrinterChangeNotification(handle);
71 return true; 68 return true;
72 } 69 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 }; 165 };
169 166
170 PRINTING_EXPORT bool InitBasicPrinterInfo(HANDLE printer, 167 PRINTING_EXPORT bool InitBasicPrinterInfo(HANDLE printer,
171 PrinterBasicInfo* printer_info); 168 PrinterBasicInfo* printer_info);
172 169
173 PRINTING_EXPORT std::string GetDriverInfo(HANDLE printer); 170 PRINTING_EXPORT std::string GetDriverInfo(HANDLE printer);
174 171
175 } // namespace printing 172 } // namespace printing
176 173
177 #endif // PRINTING_BACKEND_WIN_HELPER_H_ 174 #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