| OLD | NEW |
| 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 "components/drive/job_scheduler.h" | 5 #include "components/drive/job_scheduler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 job->abort_callback; | 1153 job->abort_callback; |
| 1154 queue_[GetJobQueueType(job->job_info.job_type)]->Remove(job->job_info.job_id); | 1154 queue_[GetJobQueueType(job->job_info.job_type)]->Remove(job->job_info.job_id); |
| 1155 NotifyJobDone(job->job_info, error); | 1155 NotifyJobDone(job->job_info, error); |
| 1156 job_map_.Remove(job->job_info.job_id); | 1156 job_map_.Remove(job->job_info.job_id); |
| 1157 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 1157 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 1158 base::Bind(callback, error)); | 1158 base::Bind(callback, error)); |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 void JobScheduler::NotifyJobAdded(const JobInfo& job_info) { | 1161 void JobScheduler::NotifyJobAdded(const JobInfo& job_info) { |
| 1162 DCHECK(thread_checker_.CalledOnValidThread()); | 1162 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1163 FOR_EACH_OBSERVER(JobListObserver, observer_list_, OnJobAdded(job_info)); | 1163 for (auto& observer : observer_list_) |
| 1164 observer.OnJobAdded(job_info); |
| 1164 } | 1165 } |
| 1165 | 1166 |
| 1166 void JobScheduler::NotifyJobDone(const JobInfo& job_info, | 1167 void JobScheduler::NotifyJobDone(const JobInfo& job_info, |
| 1167 google_apis::DriveApiErrorCode error) { | 1168 google_apis::DriveApiErrorCode error) { |
| 1168 DCHECK(thread_checker_.CalledOnValidThread()); | 1169 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1169 FOR_EACH_OBSERVER(JobListObserver, observer_list_, | 1170 for (auto& observer : observer_list_) |
| 1170 OnJobDone(job_info, GDataToFileError(error))); | 1171 observer.OnJobDone(job_info, GDataToFileError(error)); |
| 1171 } | 1172 } |
| 1172 | 1173 |
| 1173 void JobScheduler::NotifyJobUpdated(const JobInfo& job_info) { | 1174 void JobScheduler::NotifyJobUpdated(const JobInfo& job_info) { |
| 1174 DCHECK(thread_checker_.CalledOnValidThread()); | 1175 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1175 FOR_EACH_OBSERVER(JobListObserver, observer_list_, OnJobUpdated(job_info)); | 1176 for (auto& observer : observer_list_) |
| 1177 observer.OnJobUpdated(job_info); |
| 1176 } | 1178 } |
| 1177 | 1179 |
| 1178 std::string JobScheduler::GetQueueInfo(QueueType type) const { | 1180 std::string JobScheduler::GetQueueInfo(QueueType type) const { |
| 1179 return QueueTypeToString(type) + " " + queue_[type]->ToString(); | 1181 return QueueTypeToString(type) + " " + queue_[type]->ToString(); |
| 1180 } | 1182 } |
| 1181 | 1183 |
| 1182 // static | 1184 // static |
| 1183 std::string JobScheduler::QueueTypeToString(QueueType type) { | 1185 std::string JobScheduler::QueueTypeToString(QueueType type) { |
| 1184 switch (type) { | 1186 switch (type) { |
| 1185 case METADATA_QUEUE: | 1187 case METADATA_QUEUE: |
| 1186 return "METADATA_QUEUE"; | 1188 return "METADATA_QUEUE"; |
| 1187 case FILE_QUEUE: | 1189 case FILE_QUEUE: |
| 1188 return "FILE_QUEUE"; | 1190 return "FILE_QUEUE"; |
| 1189 case NUM_QUEUES: | 1191 case NUM_QUEUES: |
| 1190 break; // This value is just a sentinel. Should never be used. | 1192 break; // This value is just a sentinel. Should never be used. |
| 1191 } | 1193 } |
| 1192 NOTREACHED(); | 1194 NOTREACHED(); |
| 1193 return ""; | 1195 return ""; |
| 1194 } | 1196 } |
| 1195 | 1197 |
| 1196 } // namespace drive | 1198 } // namespace drive |
| OLD | NEW |