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

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

Issue 628083002: Replacing the OVERRIDE with override and FINAL with final in chrome/service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
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 <cups/cups.h> 7 #include <cups/cups.h>
8 #include <dlfcn.h> 8 #include <dlfcn.h>
9 #include <errno.h> 9 #include <errno.h>
10 #include <pthread.h> 10 #include <pthread.h>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // the number of requests. 69 // the number of requests.
70 typedef std::map<std::string, printing::PrinterCapsAndDefaults> CapsMap; 70 typedef std::map<std::string, printing::PrinterCapsAndDefaults> CapsMap;
71 CapsMap caps_cache; 71 CapsMap caps_cache;
72 }; 72 };
73 73
74 class PrintSystemCUPS : public PrintSystem { 74 class PrintSystemCUPS : public PrintSystem {
75 public: 75 public:
76 explicit PrintSystemCUPS(const base::DictionaryValue* print_system_settings); 76 explicit PrintSystemCUPS(const base::DictionaryValue* print_system_settings);
77 77
78 // PrintSystem implementation. 78 // PrintSystem implementation.
79 virtual PrintSystemResult Init() OVERRIDE; 79 virtual PrintSystemResult Init() override;
80 virtual PrintSystem::PrintSystemResult EnumeratePrinters( 80 virtual PrintSystem::PrintSystemResult EnumeratePrinters(
81 printing::PrinterList* printer_list) OVERRIDE; 81 printing::PrinterList* printer_list) override;
82 virtual void GetPrinterCapsAndDefaults( 82 virtual void GetPrinterCapsAndDefaults(
83 const std::string& printer_name, 83 const std::string& printer_name,
84 const PrinterCapsAndDefaultsCallback& callback) OVERRIDE; 84 const PrinterCapsAndDefaultsCallback& callback) override;
85 virtual bool IsValidPrinter(const std::string& printer_name) OVERRIDE; 85 virtual bool IsValidPrinter(const std::string& printer_name) override;
86 virtual bool ValidatePrintTicket( 86 virtual bool ValidatePrintTicket(
87 const std::string& printer_name, 87 const std::string& printer_name,
88 const std::string& print_ticket_data, 88 const std::string& print_ticket_data,
89 const std::string& print_ticket_mime_type) OVERRIDE; 89 const std::string& print_ticket_mime_type) override;
90 virtual bool GetJobDetails(const std::string& printer_name, 90 virtual bool GetJobDetails(const std::string& printer_name,
91 PlatformJobId job_id, 91 PlatformJobId job_id,
92 PrintJobDetails *job_details) OVERRIDE; 92 PrintJobDetails *job_details) override;
93 virtual PrintSystem::PrintServerWatcher* CreatePrintServerWatcher() OVERRIDE; 93 virtual PrintSystem::PrintServerWatcher* CreatePrintServerWatcher() override;
94 virtual PrintSystem::PrinterWatcher* CreatePrinterWatcher( 94 virtual PrintSystem::PrinterWatcher* CreatePrinterWatcher(
95 const std::string& printer_name) OVERRIDE; 95 const std::string& printer_name) override;
96 virtual PrintSystem::JobSpooler* CreateJobSpooler() OVERRIDE; 96 virtual PrintSystem::JobSpooler* CreateJobSpooler() override;
97 virtual bool UseCddAndCjt() OVERRIDE; 97 virtual bool UseCddAndCjt() override;
98 virtual std::string GetSupportedMimeTypes() OVERRIDE; 98 virtual std::string GetSupportedMimeTypes() override;
99 99
100 // Helper functions. 100 // Helper functions.
101 PlatformJobId SpoolPrintJob(const std::string& print_ticket, 101 PlatformJobId SpoolPrintJob(const std::string& print_ticket,
102 const base::FilePath& print_data_file_path, 102 const base::FilePath& print_data_file_path,
103 const std::string& print_data_mime_type, 103 const std::string& print_data_mime_type,
104 const std::string& printer_name, 104 const std::string& printer_name,
105 const std::string& job_title, 105 const std::string& job_title,
106 const std::vector<std::string>& tags, 106 const std::vector<std::string>& tags,
107 bool* dry_run); 107 bool* dry_run);
108 bool GetPrinterInfo(const std::string& printer_name, 108 bool GetPrinterInfo(const std::string& printer_name,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 class PrintServerWatcherCUPS 174 class PrintServerWatcherCUPS
175 : public PrintSystem::PrintServerWatcher { 175 : public PrintSystem::PrintServerWatcher {
176 public: 176 public:
177 explicit PrintServerWatcherCUPS(PrintSystemCUPS* print_system) 177 explicit PrintServerWatcherCUPS(PrintSystemCUPS* print_system)
178 : print_system_(print_system), 178 : print_system_(print_system),
179 delegate_(NULL) { 179 delegate_(NULL) {
180 } 180 }
181 181
182 // PrintSystem::PrintServerWatcher implementation. 182 // PrintSystem::PrintServerWatcher implementation.
183 virtual bool StartWatching( 183 virtual bool StartWatching(
184 PrintSystem::PrintServerWatcher::Delegate* delegate) OVERRIDE { 184 PrintSystem::PrintServerWatcher::Delegate* delegate) override {
185 delegate_ = delegate; 185 delegate_ = delegate;
186 printers_hash_ = GetPrintersHash(); 186 printers_hash_ = GetPrintersHash();
187 base::MessageLoop::current()->PostDelayedTask( 187 base::MessageLoop::current()->PostDelayedTask(
188 FROM_HERE, 188 FROM_HERE,
189 base::Bind(&PrintServerWatcherCUPS::CheckForUpdates, this), 189 base::Bind(&PrintServerWatcherCUPS::CheckForUpdates, this),
190 print_system_->GetUpdateTimeout()); 190 print_system_->GetUpdateTimeout());
191 return true; 191 return true;
192 } 192 }
193 193
194 virtual bool StopWatching() OVERRIDE { 194 virtual bool StopWatching() override {
195 delegate_ = NULL; 195 delegate_ = NULL;
196 return true; 196 return true;
197 } 197 }
198 198
199 void CheckForUpdates() { 199 void CheckForUpdates() {
200 if (delegate_ == NULL) 200 if (delegate_ == NULL)
201 return; // Orphan call. We have been stopped already. 201 return; // Orphan call. We have been stopped already.
202 VLOG(1) << "CP_CUPS: Checking for new printers"; 202 VLOG(1) << "CP_CUPS: Checking for new printers";
203 std::string new_hash = GetPrintersHash(); 203 std::string new_hash = GetPrintersHash();
204 if (printers_hash_ != new_hash) { 204 if (printers_hash_ != new_hash) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 public: 247 public:
248 PrinterWatcherCUPS(PrintSystemCUPS* print_system, 248 PrinterWatcherCUPS(PrintSystemCUPS* print_system,
249 const std::string& printer_name) 249 const std::string& printer_name)
250 : printer_name_(printer_name), 250 : printer_name_(printer_name),
251 delegate_(NULL), 251 delegate_(NULL),
252 print_system_(print_system) { 252 print_system_(print_system) {
253 } 253 }
254 254
255 // PrintSystem::PrinterWatcher implementation. 255 // PrintSystem::PrinterWatcher implementation.
256 virtual bool StartWatching( 256 virtual bool StartWatching(
257 PrintSystem::PrinterWatcher::Delegate* delegate) OVERRIDE{ 257 PrintSystem::PrinterWatcher::Delegate* delegate) override{
258 scoped_refptr<printing::PrintBackend> print_backend( 258 scoped_refptr<printing::PrintBackend> print_backend(
259 printing::PrintBackend::CreateInstance(NULL)); 259 printing::PrintBackend::CreateInstance(NULL));
260 crash_keys::ScopedPrinterInfo crash_key( 260 crash_keys::ScopedPrinterInfo crash_key(
261 print_backend->GetPrinterDriverInfo(printer_name_)); 261 print_backend->GetPrinterDriverInfo(printer_name_));
262 if (delegate_ != NULL) 262 if (delegate_ != NULL)
263 StopWatching(); 263 StopWatching();
264 delegate_ = delegate; 264 delegate_ = delegate;
265 settings_hash_ = GetSettingsHash(); 265 settings_hash_ = GetSettingsHash();
266 // Schedule next job status update. 266 // Schedule next job status update.
267 base::MessageLoop::current()->PostDelayedTask( 267 base::MessageLoop::current()->PostDelayedTask(
268 FROM_HERE, 268 FROM_HERE,
269 base::Bind(&PrinterWatcherCUPS::JobStatusUpdate, this), 269 base::Bind(&PrinterWatcherCUPS::JobStatusUpdate, this),
270 base::TimeDelta::FromSeconds(kJobUpdateTimeoutSeconds)); 270 base::TimeDelta::FromSeconds(kJobUpdateTimeoutSeconds));
271 // Schedule next printer check. 271 // Schedule next printer check.
272 // TODO(gene): Randomize time for the next printer update. 272 // TODO(gene): Randomize time for the next printer update.
273 base::MessageLoop::current()->PostDelayedTask( 273 base::MessageLoop::current()->PostDelayedTask(
274 FROM_HERE, 274 FROM_HERE,
275 base::Bind(&PrinterWatcherCUPS::PrinterUpdate, this), 275 base::Bind(&PrinterWatcherCUPS::PrinterUpdate, this),
276 print_system_->GetUpdateTimeout()); 276 print_system_->GetUpdateTimeout());
277 return true; 277 return true;
278 } 278 }
279 279
280 virtual bool StopWatching() OVERRIDE{ 280 virtual bool StopWatching() override{
281 delegate_ = NULL; 281 delegate_ = NULL;
282 return true; 282 return true;
283 } 283 }
284 284
285 virtual bool GetCurrentPrinterInfo( 285 virtual bool GetCurrentPrinterInfo(
286 printing::PrinterBasicInfo* printer_info) OVERRIDE { 286 printing::PrinterBasicInfo* printer_info) override {
287 DCHECK(printer_info); 287 DCHECK(printer_info);
288 return print_system_->GetPrinterInfo(printer_name_, printer_info); 288 return print_system_->GetPrinterInfo(printer_name_, printer_info);
289 } 289 }
290 290
291 void JobStatusUpdate() { 291 void JobStatusUpdate() {
292 if (delegate_ == NULL) 292 if (delegate_ == NULL)
293 return; // Orphan call. We have been stopped already. 293 return; // Orphan call. We have been stopped already.
294 // For CUPS proxy, we are going to fire OnJobChanged notification 294 // For CUPS proxy, we are going to fire OnJobChanged notification
295 // periodically. Higher level will check if there are any outstanding 295 // periodically. Higher level will check if there are any outstanding
296 // jobs for this printer and check their status. If printer has no 296 // jobs for this printer and check their status. If printer has no
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 373 }
374 374
375 // PrintSystem::JobSpooler implementation. 375 // PrintSystem::JobSpooler implementation.
376 virtual bool Spool(const std::string& print_ticket, 376 virtual bool Spool(const std::string& print_ticket,
377 const std::string& print_ticket_mime_type, 377 const std::string& print_ticket_mime_type,
378 const base::FilePath& print_data_file_path, 378 const base::FilePath& print_data_file_path,
379 const std::string& print_data_mime_type, 379 const std::string& print_data_mime_type,
380 const std::string& printer_name, 380 const std::string& printer_name,
381 const std::string& job_title, 381 const std::string& job_title,
382 const std::vector<std::string>& tags, 382 const std::vector<std::string>& tags,
383 JobSpooler::Delegate* delegate) OVERRIDE{ 383 JobSpooler::Delegate* delegate) override{
384 DCHECK(delegate); 384 DCHECK(delegate);
385 bool dry_run = false; 385 bool dry_run = false;
386 int job_id = print_system_->SpoolPrintJob( 386 int job_id = print_system_->SpoolPrintJob(
387 print_ticket, print_data_file_path, print_data_mime_type, 387 print_ticket, print_data_file_path, print_data_mime_type,
388 printer_name, job_title, tags, &dry_run); 388 printer_name, job_title, tags, &dry_run);
389 base::MessageLoop::current()->PostTask( 389 base::MessageLoop::current()->PostTask(
390 FROM_HERE, 390 FROM_HERE,
391 base::Bind(&JobSpoolerCUPS::NotifyDelegate, delegate, job_id, dry_run)); 391 base::Bind(&JobSpoolerCUPS::NotifyDelegate, delegate, job_id, dry_run));
392 return true; 392 return true;
393 } 393 }
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 872
873 void PrintSystemCUPS::RunCapsCallback( 873 void PrintSystemCUPS::RunCapsCallback(
874 const PrinterCapsAndDefaultsCallback& callback, 874 const PrinterCapsAndDefaultsCallback& callback,
875 bool succeeded, 875 bool succeeded,
876 const std::string& printer_name, 876 const std::string& printer_name,
877 const printing::PrinterCapsAndDefaults& printer_info) { 877 const printing::PrinterCapsAndDefaults& printer_info) {
878 callback.Run(succeeded, printer_name, printer_info); 878 callback.Run(succeeded, printer_name, printer_info);
879 } 879 }
880 880
881 } // namespace cloud_print 881 } // namespace cloud_print
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/job_status_updater.h ('k') | chrome/service/cloud_print/print_system_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698