OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_OBSERVER_H_ |
6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_OBSERVER_H_ | 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_OBSERVER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 | 15 |
16 namespace task_manager { | 16 namespace task_manager { |
17 | 17 |
18 class TaskManagerInterface; | 18 class TaskManagerInterface; |
19 | 19 |
20 using TaskId = int64_t; | 20 using TaskId = int64_t; |
21 using TaskIdList = std::vector<TaskId>; | 21 using TaskIdList = std::vector<TaskId>; |
22 | 22 |
23 // Defines a list of types of resources that an observer needs to be refreshed | 23 // Defines a list of types of resources that an observer needs to be refreshed |
24 // on every task manager refresh cycle. | 24 // on every task manager refresh cycle. |
25 enum RefreshType { | 25 enum RefreshType { |
26 REFRESH_TYPE_NONE = 0, | 26 REFRESH_TYPE_NONE = 0, |
27 REFRESH_TYPE_CPU = 1, | 27 REFRESH_TYPE_CPU = 1, |
28 REFRESH_TYPE_PHYSICAL_MEMORY = 1 << 1, | 28 REFRESH_TYPE_PHYSICAL_MEMORY = 1 << 1, |
29 REFRESH_TYPE_MEMORY_DETAILS = 1 << 2, | 29 REFRESH_TYPE_MEMORY_DETAILS = 1 << 2, |
30 REFRESH_TYPE_GPU_MEMORY = 1 << 3, | 30 REFRESH_TYPE_GPU_MEMORY = 1 << 3, |
31 REFRESH_TYPE_V8_MEMORY = 1 << 4, | 31 REFRESH_TYPE_V8_MEMORY = 1 << 4, |
32 REFRESH_TYPE_SQLITE_MEMORY = 1 << 5, | 32 REFRESH_TYPE_SQLITE_MEMORY = 1 << 5, |
33 REFRESH_TYPE_WEBCACHE_STATS = 1 << 6, | 33 REFRESH_TYPE_WEBCACHE_STATS = 1 << 6, |
34 REFRESH_TYPE_NETWORK_USAGE = 1 << 7, | 34 REFRESH_TYPE_NETWORK_USAGE = 1 << 7, |
35 REFRESH_TYPE_NACL = 1 << 8, | 35 REFRESH_TYPE_NACL = 1 << 8, |
36 REFRESH_TYPE_IDLE_WAKEUPS = 1 << 9, | 36 REFRESH_TYPE_IDLE_WAKEUPS = 1 << 9, |
37 REFRESH_TYPE_HANDLES = 1 << 10, | 37 REFRESH_TYPE_HANDLES = 1 << 10, |
38 REFRESH_TYPE_START_TIME = 1 << 11, | 38 REFRESH_TYPE_START_TIME = 1 << 11, |
39 REFRESH_TYPE_CPU_TIME = 1 << 12, | 39 REFRESH_TYPE_CPU_TIME = 1 << 12, |
40 | 40 |
41 // Whether an observer is interested in knowing if a process is foregrounded | 41 // Whether an observer is interested in knowing if a process is foregrounded |
42 // or backgrounded. | 42 // or backgrounded. |
43 REFRESH_TYPE_PRIORITY = 1 << 13, | 43 REFRESH_TYPE_PRIORITY = 1 << 13, |
44 | 44 |
45 #if defined(OS_LINUX) | 45 #if defined(OS_LINUX) |
46 // For observers interested in getting the number of open file descriptors of | 46 // For observers interested in getting the number of open file descriptors of |
47 // processes. | 47 // processes. |
48 REFRESH_TYPE_FD_COUNT = 1 << 14, | 48 REFRESH_TYPE_FD_COUNT = 1 << 14, |
49 #endif // defined(OS_LINUX) | 49 #endif // defined(OS_LINUX) |
50 | 50 |
51 REFRESH_TYPE_MEMORY_STATE = 1 << 15, | 51 REFRESH_TYPE_MEMORY_STATE = 1 << 15, |
| 52 REFRESH_TYPE_KEEPALIVE_COUNT = 1 << 16, |
52 | 53 |
53 REFRESH_TYPE_MEMORY = REFRESH_TYPE_PHYSICAL_MEMORY | | 54 REFRESH_TYPE_MEMORY = |
54 REFRESH_TYPE_MEMORY_DETAILS, | 55 REFRESH_TYPE_PHYSICAL_MEMORY | REFRESH_TYPE_MEMORY_DETAILS, |
55 }; | 56 }; |
56 | 57 |
57 // Defines the interface for observers of the task manager. | 58 // Defines the interface for observers of the task manager. |
58 class TaskManagerObserver { | 59 class TaskManagerObserver { |
59 public: | 60 public: |
60 static bool IsResourceRefreshEnabled(RefreshType refresh_type, | 61 static bool IsResourceRefreshEnabled(RefreshType refresh_type, |
61 int refresh_flags); | 62 int refresh_flags); |
62 | 63 |
63 // Constructs a TaskManagerObserver given the minimum |refresh_time| that it | 64 // Constructs a TaskManagerObserver given the minimum |refresh_time| that it |
64 // it requires the task manager to be refreshing the values at, along with the | 65 // it requires the task manager to be refreshing the values at, along with the |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // calculated on each refresh. | 144 // calculated on each refresh. |
144 int64_t desired_resources_flags_; | 145 int64_t desired_resources_flags_; |
145 | 146 |
146 DISALLOW_COPY_AND_ASSIGN(TaskManagerObserver); | 147 DISALLOW_COPY_AND_ASSIGN(TaskManagerObserver); |
147 }; | 148 }; |
148 | 149 |
149 } // namespace task_manager | 150 } // namespace task_manager |
150 | 151 |
151 | 152 |
152 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_OBSERVER_H_ | 153 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_OBSERVER_H_ |
OLD | NEW |