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