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

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

Issue 2546773002: TaskScheduler: Add internal::GetTaskPriorityForCurrentThread(). (Closed)
Patch Set: rename to scoped_set_task_priority_for_current_thread.h/cc Created 4 years 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/scoped_set_task_priority_for_current_thread_unittest.cc ('k') | no next file » | 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/callback.h" 9 #include "base/callback.h"
10 #include "base/debug/task_annotator.h" 10 #include "base/debug/task_annotator.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/sequence_token.h" 15 #include "base/sequence_token.h"
16 #include "base/synchronization/condition_variable.h" 16 #include "base/synchronization/condition_variable.h"
17 #include "base/task_scheduler/scoped_set_task_priority_for_current_thread.h"
17 #include "base/threading/sequenced_task_runner_handle.h" 18 #include "base/threading/sequenced_task_runner_handle.h"
18 #include "base/threading/thread_restrictions.h" 19 #include "base/threading/thread_restrictions.h"
19 #include "base/threading/thread_task_runner_handle.h" 20 #include "base/threading/thread_task_runner_handle.h"
20 #include "base/trace_event/trace_event.h" 21 #include "base/trace_event/trace_event.h"
21 #include "base/values.h" 22 #include "base/values.h"
22 23
23 namespace base { 24 namespace base {
24 namespace internal { 25 namespace internal {
25 26
26 namespace { 27 namespace {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // singletons. Therefore, it isn't necessary to reset the singleton allowed 224 // singletons. Therefore, it isn't necessary to reset the singleton allowed
224 // bit after running the task. 225 // bit after running the task.
225 ThreadRestrictions::SetSingletonAllowed( 226 ThreadRestrictions::SetSingletonAllowed(
226 task->traits.shutdown_behavior() != 227 task->traits.shutdown_behavior() !=
227 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN); 228 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN);
228 229
229 const bool previous_wait_allowed = 230 const bool previous_wait_allowed =
230 ThreadRestrictions::SetWaitAllowed(task->traits.with_wait()); 231 ThreadRestrictions::SetWaitAllowed(task->traits.with_wait());
231 232
232 { 233 {
233 // Set up SequenceToken as expected for the scope of the task.
234 ScopedSetSequenceTokenForCurrentThread 234 ScopedSetSequenceTokenForCurrentThread
235 scoped_set_sequence_token_for_current_thread(sequence_token); 235 scoped_set_sequence_token_for_current_thread(sequence_token);
236 ScopedSetTaskPriorityForCurrentThread
237 scoped_set_task_priority_for_current_thread(task->traits.priority());
236 238
237 // Set up TaskRunnerHandle as expected for the scope of the task. 239 // Set up TaskRunnerHandle as expected for the scope of the task.
238 std::unique_ptr<SequencedTaskRunnerHandle> sequenced_task_runner_handle; 240 std::unique_ptr<SequencedTaskRunnerHandle> sequenced_task_runner_handle;
239 std::unique_ptr<ThreadTaskRunnerHandle> single_thread_task_runner_handle; 241 std::unique_ptr<ThreadTaskRunnerHandle> single_thread_task_runner_handle;
240 DCHECK(!task->sequenced_task_runner_ref || 242 DCHECK(!task->sequenced_task_runner_ref ||
241 !task->single_thread_task_runner_ref); 243 !task->single_thread_task_runner_ref);
242 if (task->sequenced_task_runner_ref) { 244 if (task->sequenced_task_runner_ref) {
243 sequenced_task_runner_handle.reset( 245 sequenced_task_runner_handle.reset(
244 new SequencedTaskRunnerHandle(task->sequenced_task_runner_ref)); 246 new SequencedTaskRunnerHandle(task->sequenced_task_runner_ref));
245 } else if (task->single_thread_task_runner_ref) { 247 } else if (task->single_thread_task_runner_ref) {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1); 449 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1);
448 DCHECK_GE(new_num_pending_undelayed_tasks, 0); 450 DCHECK_GE(new_num_pending_undelayed_tasks, 0);
449 if (new_num_pending_undelayed_tasks == 0) { 451 if (new_num_pending_undelayed_tasks == 0) {
450 AutoSchedulerLock auto_lock(flush_lock_); 452 AutoSchedulerLock auto_lock(flush_lock_);
451 flush_cv_->Signal(); 453 flush_cv_->Signal();
452 } 454 }
453 } 455 }
454 456
455 } // namespace internal 457 } // namespace internal
456 } // namespace base 458 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/scoped_set_task_priority_for_current_thread_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698