xref: /aosp_15_r20/external/libchrome/base/task_scheduler/task_traits.cc (revision 635a864187cb8b6c713ff48b7e790a6b21769273)
1*635a8641SAndroid Build Coastguard Worker // Copyright 2016 The Chromium Authors. All rights reserved.
2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file.
4*635a8641SAndroid Build Coastguard Worker 
5*635a8641SAndroid Build Coastguard Worker #include "base/task_scheduler/task_traits.h"
6*635a8641SAndroid Build Coastguard Worker 
7*635a8641SAndroid Build Coastguard Worker #include <stddef.h>
8*635a8641SAndroid Build Coastguard Worker 
9*635a8641SAndroid Build Coastguard Worker #include <ostream>
10*635a8641SAndroid Build Coastguard Worker 
11*635a8641SAndroid Build Coastguard Worker #include "base/logging.h"
12*635a8641SAndroid Build Coastguard Worker 
13*635a8641SAndroid Build Coastguard Worker namespace base {
14*635a8641SAndroid Build Coastguard Worker 
TaskPriorityToString(TaskPriority task_priority)15*635a8641SAndroid Build Coastguard Worker const char* TaskPriorityToString(TaskPriority task_priority) {
16*635a8641SAndroid Build Coastguard Worker   switch (task_priority) {
17*635a8641SAndroid Build Coastguard Worker     case TaskPriority::BACKGROUND:
18*635a8641SAndroid Build Coastguard Worker       return "BACKGROUND";
19*635a8641SAndroid Build Coastguard Worker     case TaskPriority::USER_VISIBLE:
20*635a8641SAndroid Build Coastguard Worker       return "USER_VISIBLE";
21*635a8641SAndroid Build Coastguard Worker     case TaskPriority::USER_BLOCKING:
22*635a8641SAndroid Build Coastguard Worker       return "USER_BLOCKING";
23*635a8641SAndroid Build Coastguard Worker   }
24*635a8641SAndroid Build Coastguard Worker   NOTREACHED();
25*635a8641SAndroid Build Coastguard Worker   return "";
26*635a8641SAndroid Build Coastguard Worker }
27*635a8641SAndroid Build Coastguard Worker 
TaskShutdownBehaviorToString(TaskShutdownBehavior shutdown_behavior)28*635a8641SAndroid Build Coastguard Worker const char* TaskShutdownBehaviorToString(
29*635a8641SAndroid Build Coastguard Worker     TaskShutdownBehavior shutdown_behavior) {
30*635a8641SAndroid Build Coastguard Worker   switch (shutdown_behavior) {
31*635a8641SAndroid Build Coastguard Worker     case TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN:
32*635a8641SAndroid Build Coastguard Worker       return "CONTINUE_ON_SHUTDOWN";
33*635a8641SAndroid Build Coastguard Worker     case TaskShutdownBehavior::SKIP_ON_SHUTDOWN:
34*635a8641SAndroid Build Coastguard Worker       return "SKIP_ON_SHUTDOWN";
35*635a8641SAndroid Build Coastguard Worker     case TaskShutdownBehavior::BLOCK_SHUTDOWN:
36*635a8641SAndroid Build Coastguard Worker       return "BLOCK_SHUTDOWN";
37*635a8641SAndroid Build Coastguard Worker   }
38*635a8641SAndroid Build Coastguard Worker   NOTREACHED();
39*635a8641SAndroid Build Coastguard Worker   return "";
40*635a8641SAndroid Build Coastguard Worker }
41*635a8641SAndroid Build Coastguard Worker 
operator <<(std::ostream & os,const TaskPriority & task_priority)42*635a8641SAndroid Build Coastguard Worker std::ostream& operator<<(std::ostream& os, const TaskPriority& task_priority) {
43*635a8641SAndroid Build Coastguard Worker   os << TaskPriorityToString(task_priority);
44*635a8641SAndroid Build Coastguard Worker   return os;
45*635a8641SAndroid Build Coastguard Worker }
46*635a8641SAndroid Build Coastguard Worker 
operator <<(std::ostream & os,const TaskShutdownBehavior & shutdown_behavior)47*635a8641SAndroid Build Coastguard Worker std::ostream& operator<<(std::ostream& os,
48*635a8641SAndroid Build Coastguard Worker                          const TaskShutdownBehavior& shutdown_behavior) {
49*635a8641SAndroid Build Coastguard Worker   os << TaskShutdownBehaviorToString(shutdown_behavior);
50*635a8641SAndroid Build Coastguard Worker   return os;
51*635a8641SAndroid Build Coastguard Worker }
52*635a8641SAndroid Build Coastguard Worker 
53*635a8641SAndroid Build Coastguard Worker }  // namespace base
54