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/atomicops.h" | 9 #include "base/atomicops.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/debug/task_annotator.h" | 11 #include "base/debug/task_annotator.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
14 #include "base/sequence_token.h" | 14 #include "base/sequence_and_task_token.h" |
15 #include "base/threading/sequenced_task_runner_handle.h" | 15 #include "base/threading/sequenced_task_runner_handle.h" |
16 #include "base/threading/thread_restrictions.h" | 16 #include "base/threading/thread_restrictions.h" |
17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 namespace internal { | 21 namespace internal { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 return; | 190 return; |
191 | 191 |
192 // All tasks run through here and the scheduler itself doesn't use singletons. | 192 // All tasks run through here and the scheduler itself doesn't use singletons. |
193 // Therefore, it isn't necessary to reset the singleton allowed bit after | 193 // Therefore, it isn't necessary to reset the singleton allowed bit after |
194 // running the task. | 194 // running the task. |
195 ThreadRestrictions::SetSingletonAllowed( | 195 ThreadRestrictions::SetSingletonAllowed( |
196 task->traits.shutdown_behavior() != | 196 task->traits.shutdown_behavior() != |
197 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN); | 197 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN); |
198 | 198 |
199 { | 199 { |
200 // Set up SequenceToken as expected for the scope of the task. | 200 // Set up SequenceToken and TaskToken as expected for the scope of the task. |
201 ScopedSetSequenceTokenForCurrentThread | 201 ScopedSetSequenceAndTaskTokenForCurrentThread |
202 scoped_set_sequence_token_for_current_thread(sequence->token()); | 202 scoped_set_sequence_and_task_token_for_current_thread( |
| 203 sequence->token()); |
203 | 204 |
204 // Set up TaskRunnerHandle as expected for the scope of the task. | 205 // Set up TaskRunnerHandle as expected for the scope of the task. |
205 std::unique_ptr<SequencedTaskRunnerHandle> sequenced_task_runner_handle; | 206 std::unique_ptr<SequencedTaskRunnerHandle> sequenced_task_runner_handle; |
206 std::unique_ptr<ThreadTaskRunnerHandle> single_thread_task_runner_handle; | 207 std::unique_ptr<ThreadTaskRunnerHandle> single_thread_task_runner_handle; |
207 DCHECK(!task->sequenced_task_runner_ref || | 208 DCHECK(!task->sequenced_task_runner_ref || |
208 !task->single_thread_task_runner_ref); | 209 !task->single_thread_task_runner_ref); |
209 if (task->sequenced_task_runner_ref) { | 210 if (task->sequenced_task_runner_ref) { |
210 sequenced_task_runner_handle.reset( | 211 sequenced_task_runner_handle.reset( |
211 new SequencedTaskRunnerHandle(task->sequenced_task_runner_ref)); | 212 new SequencedTaskRunnerHandle(task->sequenced_task_runner_ref)); |
212 } else if (task->single_thread_task_runner_ref) { | 213 } else if (task->single_thread_task_runner_ref) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 | 331 |
331 // This method can only be called after shutdown has started. | 332 // This method can only be called after shutdown has started. |
332 DCHECK(state_->HasShutdownStarted()); | 333 DCHECK(state_->HasShutdownStarted()); |
333 DCHECK(shutdown_event_); | 334 DCHECK(shutdown_event_); |
334 | 335 |
335 shutdown_event_->Signal(); | 336 shutdown_event_->Signal(); |
336 } | 337 } |
337 | 338 |
338 } // namespace internal | 339 } // namespace internal |
339 } // namespace base | 340 } // namespace base |
OLD | NEW |