Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: components/drive/job_scheduler.cc

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Fix typo breaking a bunch of trybot builds, oops Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 int32_t job_key = job_map_.Add(
725 job->job_info.job_id = job_map_.Add(job); // Takes the ownership of |job|. 725 base::MakeUnique<JobEntry>(type));
726 JobEntry* job = job_map_.Lookup(job_key);
danakj 2016/11/18 00:15:32 You don't need to do Lookup, you can just get a po
727 job->job_info.job_id = job_key;
726 return job; 728 return job;
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 }
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698