Index: chrome/browser/chromeos/drive/job_queue.cc |
diff --git a/chrome/browser/chromeos/drive/job_queue.cc b/chrome/browser/chromeos/drive/job_queue.cc |
index e1ea3174020f53f526ee12a43f6af13ffd9610eb..f6070b1dc91a83259bd32af164e91a76ff0f1d87 100644 |
--- a/chrome/browser/chromeos/drive/job_queue.cc |
+++ b/chrome/browser/chromeos/drive/job_queue.cc |
@@ -41,22 +41,18 @@ |
return; |
// Looks up the queue in the order of priority upto |accepted_priority|. |
- bool processing_batch_request = false; |
- int64 total_size = 0; |
+ uint64 total_size = 0; |
+ bool batchable = true; |
for (int priority = 0; priority <= accepted_priority; ++priority) { |
- auto it = queue_[priority].begin(); |
- while (it != queue_[priority].end()) { |
- if (!processing_batch_request || |
- (it->batchable && total_size + it->size <= max_batch_size_)) { |
- total_size += it->size; |
- processing_batch_request = it->batchable; |
- jobs->push_back(it->id); |
- running_.insert(it->id); |
- it = queue_[priority].erase(it); |
- if (processing_batch_request) |
- continue; |
- } |
- return; |
+ while (!queue_[priority].empty()) { |
+ const auto& item = queue_[priority].front(); |
+ total_size += item.size; |
+ batchable = batchable && item.batchable && total_size <= max_batch_size_; |
+ if (!(jobs->empty() || batchable)) |
+ return; |
+ jobs->push_back(item.id); |
+ running_.insert(item.id); |
+ queue_[priority].pop_front(); |
} |
} |
} |