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

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

Issue 11572033: Merge 171447 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1312/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
===================================================================
--- chrome/browser/printing/print_job_manager.cc (revision 173056)
+++ chrome/browser/printing/print_job_manager.cc (working copy)
@@ -29,23 +29,17 @@
}
void PrintJobManager::StopJobs(bool wait_for_finish) {
- if (current_jobs_.empty())
- return;
- {
- // Copy the array since it can be modified in transit.
- PrintJobs current_jobs(current_jobs_);
- // Wait for each job to finish.
- for (size_t i = 0; i < current_jobs.size(); ++i) {
- PrintJob* job = current_jobs[i];
- if (!job)
- continue;
- // Wait for two minutes for the print job to be spooled.
- if (wait_for_finish)
- job->FlushJob(base::TimeDelta::FromMinutes(2));
- job->Stop();
- }
+ // Copy the array since it can be modified in transit.
+ PrintJobs to_stop;
+ to_stop.swap(current_jobs_);
+
+ for (PrintJobs::const_iterator job = to_stop.begin(); job != to_stop.end();
+ ++job) {
+ // Wait for two minutes for the print job to be spooled.
+ if (wait_for_finish)
+ (*job)->FlushJob(base::TimeDelta::FromMinutes(2));
+ (*job)->Stop();
}
- current_jobs_.clear();
}
void PrintJobManager::SetPrintDestination(
@@ -98,37 +92,18 @@
const JobEventDetails& event_details) {
switch (event_details.type()) {
case JobEventDetails::NEW_DOC: {
- DCHECK(current_jobs_.end() == std::find(current_jobs_.begin(),
- current_jobs_.end(),
- print_job));
+ DCHECK(current_jobs_.end() == current_jobs_.find(print_job));
// Causes a AddRef().
- current_jobs_.push_back(make_scoped_refptr(print_job));
+ current_jobs_.insert(print_job);
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(current_jobs_.end() != current_jobs_.find(print_job));
+ current_jobs_.erase(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));
- }
+ current_jobs_.erase(print_job);
break;
}
case JobEventDetails::USER_INIT_DONE:
« 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