 Chromium Code Reviews
 Chromium Code Reviews Issue 2480293004:
  Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode.  (Closed)
    
  
    Issue 2480293004:
  Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode.  (Closed) 
  | 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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 JobEntry* job = new JobEntry(type); | 
| 725 job->job_info.job_id = job_map_.Add(job); // Takes the ownership of |job|. | 725 job->job_info.job_id = job_map_.Add( | 
| 726 std::unique_ptr<JobEntry>(job)); // Takes the ownership of |job|. | |
| 
aelias_OOO_until_Jul13
2016/11/10 06:04:48
Please replace this with base::MakeUnique<JobEntry
 
rlanday
2016/11/10 18:20:01
So this one's a little weird, job is actually used
 
aelias_OOO_until_Jul13
2016/11/10 19:36:19
Yes, that's preferable in both cases, thanks.
 | |
| 726 return job; | 727 return job; | 
| 727 } | 728 } | 
| 728 | 729 | 
| 729 void JobScheduler::StartJob(JobEntry* job) { | 730 void JobScheduler::StartJob(JobEntry* job) { | 
| 730 DCHECK(!job->task.is_null()); | 731 DCHECK(!job->task.is_null()); | 
| 731 | 732 | 
| 732 QueueJob(job->job_info.job_id); | 733 QueueJob(job->job_info.job_id); | 
| 733 NotifyJobAdded(job->job_info); | 734 NotifyJobAdded(job->job_info); | 
| 734 DoJobLoop(GetJobQueueType(job->job_info.job_type)); | 735 DoJobLoop(GetJobQueueType(job->job_info.job_type)); | 
| 735 } | 736 } | 
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1189 case FILE_QUEUE: | 1190 case FILE_QUEUE: | 
| 1190 return "FILE_QUEUE"; | 1191 return "FILE_QUEUE"; | 
| 1191 case NUM_QUEUES: | 1192 case NUM_QUEUES: | 
| 1192 break; // This value is just a sentinel. Should never be used. | 1193 break; // This value is just a sentinel. Should never be used. | 
| 1193 } | 1194 } | 
| 1194 NOTREACHED(); | 1195 NOTREACHED(); | 
| 1195 return ""; | 1196 return ""; | 
| 1196 } | 1197 } | 
| 1197 | 1198 | 
| 1198 } // namespace drive | 1199 } // namespace drive | 
| OLD | NEW |