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

Side by Side Diff: chrome/service/cloud_print/print_system_win.cc

Issue 9212020: Make scoped dc objects smarter. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 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
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 "chrome/service/cloud_print/print_system.h" 5 #include "chrome/service/cloud_print/print_system.h"
6 6
7 #include <objidl.h> 7 #include <objidl.h>
8 #include <winspool.h> 8 #include <winspool.h>
9 #include <xpsprint.h> 9 #include <xpsprint.h>
10 10
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 HRESULT hr = PrintTicketToDevMode(printer_name, print_ticket, 400 HRESULT hr = PrintTicketToDevMode(printer_name, print_ticket,
401 &pt_dev_mode); 401 &pt_dev_mode);
402 if (FAILED(hr)) { 402 if (FAILED(hr)) {
403 NOTREACHED(); 403 NOTREACHED();
404 return false; 404 return false;
405 } 405 }
406 406
407 HDC dc = CreateDC(L"WINSPOOL", UTF8ToWide(printer_name).c_str(), 407 HDC dc = CreateDC(L"WINSPOOL", UTF8ToWide(printer_name).c_str(),
408 NULL, pt_dev_mode.dm_); 408 NULL, pt_dev_mode.dm_);
409 if (!dc) { 409 if (!dc) {
410 NOTREACHED(); 410 NOTREACHED();
Peter Kasting 2012/02/08 00:38:49 Is it possible for the CreateDC() call to fail leg
cpu_(ooo_6.6-7.5) 2012/02/10 19:41:55 Not an expert on printing but I can imagine that i
411 return false; 411 return false;
412 } 412 }
413 printer_dc_.Set(dc);
414
413 hr = E_FAIL; 415 hr = E_FAIL;
414 DOCINFO di = {0}; 416 DOCINFO di = {0};
415 di.cbSize = sizeof(DOCINFO); 417 di.cbSize = sizeof(DOCINFO);
416 std::wstring doc_name = UTF8ToWide(job_title); 418 std::wstring doc_name = UTF8ToWide(job_title);
417 di.lpszDocName = doc_name.c_str(); 419 di.lpszDocName = doc_name.c_str();
418 job_id_ = StartDoc(dc, &di); 420 job_id_ = StartDoc(dc, &di);
419 if (job_id_ <= 0) 421 if (job_id_ <= 0)
420 return false; 422 return false;
421 423
422 printer_dc_.Set(dc);
423 saved_dc_ = SaveDC(printer_dc_.Get()); 424 saved_dc_ = SaveDC(printer_dc_.Get());
424 print_data_file_path_ = print_data_file_path; 425 print_data_file_path_ = print_data_file_path;
425 delegate_ = delegate; 426 delegate_ = delegate;
426 RenderNextPDFPages(); 427 RenderNextPDFPages();
427 } else if (print_data_mime_type == "application/vnd.ms-xpsdocument") { 428 } else if (print_data_mime_type == "application/vnd.ms-xpsdocument") {
428 bool ret = PrintXPSDocument(printer_name, 429 bool ret = PrintXPSDocument(printer_name,
429 job_title, 430 job_title,
430 print_data_file_path, 431 print_data_file_path,
431 print_ticket); 432 print_ticket);
432 if (ret) 433 if (ret)
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); 881 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string));
881 return ret; 882 return ret;
882 } 883 }
883 884
884 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( 885 scoped_refptr<PrintSystem> PrintSystem::CreateInstance(
885 const base::DictionaryValue* print_system_settings) { 886 const base::DictionaryValue* print_system_settings) {
886 return new PrintSystemWin; 887 return new PrintSystemWin;
887 } 888 }
888 889
889 } // namespace cloud_print 890 } // namespace cloud_print
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698