| OLD | NEW |
| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 DCHECK(task); | 213 DCHECK(task); |
| 214 DCHECK(sequence_token.IsValid()); | 214 DCHECK(sequence_token.IsValid()); |
| 215 | 215 |
| 216 const TaskShutdownBehavior shutdown_behavior = | 216 const TaskShutdownBehavior shutdown_behavior = |
| 217 task->traits.shutdown_behavior(); | 217 task->traits.shutdown_behavior(); |
| 218 const bool can_run_task = BeforeRunTask(shutdown_behavior); | 218 const bool can_run_task = BeforeRunTask(shutdown_behavior); |
| 219 const bool is_delayed = !task->delayed_run_time.is_null(); | 219 const bool is_delayed = !task->delayed_run_time.is_null(); |
| 220 | 220 |
| 221 if (can_run_task) { | 221 if (can_run_task) { |
| 222 // All tasks run through here and the scheduler itself doesn't use | 222 // All tasks run through here and the scheduler itself doesn't use |
| 223 // singletons. Therefore, it isn't necessary to reset the singleton allowed | 223 // singletons or file I/O. Therefore, it isn't necessary to reset the |
| 224 // bit after running the task. | 224 // singleton allowed or file I/O allowed bits after running the task. |
| 225 ThreadRestrictions::SetSingletonAllowed( | 225 ThreadRestrictions::SetSingletonAllowed( |
| 226 task->traits.shutdown_behavior() != | 226 task->traits.shutdown_behavior() != |
| 227 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN); | 227 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN); |
| 228 ThreadRestrictions::SetIOAllowed(task->traits.with_file_io()); |
| 228 | 229 |
| 229 { | 230 { |
| 230 // Set up SequenceToken as expected for the scope of the task. | 231 // Set up SequenceToken as expected for the scope of the task. |
| 231 ScopedSetSequenceTokenForCurrentThread | 232 ScopedSetSequenceTokenForCurrentThread |
| 232 scoped_set_sequence_token_for_current_thread(sequence_token); | 233 scoped_set_sequence_token_for_current_thread(sequence_token); |
| 233 | 234 |
| 234 // Set up TaskRunnerHandle as expected for the scope of the task. | 235 // Set up TaskRunnerHandle as expected for the scope of the task. |
| 235 std::unique_ptr<SequencedTaskRunnerHandle> sequenced_task_runner_handle; | 236 std::unique_ptr<SequencedTaskRunnerHandle> sequenced_task_runner_handle; |
| 236 std::unique_ptr<ThreadTaskRunnerHandle> single_thread_task_runner_handle; | 237 std::unique_ptr<ThreadTaskRunnerHandle> single_thread_task_runner_handle; |
| 237 DCHECK(!task->sequenced_task_runner_ref || | 238 DCHECK(!task->sequenced_task_runner_ref || |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1); | 443 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1); |
| 443 DCHECK_GE(new_num_pending_undelayed_tasks, 0); | 444 DCHECK_GE(new_num_pending_undelayed_tasks, 0); |
| 444 if (new_num_pending_undelayed_tasks == 0) { | 445 if (new_num_pending_undelayed_tasks == 0) { |
| 445 AutoSchedulerLock auto_lock(flush_lock_); | 446 AutoSchedulerLock auto_lock(flush_lock_); |
| 446 flush_cv_->Signal(); | 447 flush_cv_->Signal(); |
| 447 } | 448 } |
| 448 } | 449 } |
| 449 | 450 |
| 450 } // namespace internal | 451 } // namespace internal |
| 451 } // namespace base | 452 } // namespace base |
| OLD | NEW |