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 3 // found in the LICENSE file. 4 5 #ifndef BASE_TASK_SCHEDULER_SCOPED_SET_TASK_PRIORITY_FOR_CURRENT_THREAD_H_ 6 #define BASE_TASK_SCHEDULER_SCOPED_SET_TASK_PRIORITY_FOR_CURRENT_THREAD_H_ 7 8 #include "base/base_export.h" 9 #include "base/macros.h" 10 #include "base/task_scheduler/task_traits.h" 11 12 namespace base { 13 namespace internal { 14 15 class BASE_EXPORT ScopedSetTaskPriorityForCurrentThread { 16 public: 17 // Within the scope of this object, GetTaskPriorityForCurrentThread() will 18 // return |priority|. 19 ScopedSetTaskPriorityForCurrentThread(TaskPriority priority); 20 ~ScopedSetTaskPriorityForCurrentThread(); 21 22 private: 23 const TaskPriority priority_; 24 25 DISALLOW_COPY_AND_ASSIGN(ScopedSetTaskPriorityForCurrentThread); 26 }; 27 28 // Returns the priority of the TaskScheduler task running on the current thread, 29 // or TaskPriority::USER_VISIBLE if no TaskScheduler task is running on the 30 // current thread. 31 BASE_EXPORT TaskPriority GetTaskPriorityForCurrentThread(); 32 33 } // namespace internal 34 } // namespace base 35 36 #endif // BASE_TASK_SCHEDULER_SCOPED_SET_TASK_PRIORITY_FOR_CURRENT_THREAD_H_ 37