| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/object_watcher.h" | |
| 12 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 13 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.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/service/cloud_print/cloud_print_consts.h" | 17 #include "chrome/service/cloud_print/cloud_print_consts.h" |
| 18 #include "chrome/service/service_process.h" | 18 #include "chrome/service/service_process.h" |
| 19 #include "chrome/service/service_utility_process_host.h" | 19 #include "chrome/service/service_utility_process_host.h" |
| 20 #include "gfx/rect.h" | 20 #include "gfx/rect.h" |
| 21 #include "printing/backend/print_backend.h" | 21 #include "printing/backend/print_backend.h" |
| 22 #include "printing/backend/print_backend_consts.h" | 22 #include "printing/backend/print_backend_consts.h" |
| 23 #include "printing/backend/win_helper.h" | 23 #include "printing/backend/win_helper.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 103 } |
| 104 printing::XPSModule::CloseProvider(provider); | 104 printing::XPSModule::CloseProvider(provider); |
| 105 } | 105 } |
| 106 return hr; | 106 return hr; |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace | 109 } // namespace |
| 110 | 110 |
| 111 namespace cloud_print { | 111 namespace cloud_print { |
| 112 | 112 |
| 113 class PrintSystemWatcherWin | 113 class PrintSystemWatcherWin : public base::win::ObjectWatcher::Delegate { |
| 114 : public base::ObjectWatcher::Delegate { | |
| 115 public: | 114 public: |
| 116 PrintSystemWatcherWin() | 115 PrintSystemWatcherWin() |
| 117 : printer_(NULL), | 116 : printer_(NULL), |
| 118 printer_change_(NULL), | 117 printer_change_(NULL), |
| 119 delegate_(NULL), | 118 delegate_(NULL), |
| 120 did_signal_(false) { | 119 did_signal_(false) { |
| 121 } | 120 } |
| 122 ~PrintSystemWatcherWin() { | 121 ~PrintSystemWatcherWin() { |
| 123 Stop(); | 122 Stop(); |
| 124 } | 123 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 printer_info->options[kDriverNameTagName] = | 216 printer_info->options[kDriverNameTagName] = |
| 218 WideToUTF8(printer_info_win->pDriverName); | 217 WideToUTF8(printer_info_win->pDriverName); |
| 219 printer_info->printer_status = printer_info_win->Status; | 218 printer_info->printer_status = printer_info_win->Status; |
| 220 ret = true; | 219 ret = true; |
| 221 } | 220 } |
| 222 } | 221 } |
| 223 return ret; | 222 return ret; |
| 224 } | 223 } |
| 225 | 224 |
| 226 private: | 225 private: |
| 227 base::ObjectWatcher watcher_; | 226 base::win::ObjectWatcher watcher_; |
| 228 HANDLE printer_; // The printer being watched | 227 HANDLE printer_; // The printer being watched |
| 229 HANDLE printer_change_; // Returned by FindFirstPrinterChangeNotifier | 228 HANDLE printer_change_; // Returned by FindFirstPrinterChangeNotifier |
| 230 Delegate* delegate_; // Delegate to notify | 229 Delegate* delegate_; // Delegate to notify |
| 231 bool did_signal_; // DoneWaiting was called | 230 bool did_signal_; // DoneWaiting was called |
| 232 }; | 231 }; |
| 233 | 232 |
| 234 // This typedef is to workaround the issue with certain versions of | 233 // This typedef is to workaround the issue with certain versions of |
| 235 // Visual Studio where it gets confused between multiple Delegate. | 234 // Visual Studio where it gets confused between multiple Delegate. |
| 236 // In this case, some compilers get confused and inherit | 235 // In this case, some compilers get confused and inherit |
| 237 // PrintSystemWin watchers from wrong Delegate, giving C2664 and C2259 errors. | 236 // PrintSystemWin watchers from wrong Delegate, giving C2664 and C2259 errors. |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); | 726 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); |
| 728 return ret; | 727 return ret; |
| 729 } | 728 } |
| 730 | 729 |
| 731 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 730 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
| 732 const DictionaryValue* print_system_settings) { | 731 const DictionaryValue* print_system_settings) { |
| 733 return new PrintSystemWin; | 732 return new PrintSystemWin; |
| 734 } | 733 } |
| 735 | 734 |
| 736 } // namespace cloud_print | 735 } // namespace cloud_print |
| OLD | NEW |