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

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

Issue 2122543002: Replace Closure in TaskRunner::PostTask with OneShotCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@07_oneshot
Patch Set: fix Created 4 years, 3 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
« no previous file with comments | « base/task_scheduler/task_tracker.h ('k') | base/test/null_task_runner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/atomicops.h" 9 #include "base/atomicops.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 if (!BeforePostTask(task->traits.shutdown_behavior())) 185 if (!BeforePostTask(task->traits.shutdown_behavior()))
186 return false; 186 return false;
187 187
188 debug::TaskAnnotator task_annotator; 188 debug::TaskAnnotator task_annotator;
189 task_annotator.DidQueueTask(kQueueFunctionName, *task); 189 task_annotator.DidQueueTask(kQueueFunctionName, *task);
190 190
191 return true; 191 return true;
192 } 192 }
193 193
194 bool TaskTracker::RunTask(const Task* task, 194 bool TaskTracker::RunTask(Task* task,
195 const SequenceToken& sequence_token) { 195 const SequenceToken& sequence_token) {
196 DCHECK(task); 196 DCHECK(task);
197 DCHECK(sequence_token.IsValid()); 197 DCHECK(sequence_token.IsValid());
198 198
199 const TaskShutdownBehavior shutdown_behavior = 199 const TaskShutdownBehavior shutdown_behavior =
200 task->traits.shutdown_behavior(); 200 task->traits.shutdown_behavior();
201 if (!BeforeRunTask(shutdown_behavior)) 201 if (!BeforeRunTask(shutdown_behavior))
202 return false; 202 return false;
203 203
204 // All tasks run through here and the scheduler itself doesn't use singletons. 204 // All tasks run through here and the scheduler itself doesn't use singletons.
(...skipping 17 matching lines...) Expand all
222 sequenced_task_runner_handle.reset( 222 sequenced_task_runner_handle.reset(
223 new SequencedTaskRunnerHandle(task->sequenced_task_runner_ref)); 223 new SequencedTaskRunnerHandle(task->sequenced_task_runner_ref));
224 } else if (task->single_thread_task_runner_ref) { 224 } else if (task->single_thread_task_runner_ref) {
225 single_thread_task_runner_handle.reset( 225 single_thread_task_runner_handle.reset(
226 new ThreadTaskRunnerHandle(task->single_thread_task_runner_ref)); 226 new ThreadTaskRunnerHandle(task->single_thread_task_runner_ref));
227 } 227 }
228 228
229 TRACE_TASK_EXECUTION(kRunFunctionName, *task); 229 TRACE_TASK_EXECUTION(kRunFunctionName, *task);
230 230
231 debug::TaskAnnotator task_annotator; 231 debug::TaskAnnotator task_annotator;
232 task_annotator.RunTask(kQueueFunctionName, *task); 232 task_annotator.RunTask(kQueueFunctionName, task);
233 } 233 }
234 234
235 AfterRunTask(shutdown_behavior); 235 AfterRunTask(shutdown_behavior);
236 236
237 return true; 237 return true;
238 } 238 }
239 239
240 bool TaskTracker::HasShutdownStarted() const { 240 bool TaskTracker::HasShutdownStarted() const {
241 return state_->HasShutdownStarted(); 241 return state_->HasShutdownStarted();
242 } 242 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 344
345 // This method can only be called after shutdown has started. 345 // This method can only be called after shutdown has started.
346 DCHECK(state_->HasShutdownStarted()); 346 DCHECK(state_->HasShutdownStarted());
347 DCHECK(shutdown_event_); 347 DCHECK(shutdown_event_);
348 348
349 shutdown_event_->Signal(); 349 shutdown_event_->Signal();
350 } 350 }
351 351
352 } // namespace internal 352 } // namespace internal
353 } // namespace base 353 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/task_tracker.h ('k') | base/test/null_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698