OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/drive/job_queue.h" | 5 #include "chrome/browser/chromeos/drive/job_queue.h" |
6 | 6 |
| 7 #include <algorithm> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
9 | 11 |
10 namespace drive { | 12 namespace drive { |
11 | 13 |
12 JobQueue::JobQueue(size_t num_max_concurrent_jobs, | 14 JobQueue::JobQueue(size_t num_max_concurrent_jobs, |
13 size_t num_priority_levels) | 15 size_t num_priority_levels) |
14 : num_max_concurrent_jobs_(num_max_concurrent_jobs), | 16 : num_max_concurrent_jobs_(num_max_concurrent_jobs), |
15 queue_(num_priority_levels) { | 17 queue_(num_priority_levels) { |
16 } | 18 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 static_cast<int>(running_.size())); | 59 static_cast<int>(running_.size())); |
58 } | 60 } |
59 | 61 |
60 size_t JobQueue::GetNumberOfJobs() const { | 62 size_t JobQueue::GetNumberOfJobs() const { |
61 size_t count = running_.size(); | 63 size_t count = running_.size(); |
62 for (size_t i = 0; i < queue_.size(); ++i) | 64 for (size_t i = 0; i < queue_.size(); ++i) |
63 count += queue_[i].size(); | 65 count += queue_[i].size(); |
64 return count; | 66 return count; |
65 } | 67 } |
66 | 68 |
| 69 void JobQueue::Remove(JobID id) { |
| 70 for (size_t i = 0; i < queue_.size(); ++i) { |
| 71 std::deque<JobID>::iterator iter = |
| 72 std::find(queue_[i].begin(), queue_[i].end(), id); |
| 73 if (iter != queue_[i].end()) { |
| 74 queue_[i].erase(iter); |
| 75 break; |
| 76 } |
| 77 } |
| 78 } |
| 79 |
67 } // namespace drive | 80 } // namespace drive |
OLD | NEW |