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> |
| 9 #include <stdint.h> |
| 10 |
8 #include <map> | 11 #include <map> |
9 | 12 |
| 13 #include "base/macros.h" |
10 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
11 #include "base/process/process_handle.h" | 15 #include "base/process/process_handle.h" |
12 #include "base/process/process_metrics.h" | 16 #include "base/process/process_metrics.h" |
| 17 #include "build/build_config.h" |
13 #include "chrome/browser/task_management/providers/task.h" | 18 #include "chrome/browser/task_management/providers/task.h" |
14 #include "chrome/browser/task_management/sampling/task_group_sampler.h" | 19 #include "chrome/browser/task_management/sampling/task_group_sampler.h" |
15 #include "chrome/browser/task_management/task_manager_observer.h" | 20 #include "chrome/browser/task_management/task_manager_observer.h" |
16 #include "content/public/common/gpu_memory_stats.h" | 21 #include "content/public/common/gpu_memory_stats.h" |
17 | 22 |
18 namespace task_management { | 23 namespace task_management { |
19 | 24 |
20 // 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 |
21 // process. This class lives on the UI thread. | 26 // process. This class lives on the UI thread. |
22 class TaskGroup { | 27 class TaskGroup { |
23 public: | 28 public: |
24 TaskGroup( | 29 TaskGroup( |
25 base::ProcessHandle proc_handle, | 30 base::ProcessHandle proc_handle, |
26 base::ProcessId proc_id, | 31 base::ProcessId proc_id, |
27 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner); | 32 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner); |
28 ~TaskGroup(); | 33 ~TaskGroup(); |
29 | 34 |
30 // 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 |
31 // the same process represented by this group. | 36 // the same process represented by this group. |
32 void AddTask(Task* task); | 37 void AddTask(Task* task); |
33 void RemoveTask(Task* task); | 38 void RemoveTask(Task* task); |
34 | 39 |
35 void Refresh(const content::GPUVideoMemoryUsageStats& gpu_memory_stats, | 40 void Refresh(const content::GPUVideoMemoryUsageStats& gpu_memory_stats, |
36 base::TimeDelta update_interval, | 41 base::TimeDelta update_interval, |
37 int64 refresh_flags); | 42 int64_t refresh_flags); |
38 | 43 |
39 // 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 |
40 // |out_list|. | 45 // |out_list|. |
41 void AppendSortedTaskIds(TaskIdList* out_list) const; | 46 void AppendSortedTaskIds(TaskIdList* out_list) const; |
42 | 47 |
43 Task* GetTaskById(TaskId task_id) const; | 48 Task* GetTaskById(TaskId task_id) const; |
44 | 49 |
45 const base::ProcessHandle& process_handle() const { return process_handle_; } | 50 const base::ProcessHandle& process_handle() const { return process_handle_; } |
46 const base::ProcessId& process_id() const { return process_id_; } | 51 const base::ProcessId& process_id() const { return process_id_; } |
47 | 52 |
48 size_t num_tasks() const { return tasks_.size(); } | 53 size_t num_tasks() const { return tasks_.size(); } |
49 bool empty() const { return tasks_.empty(); } | 54 bool empty() const { return tasks_.empty(); } |
50 | 55 |
51 double cpu_usage() const { return cpu_usage_; } | 56 double cpu_usage() const { return cpu_usage_; } |
52 int64 private_bytes() const { return memory_usage_.private_bytes; } | 57 int64_t private_bytes() const { return memory_usage_.private_bytes; } |
53 int64 shared_bytes() const { return memory_usage_.shared_bytes; } | 58 int64_t shared_bytes() const { return memory_usage_.shared_bytes; } |
54 int64 physical_bytes() const { return memory_usage_.physical_bytes; } | 59 int64_t physical_bytes() const { return memory_usage_.physical_bytes; } |
55 int64 gpu_memory() const { return gpu_memory_; } | 60 int64_t gpu_memory() const { return gpu_memory_; } |
56 bool gpu_memory_has_duplicates() const { return gpu_memory_has_duplicates_; } | 61 bool gpu_memory_has_duplicates() const { return gpu_memory_has_duplicates_; } |
57 int64 per_process_network_usage() const { return per_process_network_usage_; } | 62 int64_t per_process_network_usage() const { |
| 63 return per_process_network_usage_; |
| 64 } |
58 bool is_backgrounded() const { return is_backgrounded_; } | 65 bool is_backgrounded() const { return is_backgrounded_; } |
59 | 66 |
60 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
61 int64 gdi_current_handles() const { return gdi_current_handles_; } | 68 int64_t gdi_current_handles() const { return gdi_current_handles_; } |
62 int64 gdi_peak_handles() const { return gdi_peak_handles_; } | 69 int64_t gdi_peak_handles() const { return gdi_peak_handles_; } |
63 int64 user_current_handles() const { return user_current_handles_; } | 70 int64_t user_current_handles() const { return user_current_handles_; } |
64 int64 user_peak_handles() const { return user_peak_handles_; } | 71 int64_t user_peak_handles() const { return user_peak_handles_; } |
65 #endif // defined(OS_WIN) | 72 #endif // defined(OS_WIN) |
66 | 73 |
67 #if !defined(DISABLE_NACL) | 74 #if !defined(DISABLE_NACL) |
68 int nacl_debug_stub_port() const { return nacl_debug_stub_port_; } | 75 int nacl_debug_stub_port() const { return nacl_debug_stub_port_; } |
69 #endif // !defined(DISABLE_NACL) | 76 #endif // !defined(DISABLE_NACL) |
70 | 77 |
71 #if defined(OS_LINUX) | 78 #if defined(OS_LINUX) |
72 int open_fd_count() const { return open_fd_count_; } | 79 int open_fd_count() const { return open_fd_count_; } |
73 #endif // defined(OS_LINUX) | 80 #endif // defined(OS_LINUX) |
74 | 81 |
(...skipping 26 matching lines...) Expand all Loading... |
101 | 108 |
102 scoped_refptr<TaskGroupSampler> worker_thread_sampler_; | 109 scoped_refptr<TaskGroupSampler> worker_thread_sampler_; |
103 | 110 |
104 // Maps the Tasks by their IDs. | 111 // Maps the Tasks by their IDs. |
105 // Tasks are not owned by the TaskGroup. They're owned by the TaskProviders. | 112 // Tasks are not owned by the TaskGroup. They're owned by the TaskProviders. |
106 std::map<TaskId, Task*> tasks_; | 113 std::map<TaskId, Task*> tasks_; |
107 | 114 |
108 // The per process resources usages. | 115 // The per process resources usages. |
109 double cpu_usage_; | 116 double cpu_usage_; |
110 MemoryUsageStats memory_usage_; | 117 MemoryUsageStats memory_usage_; |
111 int64 gpu_memory_; | 118 int64_t gpu_memory_; |
112 // The network usage in bytes per second as the sum of all network usages of | 119 // The network usage in bytes per second as the sum of all network usages of |
113 // the individual tasks sharing the same process. | 120 // the individual tasks sharing the same process. |
114 int64 per_process_network_usage_; | 121 int64_t per_process_network_usage_; |
115 #if defined(OS_WIN) | 122 #if defined(OS_WIN) |
116 // Windows GDI and USER Handles. | 123 // Windows GDI and USER Handles. |
117 int64 gdi_current_handles_; | 124 int64_t gdi_current_handles_; |
118 int64 gdi_peak_handles_; | 125 int64_t gdi_peak_handles_; |
119 int64 user_current_handles_; | 126 int64_t user_current_handles_; |
120 int64 user_peak_handles_; | 127 int64_t user_peak_handles_; |
121 #endif // defined(OS_WIN) | 128 #endif // defined(OS_WIN) |
122 #if !defined(DISABLE_NACL) | 129 #if !defined(DISABLE_NACL) |
123 int nacl_debug_stub_port_; | 130 int nacl_debug_stub_port_; |
124 #endif // !defined(DISABLE_NACL) | 131 #endif // !defined(DISABLE_NACL) |
125 int idle_wakeups_per_second_; | 132 int idle_wakeups_per_second_; |
126 #if defined(OS_LINUX) | 133 #if defined(OS_LINUX) |
127 // The number of file descriptors currently open by the process. | 134 // The number of file descriptors currently open by the process. |
128 int open_fd_count_; | 135 int open_fd_count_; |
129 #endif // defined(OS_LINUX) | 136 #endif // defined(OS_LINUX) |
130 bool gpu_memory_has_duplicates_; | 137 bool gpu_memory_has_duplicates_; |
131 bool is_backgrounded_; | 138 bool is_backgrounded_; |
132 | 139 |
133 // Always keep this the last member of this class so that it's the first to be | 140 // Always keep this the last member of this class so that it's the first to be |
134 // destroyed. | 141 // destroyed. |
135 base::WeakPtrFactory<TaskGroup> weak_ptr_factory_; | 142 base::WeakPtrFactory<TaskGroup> weak_ptr_factory_; |
136 | 143 |
137 DISALLOW_COPY_AND_ASSIGN(TaskGroup); | 144 DISALLOW_COPY_AND_ASSIGN(TaskGroup); |
138 }; | 145 }; |
139 | 146 |
140 } // namespace task_management | 147 } // namespace task_management |
141 | 148 |
142 | 149 |
143 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ | 150 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ |
OLD | NEW |