| 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 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/process/process_handle.h" | 15 #include "base/process/process_handle.h" |
| 16 #include "base/process/process_metrics.h" | 16 #include "base/process/process_metrics.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "chrome/browser/task_management/providers/task.h" | 18 #include "chrome/browser/task_management/providers/task.h" |
| 19 #include "chrome/browser/task_management/sampling/task_group_sampler.h" | 19 #include "chrome/browser/task_management/sampling/task_group_sampler.h" |
| 20 #include "chrome/browser/task_management/task_manager_observer.h" | 20 #include "chrome/browser/task_management/task_manager_observer.h" |
| 21 | 21 #include "content/public/common/gpu_memory_stats.h" |
| 22 namespace gpu { | |
| 23 struct VideoMemoryUsageStats; | |
| 24 } | |
| 25 | 22 |
| 26 namespace task_management { | 23 namespace task_management { |
| 27 | 24 |
| 28 // 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 |
| 29 // process. This class lives on the UI thread. | 26 // process. This class lives on the UI thread. |
| 30 class TaskGroup { | 27 class TaskGroup { |
| 31 public: | 28 public: |
| 32 TaskGroup( | 29 TaskGroup( |
| 33 base::ProcessHandle proc_handle, | 30 base::ProcessHandle proc_handle, |
| 34 base::ProcessId proc_id, | 31 base::ProcessId proc_id, |
| 35 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner); | 32 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner); |
| 36 ~TaskGroup(); | 33 ~TaskGroup(); |
| 37 | 34 |
| 38 // Adds and removes the given |task| to this group. |task| must be running on | 35 // Adds and removes the given |task| to this group. |task| must be running on |
| 39 // the same process represented by this group. | 36 // the same process represented by this group. |
| 40 void AddTask(Task* task); | 37 void AddTask(Task* task); |
| 41 void RemoveTask(Task* task); | 38 void RemoveTask(Task* task); |
| 42 | 39 |
| 43 void Refresh(const gpu::VideoMemoryUsageStats& gpu_memory_stats, | 40 void Refresh(const content::GPUVideoMemoryUsageStats& gpu_memory_stats, |
| 44 base::TimeDelta update_interval, | 41 base::TimeDelta update_interval, |
| 45 int64_t refresh_flags); | 42 int64_t refresh_flags); |
| 46 | 43 |
| 47 // Appends the sorted IDs of the tasks that belong to this group to | 44 // Appends the sorted IDs of the tasks that belong to this group to |
| 48 // |out_list|. | 45 // |out_list|. |
| 49 void AppendSortedTaskIds(TaskIdList* out_list) const; | 46 void AppendSortedTaskIds(TaskIdList* out_list) const; |
| 50 | 47 |
| 51 Task* GetTaskById(TaskId task_id) const; | 48 Task* GetTaskById(TaskId task_id) const; |
| 52 | 49 |
| 53 const base::ProcessHandle& process_handle() const { return process_handle_; } | 50 const base::ProcessHandle& process_handle() const { return process_handle_; } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 78 int nacl_debug_stub_port() const { return nacl_debug_stub_port_; } | 75 int nacl_debug_stub_port() const { return nacl_debug_stub_port_; } |
| 79 #endif // !defined(DISABLE_NACL) | 76 #endif // !defined(DISABLE_NACL) |
| 80 | 77 |
| 81 #if defined(OS_LINUX) | 78 #if defined(OS_LINUX) |
| 82 int open_fd_count() const { return open_fd_count_; } | 79 int open_fd_count() const { return open_fd_count_; } |
| 83 #endif // defined(OS_LINUX) | 80 #endif // defined(OS_LINUX) |
| 84 | 81 |
| 85 int idle_wakeups_per_second() const { return idle_wakeups_per_second_; } | 82 int idle_wakeups_per_second() const { return idle_wakeups_per_second_; } |
| 86 | 83 |
| 87 private: | 84 private: |
| 88 void RefreshGpuMemory(const gpu::VideoMemoryUsageStats& gpu_memory_stats); | 85 void RefreshGpuMemory( |
| 86 const content::GPUVideoMemoryUsageStats& gpu_memory_stats); |
| 89 | 87 |
| 90 void RefreshWindowsHandles(); | 88 void RefreshWindowsHandles(); |
| 91 | 89 |
| 92 // |child_process_unique_id| see Task::GetChildProcessUniqueID(). | 90 // |child_process_unique_id| see Task::GetChildProcessUniqueID(). |
| 93 void RefreshNaClDebugStubPort(int child_process_unique_id); | 91 void RefreshNaClDebugStubPort(int child_process_unique_id); |
| 94 | 92 |
| 95 void OnCpuRefreshDone(double cpu_usage); | 93 void OnCpuRefreshDone(double cpu_usage); |
| 96 | 94 |
| 97 void OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage); | 95 void OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage); |
| 98 | 96 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // destroyed. | 141 // destroyed. |
| 144 base::WeakPtrFactory<TaskGroup> weak_ptr_factory_; | 142 base::WeakPtrFactory<TaskGroup> weak_ptr_factory_; |
| 145 | 143 |
| 146 DISALLOW_COPY_AND_ASSIGN(TaskGroup); | 144 DISALLOW_COPY_AND_ASSIGN(TaskGroup); |
| 147 }; | 145 }; |
| 148 | 146 |
| 149 } // namespace task_management | 147 } // namespace task_management |
| 150 | 148 |
| 151 | 149 |
| 152 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ | 150 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ |
| OLD | NEW |