| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/profiler/scoped_profile.h" | 11 #include "base/profiler/scoped_tracker.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/win/object_watcher.h" | 13 #include "base/win/object_watcher.h" |
| 14 #include "base/win/scoped_bstr.h" | 14 #include "base/win/scoped_bstr.h" |
| 15 #include "base/win/scoped_comptr.h" | 15 #include "base/win/scoped_comptr.h" |
| 16 #include "base/win/scoped_hdc.h" | 16 #include "base/win/scoped_hdc.h" |
| 17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/cloud_print/cloud_print_cdd_conversion.h" | 18 #include "chrome/common/cloud_print/cloud_print_cdd_conversion.h" |
| 19 #include "chrome/common/cloud_print/cloud_print_constants.h" | 19 #include "chrome/common/cloud_print/cloud_print_constants.h" |
| 20 #include "chrome/common/crash_keys.h" | 20 #include "chrome/common/crash_keys.h" |
| 21 #include "chrome/service/cloud_print/cdd_conversion_win.h" | 21 #include "chrome/service/cloud_print/cdd_conversion_win.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 bool Stop() { | 83 bool Stop() { |
| 84 watcher_.StopWatching(); | 84 watcher_.StopWatching(); |
| 85 printer_.Close(); | 85 printer_.Close(); |
| 86 printer_change_.Close(); | 86 printer_change_.Close(); |
| 87 return true; | 87 return true; |
| 88 } | 88 } |
| 89 | 89 |
| 90 // base::ObjectWatcher::Delegate method | 90 // base::ObjectWatcher::Delegate method |
| 91 virtual void OnObjectSignaled(HANDLE object) { | 91 virtual void OnObjectSignaled(HANDLE object) { |
| 92 // TODO(vadimt): Remove ScopedProfile below once crbug.com/418183 is fixed. | 92 // TODO(vadimt): Remove ScopedTracker below once crbug.com/418183 is fixed. |
| 93 tracked_objects::ScopedProfile tracking_profile( | 93 tracked_objects::ScopedTracker tracking_profile( |
| 94 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 94 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 95 "PrintSystemWatcherWin_OnObjectSignaled")); | 95 "PrintSystemWatcherWin_OnObjectSignaled")); |
| 96 | 96 |
| 97 crash_keys::ScopedPrinterInfo crash_key(printer_info_); | 97 crash_keys::ScopedPrinterInfo crash_key(printer_info_); |
| 98 DWORD change = 0; | 98 DWORD change = 0; |
| 99 FindNextPrinterChangeNotification(object, &change, NULL, NULL); | 99 FindNextPrinterChangeNotification(object, &change, NULL, NULL); |
| 100 | 100 |
| 101 if (change != ((PRINTER_CHANGE_PRINTER|PRINTER_CHANGE_JOB) & | 101 if (change != ((PRINTER_CHANGE_PRINTER|PRINTER_CHANGE_JOB) & |
| 102 (~PRINTER_CHANGE_FAILED_CONNECTION_PRINTER))) { | 102 (~PRINTER_CHANGE_FAILED_CONNECTION_PRINTER))) { |
| 103 // For printer connections, we get spurious change notifications with | 103 // For printer connections, we get spurious change notifications with |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 348 |
| 349 // ServiceUtilityProcessHost::Client implementation. | 349 // ServiceUtilityProcessHost::Client implementation. |
| 350 virtual void OnRenderPDFPagesToMetafileDone(bool success) override { | 350 virtual void OnRenderPDFPagesToMetafileDone(bool success) override { |
| 351 PrintJobDone(success); | 351 PrintJobDone(success); |
| 352 } | 352 } |
| 353 | 353 |
| 354 virtual void OnChildDied() override { PrintJobDone(false); } | 354 virtual void OnChildDied() override { PrintJobDone(false); } |
| 355 | 355 |
| 356 // base::win::ObjectWatcher::Delegate implementation. | 356 // base::win::ObjectWatcher::Delegate implementation. |
| 357 virtual void OnObjectSignaled(HANDLE object) override { | 357 virtual void OnObjectSignaled(HANDLE object) override { |
| 358 // TODO(vadimt): Remove ScopedProfile below once crbug.com/418183 is fixed. | 358 // TODO(vadimt): Remove ScopedTracker below once crbug.com/418183 is |
| 359 tracked_objects::ScopedProfile tracking_profile( | 359 // fixed. |
| 360 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 360 tracked_objects::ScopedTracker tracking_profile( |
| 361 "Core_OnObjectSignaled")); | 361 FROM_HERE_WITH_EXPLICIT_FUNCTION("Core_OnObjectSignaled")); |
| 362 | 362 |
| 363 DCHECK(xps_print_job_); | 363 DCHECK(xps_print_job_); |
| 364 DCHECK(object == job_progress_event_.Get()); | 364 DCHECK(object == job_progress_event_.Get()); |
| 365 ResetEvent(job_progress_event_.Get()); | 365 ResetEvent(job_progress_event_.Get()); |
| 366 if (!delegate_) | 366 if (!delegate_) |
| 367 return; | 367 return; |
| 368 XPS_JOB_STATUS job_status = {0}; | 368 XPS_JOB_STATUS job_status = {0}; |
| 369 xps_print_job_->GetJobStatus(&job_status); | 369 xps_print_job_->GetJobStatus(&job_status); |
| 370 if ((job_status.completion == XPS_JOB_CANCELLED) || | 370 if ((job_status.completion == XPS_JOB_CANCELLED) || |
| 371 (job_status.completion == XPS_JOB_FAILED)) { | 371 (job_status.completion == XPS_JOB_FAILED)) { |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 } | 830 } |
| 831 | 831 |
| 832 } // namespace | 832 } // namespace |
| 833 | 833 |
| 834 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 834 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
| 835 const base::DictionaryValue* print_system_settings) { | 835 const base::DictionaryValue* print_system_settings) { |
| 836 return new PrintSystemWin; | 836 return new PrintSystemWin; |
| 837 } | 837 } |
| 838 | 838 |
| 839 } // namespace cloud_print | 839 } // namespace cloud_print |
| OLD | NEW |