| 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_MANAGEMENT_SAMPLING_TASK_GROUP_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ |
| 6 #define CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ | 6 #define CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 namespace task_management { | 26 namespace task_management { |
| 27 | 27 |
| 28 // Defines a group of tasks tracked by the task manager which belong to the same | 28 // Defines a group of tasks tracked by the task manager which belong to the same |
| 29 // process. This class lives on the UI thread. | 29 // process. This class lives on the UI thread. |
| 30 class TaskGroup { | 30 class TaskGroup { |
| 31 public: | 31 public: |
| 32 TaskGroup( | 32 TaskGroup( |
| 33 base::ProcessHandle proc_handle, | 33 base::ProcessHandle proc_handle, |
| 34 base::ProcessId proc_id, | 34 base::ProcessId proc_id, |
| 35 const base::Closure& on_background_calculations_done, |
| 35 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner); | 36 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner); |
| 36 ~TaskGroup(); | 37 ~TaskGroup(); |
| 37 | 38 |
| 38 // Adds and removes the given |task| to this group. |task| must be running on | 39 // Adds and removes the given |task| to this group. |task| must be running on |
| 39 // the same process represented by this group. | 40 // the same process represented by this group. |
| 40 void AddTask(Task* task); | 41 void AddTask(Task* task); |
| 41 void RemoveTask(Task* task); | 42 void RemoveTask(Task* task); |
| 42 | 43 |
| 43 void Refresh(const gpu::VideoMemoryUsageStats& gpu_memory_stats, | 44 void Refresh(const gpu::VideoMemoryUsageStats& gpu_memory_stats, |
| 44 base::TimeDelta update_interval, | 45 base::TimeDelta update_interval, |
| 45 int64_t refresh_flags); | 46 int64_t refresh_flags); |
| 46 | 47 |
| 47 // Appends the sorted IDs of the tasks that belong to this group to | 48 // Appends the sorted IDs of the tasks that belong to this group to |
| 48 // |out_list|. | 49 // |out_list|. |
| 49 void AppendSortedTaskIds(TaskIdList* out_list) const; | 50 void AppendSortedTaskIds(TaskIdList* out_list) const; |
| 50 | 51 |
| 51 Task* GetTaskById(TaskId task_id) const; | 52 Task* GetTaskById(TaskId task_id) const; |
| 52 | 53 |
| 54 // This is to be called after the task manager had informed its observers with |
| 55 // OnTasksRefreshedWithBackgroundCalculations() to begin another cycle for |
| 56 // this notification type. |
| 57 void ClearCurrentBackgroundCalculationsFlags(); |
| 58 |
| 59 // True if all enabled background operations calculating resource usage of the |
| 60 // process represented by this TaskGroup have completed. |
| 61 bool AreBackgroundCalculationsDone() const; |
| 62 |
| 53 const base::ProcessHandle& process_handle() const { return process_handle_; } | 63 const base::ProcessHandle& process_handle() const { return process_handle_; } |
| 54 const base::ProcessId& process_id() const { return process_id_; } | 64 const base::ProcessId& process_id() const { return process_id_; } |
| 55 | 65 |
| 56 size_t num_tasks() const { return tasks_.size(); } | 66 size_t num_tasks() const { return tasks_.size(); } |
| 57 bool empty() const { return tasks_.empty(); } | 67 bool empty() const { return tasks_.empty(); } |
| 58 | 68 |
| 59 double cpu_usage() const { return cpu_usage_; } | 69 double cpu_usage() const { return cpu_usage_; } |
| 60 int64_t private_bytes() const { return memory_usage_.private_bytes; } | 70 int64_t private_bytes() const { return memory_usage_.private_bytes; } |
| 61 int64_t shared_bytes() const { return memory_usage_.shared_bytes; } | 71 int64_t shared_bytes() const { return memory_usage_.shared_bytes; } |
| 62 int64_t physical_bytes() const { return memory_usage_.physical_bytes; } | 72 int64_t physical_bytes() const { return memory_usage_.physical_bytes; } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 void OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage); | 107 void OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage); |
| 98 | 108 |
| 99 void OnIdleWakeupsRefreshDone(int idle_wakeups_per_second); | 109 void OnIdleWakeupsRefreshDone(int idle_wakeups_per_second); |
| 100 | 110 |
| 101 #if defined(OS_LINUX) | 111 #if defined(OS_LINUX) |
| 102 void OnOpenFdCountRefreshDone(int open_fd_count); | 112 void OnOpenFdCountRefreshDone(int open_fd_count); |
| 103 #endif // defined(OS_LINUX) | 113 #endif // defined(OS_LINUX) |
| 104 | 114 |
| 105 void OnProcessPriorityDone(bool is_backgrounded); | 115 void OnProcessPriorityDone(bool is_backgrounded); |
| 106 | 116 |
| 117 void OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type); |
| 118 |
| 107 // The process' handle and ID. | 119 // The process' handle and ID. |
| 108 base::ProcessHandle process_handle_; | 120 base::ProcessHandle process_handle_; |
| 109 base::ProcessId process_id_; | 121 base::ProcessId process_id_; |
| 110 | 122 |
| 123 // This is a callback into the TaskManagerImpl to inform it that the |
| 124 // background calculations for this TaskGroup has finished. |
| 125 const base::Closure on_background_calculations_done_; |
| 126 |
| 111 scoped_refptr<TaskGroupSampler> worker_thread_sampler_; | 127 scoped_refptr<TaskGroupSampler> worker_thread_sampler_; |
| 112 | 128 |
| 113 // Maps the Tasks by their IDs. | 129 // Maps the Tasks by their IDs. |
| 114 // Tasks are not owned by the TaskGroup. They're owned by the TaskProviders. | 130 // Tasks are not owned by the TaskGroup. They're owned by the TaskProviders. |
| 115 std::map<TaskId, Task*> tasks_; | 131 std::map<TaskId, Task*> tasks_; |
| 116 | 132 |
| 133 // Flags will be used to determine when the background calculations has |
| 134 // completed for the enabled refresh types for this TaskGroup. |
| 135 int64_t expected_on_bg_done_flags_; |
| 136 int64_t current_on_bg_done_flags_; |
| 137 |
| 117 // The per process resources usages. | 138 // The per process resources usages. |
| 118 double cpu_usage_; | 139 double cpu_usage_; |
| 119 MemoryUsageStats memory_usage_; | 140 MemoryUsageStats memory_usage_; |
| 120 int64_t gpu_memory_; | 141 int64_t gpu_memory_; |
| 121 // The network usage in bytes per second as the sum of all network usages of | 142 // The network usage in bytes per second as the sum of all network usages of |
| 122 // the individual tasks sharing the same process. | 143 // the individual tasks sharing the same process. |
| 123 int64_t per_process_network_usage_; | 144 int64_t per_process_network_usage_; |
| 124 #if defined(OS_WIN) | 145 #if defined(OS_WIN) |
| 125 // Windows GDI and USER Handles. | 146 // Windows GDI and USER Handles. |
| 126 int64_t gdi_current_handles_; | 147 int64_t gdi_current_handles_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 143 // destroyed. | 164 // destroyed. |
| 144 base::WeakPtrFactory<TaskGroup> weak_ptr_factory_; | 165 base::WeakPtrFactory<TaskGroup> weak_ptr_factory_; |
| 145 | 166 |
| 146 DISALLOW_COPY_AND_ASSIGN(TaskGroup); | 167 DISALLOW_COPY_AND_ASSIGN(TaskGroup); |
| 147 }; | 168 }; |
| 148 | 169 |
| 149 } // namespace task_management | 170 } // namespace task_management |
| 150 | 171 |
| 151 | 172 |
| 152 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ | 173 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ |
| OLD | NEW |