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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
714 role, | 714 role, |
715 base::Bind(&JobScheduler::OnEntryActionJobDone, | 715 base::Bind(&JobScheduler::OnEntryActionJobDone, |
716 weak_ptr_factory_.GetWeakPtr(), | 716 weak_ptr_factory_.GetWeakPtr(), |
717 new_job->job_info.job_id, | 717 new_job->job_info.job_id, |
718 callback)); | 718 callback)); |
719 new_job->abort_callback = callback; | 719 new_job->abort_callback = callback; |
720 StartJob(new_job); | 720 StartJob(new_job); |
721 } | 721 } |
722 | 722 |
723 JobScheduler::JobEntry* JobScheduler::CreateNewJob(JobType type) { | 723 JobScheduler::JobEntry* JobScheduler::CreateNewJob(JobType type) { |
724 JobEntry* job = new JobEntry(type); | 724 std::unique_ptr<JobEntry> job = base::MakeUnique<JobEntry>(type); |
danakj
2016/11/30 00:34:00
can use auto
| |
725 job->job_info.job_id = job_map_.Add(job); // Takes the ownership of |job|. | 725 JobEntry* job_raw = job.get(); |
726 return job; | 726 int32_t job_key = job_map_.Add(std::move(job)); |
727 job_raw->job_info.job_id = job_key; | |
728 return job_raw; | |
727 } | 729 } |
728 | 730 |
729 void JobScheduler::StartJob(JobEntry* job) { | 731 void JobScheduler::StartJob(JobEntry* job) { |
730 DCHECK(!job->task.is_null()); | 732 DCHECK(!job->task.is_null()); |
731 | 733 |
732 QueueJob(job->job_info.job_id); | 734 QueueJob(job->job_info.job_id); |
733 NotifyJobAdded(job->job_info); | 735 NotifyJobAdded(job->job_info); |
734 DoJobLoop(GetJobQueueType(job->job_info.job_type)); | 736 DoJobLoop(GetJobQueueType(job->job_info.job_type)); |
735 } | 737 } |
736 | 738 |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1189 case FILE_QUEUE: | 1191 case FILE_QUEUE: |
1190 return "FILE_QUEUE"; | 1192 return "FILE_QUEUE"; |
1191 case NUM_QUEUES: | 1193 case NUM_QUEUES: |
1192 break; // This value is just a sentinel. Should never be used. | 1194 break; // This value is just a sentinel. Should never be used. |
1193 } | 1195 } |
1194 NOTREACHED(); | 1196 NOTREACHED(); |
1195 return ""; | 1197 return ""; |
1196 } | 1198 } |
1197 | 1199 |
1198 } // namespace drive | 1200 } // namespace drive |
OLD | NEW |