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 #include "base/task_scheduler/task_traits.h" 6 7 #include <stddef.h> 8 9 #include <ostream> 10 11 #include "base/logging.h" 12 13 namespace base { 14 TaskPriorityToString(TaskPriority task_priority)15const char* TaskPriorityToString(TaskPriority task_priority) { 16 switch (task_priority) { 17 case TaskPriority::BACKGROUND: 18 return "BACKGROUND"; 19 case TaskPriority::USER_VISIBLE: 20 return "USER_VISIBLE"; 21 case TaskPriority::USER_BLOCKING: 22 return "USER_BLOCKING"; 23 } 24 NOTREACHED(); 25 return ""; 26 } 27 TaskShutdownBehaviorToString(TaskShutdownBehavior shutdown_behavior)28const char* TaskShutdownBehaviorToString( 29 TaskShutdownBehavior shutdown_behavior) { 30 switch (shutdown_behavior) { 31 case TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN: 32 return "CONTINUE_ON_SHUTDOWN"; 33 case TaskShutdownBehavior::SKIP_ON_SHUTDOWN: 34 return "SKIP_ON_SHUTDOWN"; 35 case TaskShutdownBehavior::BLOCK_SHUTDOWN: 36 return "BLOCK_SHUTDOWN"; 37 } 38 NOTREACHED(); 39 return ""; 40 } 41 operator <<(std::ostream & os,const TaskPriority & task_priority)42std::ostream& operator<<(std::ostream& os, const TaskPriority& task_priority) { 43 os << TaskPriorityToString(task_priority); 44 return os; 45 } 46 operator <<(std::ostream & os,const TaskShutdownBehavior & shutdown_behavior)47std::ostream& operator<<(std::ostream& os, 48 const TaskShutdownBehavior& shutdown_behavior) { 49 os << TaskShutdownBehaviorToString(shutdown_behavior); 50 return os; 51 } 52 53 } // namespace base 54