| 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 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "base/process/process_handle.h" | 16 #include "base/process/process_handle.h" |
| 16 #include "base/process/process_metrics.h" | 17 #include "base/process/process_metrics.h" |
| 17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 18 #include "chrome/browser/task_management/providers/task.h" | 19 #include "chrome/browser/task_management/providers/task.h" |
| 19 #include "chrome/browser/task_management/sampling/task_group_sampler.h" | 20 #include "chrome/browser/task_management/sampling/task_group_sampler.h" |
| 20 #include "chrome/browser/task_management/task_manager_observer.h" | 21 #include "chrome/browser/task_management/task_manager_observer.h" |
| 21 | 22 |
| 22 namespace gpu { | 23 namespace gpu { |
| 23 struct VideoMemoryUsageStats; | 24 struct VideoMemoryUsageStats; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace task_management { | 27 namespace task_management { |
| 27 | 28 |
| 29 class SharedSampler; |
| 30 |
| 28 // Defines a group of tasks tracked by the task manager which belong to the same | 31 // Defines a group of tasks tracked by the task manager which belong to the same |
| 29 // process. This class lives on the UI thread. | 32 // process. This class lives on the UI thread. |
| 30 class TaskGroup { | 33 class TaskGroup { |
| 31 public: | 34 public: |
| 32 TaskGroup( | 35 TaskGroup( |
| 33 base::ProcessHandle proc_handle, | 36 base::ProcessHandle proc_handle, |
| 34 base::ProcessId proc_id, | 37 base::ProcessId proc_id, |
| 35 const base::Closure& on_background_calculations_done, | 38 const base::Closure& on_background_calculations_done, |
| 39 const scoped_refptr<SharedSampler> shared_sampler, |
| 36 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner); | 40 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner); |
| 37 ~TaskGroup(); | 41 ~TaskGroup(); |
| 38 | 42 |
| 39 // Adds and removes the given |task| to this group. |task| must be running on | 43 // Adds and removes the given |task| to this group. |task| must be running on |
| 40 // the same process represented by this group. | 44 // the same process represented by this group. |
| 41 void AddTask(Task* task); | 45 void AddTask(Task* task); |
| 42 void RemoveTask(Task* task); | 46 void RemoveTask(Task* task); |
| 43 | 47 |
| 44 void Refresh(const gpu::VideoMemoryUsageStats& gpu_memory_stats, | 48 void Refresh(const gpu::VideoMemoryUsageStats& gpu_memory_stats, |
| 45 base::TimeDelta update_interval, | 49 base::TimeDelta update_interval, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // The process' handle and ID. | 123 // The process' handle and ID. |
| 120 base::ProcessHandle process_handle_; | 124 base::ProcessHandle process_handle_; |
| 121 base::ProcessId process_id_; | 125 base::ProcessId process_id_; |
| 122 | 126 |
| 123 // This is a callback into the TaskManagerImpl to inform it that the | 127 // This is a callback into the TaskManagerImpl to inform it that the |
| 124 // background calculations for this TaskGroup has finished. | 128 // background calculations for this TaskGroup has finished. |
| 125 const base::Closure on_background_calculations_done_; | 129 const base::Closure on_background_calculations_done_; |
| 126 | 130 |
| 127 scoped_refptr<TaskGroupSampler> worker_thread_sampler_; | 131 scoped_refptr<TaskGroupSampler> worker_thread_sampler_; |
| 128 | 132 |
| 133 scoped_refptr<SharedSampler> shared_sampler_; |
| 134 |
| 129 // Lists the Tasks in this TaskGroup. | 135 // Lists the Tasks in this TaskGroup. |
| 130 // Tasks are not owned by the TaskGroup. They're owned by the TaskProviders. | 136 // Tasks are not owned by the TaskGroup. They're owned by the TaskProviders. |
| 131 std::vector<Task*> tasks_; | 137 std::vector<Task*> tasks_; |
| 132 | 138 |
| 133 // Flags will be used to determine when the background calculations has | 139 // Flags will be used to determine when the background calculations has |
| 134 // completed for the enabled refresh types for this TaskGroup. | 140 // completed for the enabled refresh types for this TaskGroup. |
| 135 int64_t expected_on_bg_done_flags_; | 141 int64_t expected_on_bg_done_flags_; |
| 136 int64_t current_on_bg_done_flags_; | 142 int64_t current_on_bg_done_flags_; |
| 137 | 143 |
| 138 // The per process resources usages. | 144 // The per process resources usages. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 164 // destroyed. | 170 // destroyed. |
| 165 base::WeakPtrFactory<TaskGroup> weak_ptr_factory_; | 171 base::WeakPtrFactory<TaskGroup> weak_ptr_factory_; |
| 166 | 172 |
| 167 DISALLOW_COPY_AND_ASSIGN(TaskGroup); | 173 DISALLOW_COPY_AND_ASSIGN(TaskGroup); |
| 168 }; | 174 }; |
| 169 | 175 |
| 170 } // namespace task_management | 176 } // namespace task_management |
| 171 | 177 |
| 172 | 178 |
| 173 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ | 179 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ |
| OLD | NEW |