1 // Copyright 2017 The Chromium Authors 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_THREAD_POOL_ENVIRONMENT_CONFIG_H_ 6 #define BASE_TASK_THREAD_POOL_ENVIRONMENT_CONFIG_H_ 7 8 #include <stddef.h> 9 10 #include "base/base_export.h" 11 #include "base/task/task_traits.h" 12 #include "base/threading/thread.h" 13 14 namespace base { 15 namespace internal { 16 17 // TODO(etiennep): This is now specific to 18 // PooledSingleThreadTaskRunnerManager, move it there. 19 enum EnvironmentType { 20 FOREGROUND = 0, 21 FOREGROUND_BLOCKING, 22 UTILITY, 23 UTILITY_BLOCKING, 24 BACKGROUND, 25 BACKGROUND_BLOCKING, 26 ENVIRONMENT_COUNT // Always last. 27 }; 28 29 // Order must match the EnvironmentType enum. 30 struct EnvironmentParams { 31 // The threads and histograms of this environment will be labeled with 32 // the thread pool name concatenated to this. 33 const char* name_suffix; 34 35 // Preferred type for threads in this environment; the actual thread type 36 // depends on shutdown state and platform capabilities. 37 ThreadType thread_type_hint; 38 }; 39 40 constexpr EnvironmentParams kEnvironmentParams[] = { 41 {"Foreground", base::ThreadType::kDefault}, 42 {"ForegroundBlocking", base::ThreadType::kDefault}, 43 {"Utility", base::ThreadType::kUtility}, 44 {"UtilityBlocking", base::ThreadType::kUtility}, 45 {"Background", base::ThreadType::kBackground}, 46 {"BackgroundBlocking", base::ThreadType::kBackground}, 47 }; 48 49 // Returns true if this platform supports having WorkerThreads running with a 50 // background thread type. 51 bool BASE_EXPORT CanUseBackgroundThreadTypeForWorkerThread(); 52 53 // Returns true if this platform supports having WorkerThreads running with a 54 // utility thread type. 55 bool BASE_EXPORT CanUseUtilityThreadTypeForWorkerThread(); 56 57 } // namespace internal 58 } // namespace base 59 60 #endif // BASE_TASK_THREAD_POOL_ENVIRONMENT_CONFIG_H_ 61