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

Unified Diff: chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc

Issue 2694123002: Handle retained printing history. (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc
diff --git a/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc b/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc
index 6651a368b39d6cca4a7d0c1f6dbdedfc28e44cd7..327e63aed87f769b8e860729e5aa2ff4cd0fd86d 100644
--- a/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc
+++ b/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc
@@ -188,42 +188,28 @@ void CupsPrintJobManagerImpl::QueryCups() {
weak_ptr_factory_.GetWeakPtr(), jobs));
}
-// Use job information to update local job states. Update jobs that are no
-// longer being reported on by CUPS.
+// Use job information to update local job states. Previously completed jobs
+// could be in |jobs| but those are ignored as we will not emit updates for them
+// after they are completed.
void CupsPrintJobManagerImpl::UpdateJobs(
const std::vector<::printing::CupsJob>& jobs) {
- std::set<std::string> updated_jobs;
for (auto& job : jobs) {
std::string key = CupsPrintJob::GetUniqueId(job.printer_id, job.id);
- if (!base::ContainsKey(jobs_, key)) {
- LOG(WARNING) << "Unexpected print job encountered";
- continue;
- }
-
- JobStateUpdated(jobs_[key].get(), ConvertState(job.state));
- updated_jobs.insert(key);
- }
+ const auto& entry = jobs_.find(key);
+ if (entry != jobs_.end()) {
+ CupsPrintJob* print_job = entry->second.get();
- // Cleanup completed jobs.
- auto it = jobs_.begin();
- while (it != jobs_.end()) {
- auto& entry = *it;
- if (!base::ContainsKey(updated_jobs, entry.first)) {
- // We are no longer receiving updates for a job. Declare it
- // complete.
- JobStateUpdated(entry.second.get(),
- CupsPrintJob::State::STATE_DOCUMENT_DONE);
- }
+ // Update a job we're tracking.
+ JobStateUpdated(print_job, ConvertState(job.state));
- CupsPrintJob* job = entry.second.get();
- if (JobFinished(job->state())) {
- // Delete job since we will no longer receive events for it.
- it = jobs_.erase(it);
- } else {
- it++;
+ // Cleanup completed jobs.
+ if (JobFinished(print_job->state())) {
+ jobs_.erase(entry);
+ }
}
}
+ // Keep polling until all jobs complete or error.
if (!jobs_.empty())
ScheduleQuery();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698