xref: /aosp_15_r20/external/cronet/base/android/task_scheduler/task_traits_android.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2023 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_ANDROID_TASK_SCHEDULER_TASK_TRAITS_ANDROID_H_
6 #define BASE_ANDROID_TASK_SCHEDULER_TASK_TRAITS_ANDROID_H_
7 
8 // Enum for the TaskTraits types exposed to Java.
9 //
10 // A Java counterpart will be generated for this enum.
11 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.base.task
12 enum TaskTraits {
13   THREAD_POOL_TRAITS_START = 0,
14   // This task will only be scheduled when machine resources are available. Once
15   // running, it may be descheduled if higher priority work arrives (in this
16   // process or another) and its running on a non-critical thread. This is the
17   // lowest possible priority.
18   BEST_EFFORT = THREAD_POOL_TRAITS_START,
19   // This is a lowest-priority task which may block, for example non-urgent
20   // logging or deletion of temporary files as clean-up.
21   BEST_EFFORT_MAY_BLOCK = THREAD_POOL_TRAITS_START + 1,
22   // This task affects UI or responsiveness of future user interactions. It is
23   // not an immediate response to a user interaction. Most tasks are likely to
24   // have this priority.
25   // Examples:
26   // - Updating the UI to reflect progress on a long task.
27   // - Loading data that might be shown in the UI after a future user
28   //   interaction.
29   USER_VISIBLE = THREAD_POOL_TRAITS_START + 2,
30   // USER_VISIBLE + may block.
31   USER_VISIBLE_MAY_BLOCK = THREAD_POOL_TRAITS_START + 3,
32   // This task affects UI immediately after a user interaction.
33   // Example: Generating data shown in the UI immediately after a click.
34   USER_BLOCKING = THREAD_POOL_TRAITS_START + 4,
35   // USER_BLOCKING + may block.
36   USER_BLOCKING_MAY_BLOCK = THREAD_POOL_TRAITS_START + 5,
37   THREAD_POOL_TRAITS_END = USER_BLOCKING_MAY_BLOCK,
38   UI_TRAITS_START = THREAD_POOL_TRAITS_END + 1,
39   UI_BEST_EFFORT = UI_TRAITS_START,
40   UI_USER_VISIBLE = UI_TRAITS_START + 1,
41   UI_USER_BLOCKING = UI_TRAITS_START + 2,
42   UI_DEFAULT = UI_USER_VISIBLE,
43   UI_TRAITS_END = UI_USER_BLOCKING
44 };
45 
46 #endif  // BASE_ANDROID_TASK_SCHEDULER_TASK_TRAITS_ANDROID_H_
47