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

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

Issue 6825055: Include base/win/scoped_comptr.h instead of base/scoped_comptr_win.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert bad indentation, rebase Created 9 years, 8 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 | « chrome/installer/util/shell_util_unittest.cc ('k') | chrome_frame/bho.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #if defined(_WIN32_WINNT) 9 #if defined(_WIN32_WINNT)
10 #undef _WIN32_WINNT 10 #undef _WIN32_WINNT
(...skipping 13 matching lines...) Expand all
24 #include "chrome/service/service_utility_process_host.h" 24 #include "chrome/service/service_utility_process_host.h"
25 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
26 #include "printing/backend/print_backend.h" 26 #include "printing/backend/print_backend.h"
27 #include "printing/backend/print_backend_consts.h" 27 #include "printing/backend/print_backend_consts.h"
28 #include "printing/backend/win_helper.h" 28 #include "printing/backend/win_helper.h"
29 #include "printing/emf_win.h" 29 #include "printing/emf_win.h"
30 #include "printing/page_range.h" 30 #include "printing/page_range.h"
31 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/gfx/rect.h" 32 #include "ui/gfx/rect.h"
33 33
34 using base::win::ScopedBstr;
35 using base::win::ScopedComPtr;
36
37 namespace { 34 namespace {
38 35
39 class DevMode { 36 class DevMode {
40 public: 37 public:
41 DevMode() : dm_(NULL) {} 38 DevMode() : dm_(NULL) {}
42 ~DevMode() { Free(); } 39 ~DevMode() { Free(); }
43 40
44 void Allocate(int size) { 41 void Allocate(int size) {
45 Free(); 42 Free();
46 dm_ = reinterpret_cast<DEVMODE*>(new char[size]); 43 dm_ = reinterpret_cast<DEVMODE*>(new char[size]);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 HRESULT PrintTicketToDevMode(const std::string& printer_name, 79 HRESULT PrintTicketToDevMode(const std::string& printer_name,
83 const std::string& print_ticket, 80 const std::string& print_ticket,
84 DevMode* dev_mode) { 81 DevMode* dev_mode) {
85 DCHECK(dev_mode); 82 DCHECK(dev_mode);
86 printing::ScopedXPSInitializer xps_initializer; 83 printing::ScopedXPSInitializer xps_initializer;
87 if (!xps_initializer.initialized()) { 84 if (!xps_initializer.initialized()) {
88 // TODO(sanjeevr): Handle legacy proxy case (with no prntvpt.dll) 85 // TODO(sanjeevr): Handle legacy proxy case (with no prntvpt.dll)
89 return E_FAIL; 86 return E_FAIL;
90 } 87 }
91 88
92 ScopedComPtr<IStream> pt_stream; 89 base::win::ScopedComPtr<IStream> pt_stream;
93 HRESULT hr = StreamFromPrintTicket(print_ticket, pt_stream.Receive()); 90 HRESULT hr = StreamFromPrintTicket(print_ticket, pt_stream.Receive());
94 if (FAILED(hr)) 91 if (FAILED(hr))
95 return hr; 92 return hr;
96 93
97 HPTPROVIDER provider = NULL; 94 HPTPROVIDER provider = NULL;
98 hr = printing::XPSModule::OpenProvider(UTF8ToWide(printer_name), 95 hr = printing::XPSModule::OpenProvider(UTF8ToWide(printer_name),
99 1, 96 1,
100 &provider); 97 &provider);
101 if (SUCCEEDED(hr)) { 98 if (SUCCEEDED(hr)) {
102 ULONG size = 0; 99 ULONG size = 0;
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 const std::string& job_title, 553 const std::string& job_title,
557 const FilePath& print_data_file_path, 554 const FilePath& print_data_file_path,
558 const std::string& print_ticket) { 555 const std::string& print_ticket) {
559 if (!printing::XPSPrintModule::Init()) 556 if (!printing::XPSPrintModule::Init())
560 return false; 557 return false;
561 job_progress_event_.Set(CreateEvent(NULL, TRUE, FALSE, NULL)); 558 job_progress_event_.Set(CreateEvent(NULL, TRUE, FALSE, NULL));
562 if (!job_progress_event_.Get()) 559 if (!job_progress_event_.Get())
563 return false; 560 return false;
564 should_couninit_ = SUCCEEDED(CoInitializeEx(NULL, 561 should_couninit_ = SUCCEEDED(CoInitializeEx(NULL,
565 COINIT_MULTITHREADED)); 562 COINIT_MULTITHREADED));
566 ScopedComPtr<IXpsPrintJobStream> doc_stream; 563 base::win::ScopedComPtr<IXpsPrintJobStream> doc_stream;
567 ScopedComPtr<IXpsPrintJobStream> print_ticket_stream; 564 base::win::ScopedComPtr<IXpsPrintJobStream> print_ticket_stream;
568 bool ret = false; 565 bool ret = false;
569 // Use nested SUCCEEDED checks because we want a common return point. 566 // Use nested SUCCEEDED checks because we want a common return point.
570 if (SUCCEEDED(printing::XPSPrintModule::StartXpsPrintJob( 567 if (SUCCEEDED(printing::XPSPrintModule::StartXpsPrintJob(
571 UTF8ToWide(printer_name).c_str(), 568 UTF8ToWide(printer_name).c_str(),
572 UTF8ToWide(job_title).c_str(), 569 UTF8ToWide(job_title).c_str(),
573 NULL, 570 NULL,
574 job_progress_event_.Get(), 571 job_progress_event_.Get(),
575 NULL, 572 NULL,
576 NULL, 573 NULL,
577 NULL, 574 NULL,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // http://code.google.com/p/chromium/issues/detail?id=57350. 617 // http://code.google.com/p/chromium/issues/detail?id=57350.
621 static const int kPageCountPerBatch = 1; 618 static const int kPageCountPerBatch = 1;
622 int last_page_printed_; 619 int last_page_printed_;
623 PlatformJobId job_id_; 620 PlatformJobId job_id_;
624 PrintSystem::JobSpooler::Delegate* delegate_; 621 PrintSystem::JobSpooler::Delegate* delegate_;
625 int saved_dc_; 622 int saved_dc_;
626 base::win::ScopedHDC printer_dc_; 623 base::win::ScopedHDC printer_dc_;
627 FilePath print_data_file_path_; 624 FilePath print_data_file_path_;
628 base::win::ScopedHandle job_progress_event_; 625 base::win::ScopedHandle job_progress_event_;
629 base::win::ObjectWatcher job_progress_watcher_; 626 base::win::ObjectWatcher job_progress_watcher_;
630 ScopedComPtr<IXpsPrintJob> xps_print_job_; 627 base::win::ScopedComPtr<IXpsPrintJob> xps_print_job_;
631 bool should_couninit_; 628 bool should_couninit_;
632 DISALLOW_COPY_AND_ASSIGN(JobSpoolerWin::Core); 629 DISALLOW_COPY_AND_ASSIGN(JobSpoolerWin::Core);
633 }; 630 };
634 scoped_refptr<Core> core_; 631 scoped_refptr<Core> core_;
635 DISALLOW_COPY_AND_ASSIGN(JobSpoolerWin); 632 DISALLOW_COPY_AND_ASSIGN(JobSpoolerWin);
636 }; 633 };
637 634
638 // A helper class to handle the response from the utility process to the 635 // A helper class to handle the response from the utility process to the
639 // request to fetch printer capabilities and defaults. 636 // request to fetch printer capabilities and defaults.
640 class PrinterCapsHandler : public ServiceUtilityProcessHost::Client { 637 class PrinterCapsHandler : public ServiceUtilityProcessHost::Client {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 if (!xps_initializer.initialized()) { 748 if (!xps_initializer.initialized()) {
752 // TODO(sanjeevr): Handle legacy proxy case (with no prntvpt.dll) 749 // TODO(sanjeevr): Handle legacy proxy case (with no prntvpt.dll)
753 return false; 750 return false;
754 } 751 }
755 bool ret = false; 752 bool ret = false;
756 HPTPROVIDER provider = NULL; 753 HPTPROVIDER provider = NULL;
757 printing::XPSModule::OpenProvider(UTF8ToWide(printer_name.c_str()), 754 printing::XPSModule::OpenProvider(UTF8ToWide(printer_name.c_str()),
758 1, 755 1,
759 &provider); 756 &provider);
760 if (provider) { 757 if (provider) {
761 ScopedComPtr<IStream> print_ticket_stream; 758 base::win::ScopedComPtr<IStream> print_ticket_stream;
762 CreateStreamOnHGlobal(NULL, TRUE, print_ticket_stream.Receive()); 759 CreateStreamOnHGlobal(NULL, TRUE, print_ticket_stream.Receive());
763 ULONG bytes_written = 0; 760 ULONG bytes_written = 0;
764 print_ticket_stream->Write(print_ticket_data.c_str(), 761 print_ticket_stream->Write(print_ticket_data.c_str(),
765 print_ticket_data.length(), 762 print_ticket_data.length(),
766 &bytes_written); 763 &bytes_written);
767 DCHECK(bytes_written == print_ticket_data.length()); 764 DCHECK(bytes_written == print_ticket_data.length());
768 LARGE_INTEGER pos = {0}; 765 LARGE_INTEGER pos = {0};
769 ULARGE_INTEGER new_pos = {0}; 766 ULARGE_INTEGER new_pos = {0};
770 print_ticket_stream->Seek(pos, STREAM_SEEK_SET, &new_pos); 767 print_ticket_stream->Seek(pos, STREAM_SEEK_SET, &new_pos);
771 ScopedBstr error; 768 base::win::ScopedBstr error;
772 ScopedComPtr<IStream> result_ticket_stream; 769 base::win::ScopedComPtr<IStream> result_ticket_stream;
773 CreateStreamOnHGlobal(NULL, TRUE, result_ticket_stream.Receive()); 770 CreateStreamOnHGlobal(NULL, TRUE, result_ticket_stream.Receive());
774 ret = SUCCEEDED(printing::XPSModule::MergeAndValidatePrintTicket( 771 ret = SUCCEEDED(printing::XPSModule::MergeAndValidatePrintTicket(
775 provider, 772 provider,
776 print_ticket_stream.get(), 773 print_ticket_stream.get(),
777 NULL, 774 NULL,
778 kPTJobScope, 775 kPTJobScope,
779 result_ticket_stream.get(), 776 result_ticket_stream.get(),
780 error.Receive())); 777 error.Receive()));
781 printing::XPSModule::CloseProvider(provider); 778 printing::XPSModule::CloseProvider(provider);
782 } 779 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); 860 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string));
864 return ret; 861 return ret;
865 } 862 }
866 863
867 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( 864 scoped_refptr<PrintSystem> PrintSystem::CreateInstance(
868 const DictionaryValue* print_system_settings) { 865 const DictionaryValue* print_system_settings) {
869 return new PrintSystemWin; 866 return new PrintSystemWin;
870 } 867 }
871 868
872 } // namespace cloud_print 869 } // namespace cloud_print
OLDNEW
« no previous file with comments | « chrome/installer/util/shell_util_unittest.cc ('k') | chrome_frame/bho.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698