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

Side by Side Diff: base/task_scheduler/task_tracker.cc

Issue 2386653002: Replace base::Callback with base::OnceCallback in base::PendingTask (Closed)
Patch Set: revert most of task_scheduler changes Created 4 years, 2 months 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/task_scheduler/task_tracker.h" 5 #include "base/task_scheduler/task_tracker.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/debug/task_annotator.h" 10 #include "base/debug/task_annotator.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 if (task->delayed_run_time.is_null()) 160 if (task->delayed_run_time.is_null())
161 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, 1); 161 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, 1);
162 162
163 debug::TaskAnnotator task_annotator; 163 debug::TaskAnnotator task_annotator;
164 task_annotator.DidQueueTask(kQueueFunctionName, *task); 164 task_annotator.DidQueueTask(kQueueFunctionName, *task);
165 165
166 return true; 166 return true;
167 } 167 }
168 168
169 bool TaskTracker::RunTask(const Task* task, 169 bool TaskTracker::RunTask(Task* task, const SequenceToken& sequence_token) {
170 const SequenceToken& sequence_token) {
171 DCHECK(task); 170 DCHECK(task);
172 DCHECK(sequence_token.IsValid()); 171 DCHECK(sequence_token.IsValid());
173 172
174 const TaskShutdownBehavior shutdown_behavior = 173 const TaskShutdownBehavior shutdown_behavior =
175 task->traits.shutdown_behavior(); 174 task->traits.shutdown_behavior();
176 const bool can_run_task = BeforeRunTask(shutdown_behavior); 175 const bool can_run_task = BeforeRunTask(shutdown_behavior);
177 176
178 if (can_run_task) { 177 if (can_run_task) {
179 // All tasks run through here and the scheduler itself doesn't use 178 // All tasks run through here and the scheduler itself doesn't use
180 // singletons. Therefore, it isn't necessary to reset the singleton allowed 179 // singletons. Therefore, it isn't necessary to reset the singleton allowed
(...skipping 16 matching lines...) Expand all
197 sequenced_task_runner_handle.reset( 196 sequenced_task_runner_handle.reset(
198 new SequencedTaskRunnerHandle(task->sequenced_task_runner_ref)); 197 new SequencedTaskRunnerHandle(task->sequenced_task_runner_ref));
199 } else if (task->single_thread_task_runner_ref) { 198 } else if (task->single_thread_task_runner_ref) {
200 single_thread_task_runner_handle.reset( 199 single_thread_task_runner_handle.reset(
201 new ThreadTaskRunnerHandle(task->single_thread_task_runner_ref)); 200 new ThreadTaskRunnerHandle(task->single_thread_task_runner_ref));
202 } 201 }
203 202
204 TRACE_TASK_EXECUTION(kRunFunctionName, *task); 203 TRACE_TASK_EXECUTION(kRunFunctionName, *task);
205 204
206 debug::TaskAnnotator task_annotator; 205 debug::TaskAnnotator task_annotator;
207 task_annotator.RunTask(kQueueFunctionName, *task); 206 task_annotator.RunTask(kQueueFunctionName, task);
208 } 207 }
209 208
210 AfterRunTask(shutdown_behavior); 209 AfterRunTask(shutdown_behavior);
211 } 210 }
212 211
213 if (task->delayed_run_time.is_null()) 212 if (task->delayed_run_time.is_null())
214 DecrementNumPendingUndelayedTasks(); 213 DecrementNumPendingUndelayedTasks();
215 214
216 return can_run_task; 215 return can_run_task;
217 } 216 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1); 383 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1);
385 DCHECK_GE(new_num_pending_undelayed_tasks, 0); 384 DCHECK_GE(new_num_pending_undelayed_tasks, 0);
386 if (new_num_pending_undelayed_tasks == 0) { 385 if (new_num_pending_undelayed_tasks == 0) {
387 AutoSchedulerLock auto_lock(flush_lock_); 386 AutoSchedulerLock auto_lock(flush_lock_);
388 flush_cv_->Signal(); 387 flush_cv_->Signal();
389 } 388 }
390 } 389 }
391 390
392 } // namespace internal 391 } // namespace internal
393 } // namespace base 392 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698