| 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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 namespace cloud_print { | 30 namespace cloud_print { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 class PrintSystemWatcherWin : public base::win::ObjectWatcher::Delegate { | 34 class PrintSystemWatcherWin : public base::win::ObjectWatcher::Delegate { |
| 35 public: | 35 public: |
| 36 PrintSystemWatcherWin() | 36 PrintSystemWatcherWin() |
| 37 : delegate_(NULL), | 37 : delegate_(NULL), |
| 38 did_signal_(false) { | 38 did_signal_(false) { |
| 39 } | 39 } |
| 40 ~PrintSystemWatcherWin() { | 40 ~PrintSystemWatcherWin() override { Stop(); } |
| 41 Stop(); | |
| 42 } | |
| 43 | 41 |
| 44 class Delegate { | 42 class Delegate { |
| 45 public: | 43 public: |
| 46 virtual ~Delegate() {} | 44 virtual ~Delegate() {} |
| 47 virtual void OnPrinterAdded() = 0; | 45 virtual void OnPrinterAdded() = 0; |
| 48 virtual void OnPrinterDeleted() = 0; | 46 virtual void OnPrinterDeleted() = 0; |
| 49 virtual void OnPrinterChanged() = 0; | 47 virtual void OnPrinterChanged() = 0; |
| 50 virtual void OnJobChanged() = 0; | 48 virtual void OnJobChanged() = 0; |
| 51 }; | 49 }; |
| 52 | 50 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 80 } | 78 } |
| 81 | 79 |
| 82 bool Stop() { | 80 bool Stop() { |
| 83 watcher_.StopWatching(); | 81 watcher_.StopWatching(); |
| 84 printer_.Close(); | 82 printer_.Close(); |
| 85 printer_change_.Close(); | 83 printer_change_.Close(); |
| 86 return true; | 84 return true; |
| 87 } | 85 } |
| 88 | 86 |
| 89 // base::ObjectWatcher::Delegate method | 87 // base::ObjectWatcher::Delegate method |
| 90 virtual void OnObjectSignaled(HANDLE object) { | 88 void OnObjectSignaled(HANDLE object) override { |
| 91 crash_keys::ScopedPrinterInfo crash_key(printer_info_); | 89 crash_keys::ScopedPrinterInfo crash_key(printer_info_); |
| 92 DWORD change = 0; | 90 DWORD change = 0; |
| 93 FindNextPrinterChangeNotification(object, &change, NULL, NULL); | 91 FindNextPrinterChangeNotification(object, &change, NULL, NULL); |
| 94 | 92 |
| 95 if (change != ((PRINTER_CHANGE_PRINTER|PRINTER_CHANGE_JOB) & | 93 if (change != ((PRINTER_CHANGE_PRINTER|PRINTER_CHANGE_JOB) & |
| 96 (~PRINTER_CHANGE_FAILED_CONNECTION_PRINTER))) { | 94 (~PRINTER_CHANGE_FAILED_CONNECTION_PRINTER))) { |
| 97 // For printer connections, we get spurious change notifications with | 95 // For printer connections, we get spurious change notifications with |
| 98 // all flags set except PRINTER_CHANGE_FAILED_CONNECTION_PRINTER. | 96 // all flags set except PRINTER_CHANGE_FAILED_CONNECTION_PRINTER. |
| 99 // Ignore these. | 97 // Ignore these. |
| 100 if (change & PRINTER_CHANGE_ADD_PRINTER) { | 98 if (change & PRINTER_CHANGE_ADD_PRINTER) { |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 } | 816 } |
| 819 | 817 |
| 820 } // namespace | 818 } // namespace |
| 821 | 819 |
| 822 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 820 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
| 823 const base::DictionaryValue* print_system_settings) { | 821 const base::DictionaryValue* print_system_settings) { |
| 824 return new PrintSystemWin; | 822 return new PrintSystemWin; |
| 825 } | 823 } |
| 826 | 824 |
| 827 } // namespace cloud_print | 825 } // namespace cloud_print |
| OLD | NEW |