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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/printing/print_job_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser/printing/print_job_manager.h" 5 #include "chrome/browser/printing/print_job_manager.h"
6 6
7 #include "chrome/browser/printing/print_job.h" 7 #include "chrome/browser/printing/print_job.h"
8 #include "chrome/browser/printing/printer_query.h" 8 #include "chrome/browser/printing/printer_query.h"
9 #include "chrome/common/chrome_notification_types.h" 9 #include "chrome/common/chrome_notification_types.h"
10 #include "content/public/browser/notification_service.h" 10 #include "content/public/browser/notification_service.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 switch (event_details.type()) { 99 switch (event_details.type()) {
100 case JobEventDetails::NEW_DOC: { 100 case JobEventDetails::NEW_DOC: {
101 DCHECK(current_jobs_.end() == std::find(current_jobs_.begin(), 101 DCHECK(current_jobs_.end() == std::find(current_jobs_.begin(),
102 current_jobs_.end(), 102 current_jobs_.end(),
103 print_job)); 103 print_job));
104 // Causes a AddRef(). 104 // Causes a AddRef().
105 current_jobs_.push_back(make_scoped_refptr(print_job)); 105 current_jobs_.push_back(make_scoped_refptr(print_job));
106 break; 106 break;
107 } 107 }
108 case JobEventDetails::JOB_DONE: { 108 case JobEventDetails::JOB_DONE: {
109 PrintJobs::iterator itr = std::find(current_jobs_.begin(), 109 DCHECK(std::count(current_jobs_.begin(),
110 current_jobs_.end(), 110 current_jobs_.end(), print_job) == 1);
111 print_job); 111 RemoveJob(print_job);
112 DCHECK(current_jobs_.end() != itr);
113 current_jobs_.erase(itr);
114 DCHECK(current_jobs_.end() == std::find(current_jobs_.begin(),
115 current_jobs_.end(),
116 print_job));
117 destination_ = NULL;
118 break; 112 break;
119 } 113 }
120 case JobEventDetails::FAILED: { 114 case JobEventDetails::FAILED: {
121 PrintJobs::iterator itr = std::find(current_jobs_.begin(), 115 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.
122 current_jobs_.end(), 116 current_jobs_.end(), print_job) <= 1);
123 print_job); 117 RemoveJob(print_job);
124 // A failed job may have never started.
125 if (current_jobs_.end() != itr) {
126 current_jobs_.erase(itr);
127 DCHECK(current_jobs_.end() ==
128 std::find(current_jobs_.begin(),
129 current_jobs_.end(),
130 print_job));
131 }
132 break; 118 break;
133 } 119 }
134 case JobEventDetails::USER_INIT_DONE: 120 case JobEventDetails::USER_INIT_DONE:
135 case JobEventDetails::USER_INIT_CANCELED: 121 case JobEventDetails::USER_INIT_CANCELED:
136 case JobEventDetails::DEFAULT_INIT_DONE: 122 case JobEventDetails::DEFAULT_INIT_DONE:
137 case JobEventDetails::NEW_PAGE: 123 case JobEventDetails::NEW_PAGE:
138 case JobEventDetails::PAGE_DONE: 124 case JobEventDetails::PAGE_DONE:
139 case JobEventDetails::DOC_DONE: 125 case JobEventDetails::DOC_DONE:
140 case JobEventDetails::ALL_PAGES_REQUESTED: { 126 case JobEventDetails::ALL_PAGES_REQUESTED: {
141 // Don't care. 127 // Don't care.
142 break; 128 break;
143 } 129 }
144 default: { 130 default: {
145 NOTREACHED(); 131 NOTREACHED();
146 break; 132 break;
147 } 133 }
148 } 134 }
149 } 135 }
150 136
137 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.
138 current_jobs_.erase(std::remove(current_jobs_.begin(), current_jobs_.end(),
139 print_job),
140 current_jobs_.end());
141 }
142
151 } // namespace printing 143 } // namespace printing
OLDNEW
« 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