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

Unified Diff: chrome/browser/printing/print_job_manager.cc

Issue 11443020: Replaced vector with set for current_jobs_. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | « chrome/browser/printing/print_job_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/printing/print_job_manager.cc
diff --git a/chrome/browser/printing/print_job_manager.cc b/chrome/browser/printing/print_job_manager.cc
index 154f735423d20a45a83b596f42edd3c5aade4fb2..7e1436e43014d264d9d2f289962c7ebdc824f185 100644
--- a/chrome/browser/printing/print_job_manager.cc
+++ b/chrome/browser/printing/print_job_manager.cc
@@ -106,29 +106,15 @@ void PrintJobManager::OnPrintJobEvent(
break;
}
case JobEventDetails::JOB_DONE: {
- PrintJobs::iterator itr = std::find(current_jobs_.begin(),
- current_jobs_.end(),
- print_job);
- DCHECK(current_jobs_.end() != itr);
- current_jobs_.erase(itr);
- DCHECK(current_jobs_.end() == std::find(current_jobs_.begin(),
- current_jobs_.end(),
- print_job));
- destination_ = NULL;
+ DCHECK(std::count(current_jobs_.begin(),
+ current_jobs_.end(), print_job) == 1);
+ RemoveJob(print_job);
break;
}
case JobEventDetails::FAILED: {
- PrintJobs::iterator itr = std::find(current_jobs_.begin(),
- current_jobs_.end(),
- print_job);
- // A failed job may have never started.
- if (current_jobs_.end() != itr) {
- current_jobs_.erase(itr);
- DCHECK(current_jobs_.end() ==
- std::find(current_jobs_.begin(),
- current_jobs_.end(),
- print_job));
- }
+ DCHECK(std::count(current_jobs_.begin(),
gene 2012/12/05 21:52:31 I think this check makes more sense in RemoveJob()
Vitaly Buka (NO REVIEWS) 2012/12/05 23:27:42 Done.
+ current_jobs_.end(), print_job) <= 1);
+ RemoveJob(print_job);
break;
}
case JobEventDetails::USER_INIT_DONE:
@@ -148,4 +134,10 @@ void PrintJobManager::OnPrintJobEvent(
}
}
+void PrintJobManager::RemoveJob(PrintJob* print_job) {
gene 2012/12/05 21:52:31 I think it will be easier to read if you iterate c
Vitaly Buka (NO REVIEWS) 2012/12/05 23:27:42 Done.
+ current_jobs_.erase(std::remove(current_jobs_.begin(), current_jobs_.end(),
+ print_job),
+ current_jobs_.end());
+}
+
} // namespace printing
« no previous file with comments | « chrome/browser/printing/print_job_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698