OLD | NEW |
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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 354 |
355 // ServiceUtilityProcessHost::Client implementation. | 355 // ServiceUtilityProcessHost::Client implementation. |
356 void OnRenderPDFPagesToMetafileDone(bool success) override { | 356 void OnRenderPDFPagesToMetafileDone(bool success) override { |
357 PrintJobDone(success); | 357 PrintJobDone(success); |
358 } | 358 } |
359 | 359 |
360 void OnChildDied() override { PrintJobDone(false); } | 360 void OnChildDied() override { PrintJobDone(false); } |
361 | 361 |
362 // base::win::ObjectWatcher::Delegate implementation. | 362 // base::win::ObjectWatcher::Delegate implementation. |
363 void OnObjectSignaled(HANDLE object) override { | 363 void OnObjectSignaled(HANDLE object) override { |
364 DCHECK(xps_print_job_.get()); | 364 DCHECK(xps_print_job_.Get()); |
365 DCHECK(object == job_progress_event_.Get()); | 365 DCHECK(object == job_progress_event_.Get()); |
366 ResetEvent(job_progress_event_.Get()); | 366 ResetEvent(job_progress_event_.Get()); |
367 if (!delegate_) | 367 if (!delegate_) |
368 return; | 368 return; |
369 XPS_JOB_STATUS job_status = {0}; | 369 XPS_JOB_STATUS job_status = {0}; |
370 xps_print_job_->GetJobStatus(&job_status); | 370 xps_print_job_->GetJobStatus(&job_status); |
371 if ((job_status.completion == XPS_JOB_CANCELLED) || | 371 if ((job_status.completion == XPS_JOB_CANCELLED) || |
372 (job_status.completion == XPS_JOB_FAILED)) { | 372 (job_status.completion == XPS_JOB_FAILED)) { |
373 delegate_->OnJobSpoolFailed(); | 373 delegate_->OnJobSpoolFailed(); |
374 } else if (job_status.jobId || | 374 } else if (job_status.jobId || |
(...skipping 13 matching lines...) Expand all Loading... |
388 ~Core() override {} | 388 ~Core() override {} |
389 | 389 |
390 // Helper class to allow PrintXPSDocument() to have multiple exits. | 390 // Helper class to allow PrintXPSDocument() to have multiple exits. |
391 class PrintJobCanceler { | 391 class PrintJobCanceler { |
392 public: | 392 public: |
393 explicit PrintJobCanceler( | 393 explicit PrintJobCanceler( |
394 base::win::ScopedComPtr<IXpsPrintJob>* job_ptr) | 394 base::win::ScopedComPtr<IXpsPrintJob>* job_ptr) |
395 : job_ptr_(job_ptr) { | 395 : job_ptr_(job_ptr) { |
396 } | 396 } |
397 ~PrintJobCanceler() { | 397 ~PrintJobCanceler() { |
398 if (job_ptr_ && job_ptr_->get()) { | 398 if (job_ptr_ && job_ptr_->Get()) { |
399 (*job_ptr_)->Cancel(); | 399 (*job_ptr_)->Cancel(); |
400 job_ptr_->Reset(); | 400 job_ptr_->Reset(); |
401 } | 401 } |
402 } | 402 } |
403 | 403 |
404 void reset() { job_ptr_ = NULL; } | 404 void reset() { job_ptr_ = NULL; } |
405 | 405 |
406 private: | 406 private: |
407 base::win::ScopedComPtr<IXpsPrintJob>* job_ptr_; | 407 base::win::ScopedComPtr<IXpsPrintJob>* job_ptr_; |
408 | 408 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 &bytes_written); | 741 &bytes_written); |
742 DCHECK(bytes_written == print_ticket_data.length()); | 742 DCHECK(bytes_written == print_ticket_data.length()); |
743 LARGE_INTEGER pos = {}; | 743 LARGE_INTEGER pos = {}; |
744 ULARGE_INTEGER new_pos = {}; | 744 ULARGE_INTEGER new_pos = {}; |
745 print_ticket_stream->Seek(pos, STREAM_SEEK_SET, &new_pos); | 745 print_ticket_stream->Seek(pos, STREAM_SEEK_SET, &new_pos); |
746 base::win::ScopedBstr error; | 746 base::win::ScopedBstr error; |
747 base::win::ScopedComPtr<IStream> result_ticket_stream; | 747 base::win::ScopedComPtr<IStream> result_ticket_stream; |
748 CreateStreamOnHGlobal(NULL, TRUE, result_ticket_stream.Receive()); | 748 CreateStreamOnHGlobal(NULL, TRUE, result_ticket_stream.Receive()); |
749 ret = SUCCEEDED(printing::XPSModule::MergeAndValidatePrintTicket( | 749 ret = SUCCEEDED(printing::XPSModule::MergeAndValidatePrintTicket( |
750 provider, | 750 provider, |
751 print_ticket_stream.get(), | 751 print_ticket_stream.Get(), |
752 NULL, | 752 NULL, |
753 kPTJobScope, | 753 kPTJobScope, |
754 result_ticket_stream.get(), | 754 result_ticket_stream.Get(), |
755 error.Receive())); | 755 error.Receive())); |
756 printing::XPSModule::CloseProvider(provider); | 756 printing::XPSModule::CloseProvider(provider); |
757 } | 757 } |
758 return ret; | 758 return ret; |
759 } | 759 } |
760 | 760 |
761 bool PrintSystemWin::GetJobDetails(const std::string& printer_name, | 761 bool PrintSystemWin::GetJobDetails(const std::string& printer_name, |
762 PlatformJobId job_id, | 762 PlatformJobId job_id, |
763 PrintJobDetails* job_details) { | 763 PrintJobDetails* job_details) { |
764 crash_keys::ScopedPrinterInfo crash_key( | 764 crash_keys::ScopedPrinterInfo crash_key( |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 } | 838 } |
839 | 839 |
840 } // namespace | 840 } // namespace |
841 | 841 |
842 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 842 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
843 const base::DictionaryValue* print_system_settings) { | 843 const base::DictionaryValue* print_system_settings) { |
844 return new PrintSystemWin; | 844 return new PrintSystemWin; |
845 } | 845 } |
846 | 846 |
847 } // namespace cloud_print | 847 } // namespace cloud_print |
OLD | NEW |