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

Side by Side Diff: printing/backend/print_backend_win.cc

Issue 175603002: Less strict CHECK for DeviceCapabilities results. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 #include "printing/backend/print_backend.h" 5 #include "printing/backend/print_backend.h"
6 6
7 #include <objidl.h> 7 #include <objidl.h>
8 #include <winspool.h> 8 #include <winspool.h>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/numerics/safe_conversions.h"
11 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "base/win/scoped_bstr.h" 14 #include "base/win/scoped_bstr.h"
14 #include "base/win/scoped_comptr.h" 15 #include "base/win/scoped_comptr.h"
15 #include "base/win/scoped_hglobal.h" 16 #include "base/win/scoped_hglobal.h"
16 #include "printing/backend/print_backend_consts.h" 17 #include "printing/backend/print_backend_consts.h"
17 #include "printing/backend/printing_info_win.h" 18 #include "printing/backend/printing_info_win.h"
18 #include "printing/backend/win_helper.h" 19 #include "printing/backend/win_helper.h"
19 20
20 namespace printing { 21 namespace printing {
(...skipping 14 matching lines...) Expand all
35 } 36 }
36 37
37 template <class T> 38 template <class T>
38 void GetDeviceCapabilityArray(const wchar_t* printer, 39 void GetDeviceCapabilityArray(const wchar_t* printer,
39 const wchar_t* port, 40 const wchar_t* port,
40 WORD id, 41 WORD id,
41 std::vector<T>* result) { 42 std::vector<T>* result) {
42 int count = DeviceCapabilities(printer, port, id, NULL, NULL); 43 int count = DeviceCapabilities(printer, port, id, NULL, NULL);
43 if (count <= 0) 44 if (count <= 0)
44 return; 45 return;
45 result->resize(count); 46 std::vector<T> tmp;
46 CHECK_EQ(count, 47 tmp.resize(count * 2);
47 DeviceCapabilities(printer, port, id, 48 count = DeviceCapabilities(printer, port, id,
48 reinterpret_cast<LPTSTR>(result->data()), NULL)); 49 reinterpret_cast<LPTSTR>(tmp.data()), NULL);
50 if (count <= 0)
51 return;
52 CHECK_LE(count, base::checked_cast<int>(tmp.size()));
53 tmp.resize(count);
54 result->swap(tmp);
49 } 55 }
50 56
51 void LoadPaper(const wchar_t* printer, 57 void LoadPaper(const wchar_t* printer,
52 const wchar_t* port, 58 const wchar_t* port,
53 const DEVMODE* devmode, 59 const DEVMODE* devmode,
54 PrinterSemanticCapsAndDefaults* caps) { 60 PrinterSemanticCapsAndDefaults* caps) {
55 static const size_t kToUm = 100; // Windows uses 0.1mm. 61 static const size_t kToUm = 100; // Windows uses 0.1mm.
56 static const size_t kMaxPaperName = 64; 62 static const size_t kMaxPaperName = 64;
57 63
58 struct PaperName { 64 struct PaperName {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 ScopedPrinterHandle printer_handle; 360 ScopedPrinterHandle printer_handle;
355 return printer_handle.OpenPrinter(base::UTF8ToWide(printer_name)); 361 return printer_handle.OpenPrinter(base::UTF8ToWide(printer_name));
356 } 362 }
357 363
358 scoped_refptr<PrintBackend> PrintBackend::CreateInstance( 364 scoped_refptr<PrintBackend> PrintBackend::CreateInstance(
359 const base::DictionaryValue* print_backend_settings) { 365 const base::DictionaryValue* print_backend_settings) {
360 return new PrintBackendWin; 366 return new PrintBackendWin;
361 } 367 }
362 368
363 } // namespace printing 369 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698