| 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 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 namespace task_management { | 23 namespace task_management { |
| 24 | 24 |
| 25 // Defines a group of tasks tracked by the task manager which belong to the same | 25 // Defines a group of tasks tracked by the task manager which belong to the same |
| 26 // process. This class lives on the UI thread. | 26 // process. This class lives on the UI thread. |
| 27 class TaskGroup { | 27 class TaskGroup { |
| 28 public: | 28 public: |
| 29 TaskGroup( | 29 TaskGroup( |
| 30 base::ProcessHandle proc_handle, | 30 base::ProcessHandle proc_handle, |
| 31 base::ProcessId proc_id, | 31 base::ProcessId proc_id, |
| 32 const base::Closure& on_background_calculations_done, |
| 32 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner); | 33 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner); |
| 33 ~TaskGroup(); | 34 ~TaskGroup(); |
| 34 | 35 |
| 35 // Adds and removes the given |task| to this group. |task| must be running on | 36 // Adds and removes the given |task| to this group. |task| must be running on |
| 36 // the same process represented by this group. | 37 // the same process represented by this group. |
| 37 void AddTask(Task* task); | 38 void AddTask(Task* task); |
| 38 void RemoveTask(Task* task); | 39 void RemoveTask(Task* task); |
| 39 | 40 |
| 40 void Refresh(const content::GPUVideoMemoryUsageStats& gpu_memory_stats, | 41 void Refresh(const content::GPUVideoMemoryUsageStats& gpu_memory_stats, |
| 41 base::TimeDelta update_interval, | 42 base::TimeDelta update_interval, |
| 42 int64_t refresh_flags); | 43 int64_t refresh_flags); |
| 43 | 44 |
| 44 // Appends the sorted IDs of the tasks that belong to this group to | 45 // Appends the sorted IDs of the tasks that belong to this group to |
| 45 // |out_list|. | 46 // |out_list|. |
| 46 void AppendSortedTaskIds(TaskIdList* out_list) const; | 47 void AppendSortedTaskIds(TaskIdList* out_list) const; |
| 47 | 48 |
| 48 Task* GetTaskById(TaskId task_id) const; | 49 Task* GetTaskById(TaskId task_id) const; |
| 49 | 50 |
| 51 // This is to be called after the task manager had informed its observers with |
| 52 // OnTasksRefreshedWithBackgroundCalculations() to begin another cycle for |
| 53 // this notification type. |
| 54 void ClearCurrentBackgroundCalculationsFlags() { |
| 55 current_on_bg_done_flags_ = 0; |
| 56 } |
| 57 |
| 58 bool AreBackgroundCalculationsDone() const { |
| 59 return expected_on_bg_done_flags_ == current_on_bg_done_flags_; |
| 60 } |
| 61 |
| 50 const base::ProcessHandle& process_handle() const { return process_handle_; } | 62 const base::ProcessHandle& process_handle() const { return process_handle_; } |
| 51 const base::ProcessId& process_id() const { return process_id_; } | 63 const base::ProcessId& process_id() const { return process_id_; } |
| 52 | 64 |
| 53 size_t num_tasks() const { return tasks_.size(); } | 65 size_t num_tasks() const { return tasks_.size(); } |
| 54 bool empty() const { return tasks_.empty(); } | 66 bool empty() const { return tasks_.empty(); } |
| 55 | 67 |
| 56 double cpu_usage() const { return cpu_usage_; } | 68 double cpu_usage() const { return cpu_usage_; } |
| 57 int64_t private_bytes() const { return memory_usage_.private_bytes; } | 69 int64_t private_bytes() const { return memory_usage_.private_bytes; } |
| 58 int64_t shared_bytes() const { return memory_usage_.shared_bytes; } | 70 int64_t shared_bytes() const { return memory_usage_.shared_bytes; } |
| 59 int64_t physical_bytes() const { return memory_usage_.physical_bytes; } | 71 int64_t physical_bytes() const { return memory_usage_.physical_bytes; } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 void OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage); | 107 void OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage); |
| 96 | 108 |
| 97 void OnIdleWakeupsRefreshDone(int idle_wakeups_per_second); | 109 void OnIdleWakeupsRefreshDone(int idle_wakeups_per_second); |
| 98 | 110 |
| 99 #if defined(OS_LINUX) | 111 #if defined(OS_LINUX) |
| 100 void OnOpenFdCountRefreshDone(int open_fd_count); | 112 void OnOpenFdCountRefreshDone(int open_fd_count); |
| 101 #endif // defined(OS_LINUX) | 113 #endif // defined(OS_LINUX) |
| 102 | 114 |
| 103 void OnProcessPriorityDone(bool is_backgrounded); | 115 void OnProcessPriorityDone(bool is_backgrounded); |
| 104 | 116 |
| 117 void OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type); |
| 118 |
| 105 // The process' handle and ID. | 119 // The process' handle and ID. |
| 106 base::ProcessHandle process_handle_; | 120 base::ProcessHandle process_handle_; |
| 107 base::ProcessId process_id_; | 121 base::ProcessId process_id_; |
| 108 | 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 |
| 109 scoped_refptr<TaskGroupSampler> worker_thread_sampler_; | 127 scoped_refptr<TaskGroupSampler> worker_thread_sampler_; |
| 110 | 128 |
| 111 // Maps the Tasks by their IDs. | 129 // Maps the Tasks by their IDs. |
| 112 // 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. |
| 113 std::map<TaskId, Task*> tasks_; | 131 std::map<TaskId, Task*> tasks_; |
| 114 | 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 |
| 115 // The per process resources usages. | 138 // The per process resources usages. |
| 116 double cpu_usage_; | 139 double cpu_usage_; |
| 117 MemoryUsageStats memory_usage_; | 140 MemoryUsageStats memory_usage_; |
| 118 int64_t gpu_memory_; | 141 int64_t gpu_memory_; |
| 119 // 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 |
| 120 // the individual tasks sharing the same process. | 143 // the individual tasks sharing the same process. |
| 121 int64_t per_process_network_usage_; | 144 int64_t per_process_network_usage_; |
| 122 #if defined(OS_WIN) | 145 #if defined(OS_WIN) |
| 123 // Windows GDI and USER Handles. | 146 // Windows GDI and USER Handles. |
| 124 int64_t gdi_current_handles_; | 147 int64_t gdi_current_handles_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 141 // destroyed. | 164 // destroyed. |
| 142 base::WeakPtrFactory<TaskGroup> weak_ptr_factory_; | 165 base::WeakPtrFactory<TaskGroup> weak_ptr_factory_; |
| 143 | 166 |
| 144 DISALLOW_COPY_AND_ASSIGN(TaskGroup); | 167 DISALLOW_COPY_AND_ASSIGN(TaskGroup); |
| 145 }; | 168 }; |
| 146 | 169 |
| 147 } // namespace task_management | 170 } // namespace task_management |
| 148 | 171 |
| 149 | 172 |
| 150 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ | 173 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ |
| OLD | NEW |