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/printer_job_handler.h" | 5 #include "chrome/service/cloud_print/printer_job_handler.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/md5.h" | 9 #include "base/md5.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 bool PrinterJobHandler::Initialize() { | 60 bool PrinterJobHandler::Initialize() { |
61 if (print_system_->IsValidPrinter( | 61 if (print_system_->IsValidPrinter( |
62 printer_info_.printer_name)) { | 62 printer_info_.printer_name)) { |
63 printer_watcher_ = print_system_->CreatePrinterWatcher( | 63 printer_watcher_ = print_system_->CreatePrinterWatcher( |
64 printer_info_.printer_name); | 64 printer_info_.printer_name); |
65 printer_watcher_->StartWatching(this); | 65 printer_watcher_->StartWatching(this); |
66 CheckForJobs(kJobFetchReasonStartup); | 66 CheckForJobs(kJobFetchReasonStartup); |
67 } else { | 67 } else { |
68 // This printer does not exist any more. Delete it from the server. | 68 // This printer does not exist any more. Check if we should delete it from |
69 OnPrinterDeleted(); | 69 // the server. |
| 70 bool delete_from_server = false; |
| 71 delegate_->OnPrinterNotFound(printer_info_.printer_name, |
| 72 &delete_from_server); |
| 73 if (delete_from_server) |
| 74 OnPrinterDeleted(); |
70 } | 75 } |
71 return true; | 76 return true; |
72 } | 77 } |
73 | 78 |
74 PrinterJobHandler::~PrinterJobHandler() { | 79 PrinterJobHandler::~PrinterJobHandler() { |
75 if (printer_watcher_) | 80 if (printer_watcher_) |
76 printer_watcher_->StopWatching(); | 81 printer_watcher_->StopWatching(); |
77 } | 82 } |
78 | 83 |
79 void PrinterJobHandler::Reset() { | 84 void PrinterJobHandler::Reset() { |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 } | 637 } |
633 | 638 |
634 void PrinterJobHandler::OnJobSpoolFailed() { | 639 void PrinterJobHandler::OnJobSpoolFailed() { |
635 DCHECK(MessageLoop::current() == print_thread_.message_loop()); | 640 DCHECK(MessageLoop::current() == print_thread_.message_loop()); |
636 job_spooler_ = NULL; | 641 job_spooler_ = NULL; |
637 job_handler_message_loop_proxy_->PostTask(FROM_HERE, | 642 job_handler_message_loop_proxy_->PostTask(FROM_HERE, |
638 NewRunnableMethod(this, | 643 NewRunnableMethod(this, |
639 &PrinterJobHandler::JobFailed, | 644 &PrinterJobHandler::JobFailed, |
640 PRINT_FAILED)); | 645 PRINT_FAILED)); |
641 } | 646 } |
OLD | NEW |