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 #include "chrome/browser/task_management/sampling/task_manager_impl.h" | 5 #include "chrome/browser/task_management/sampling/task_manager_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "build/build_config.h" |
9 #include "chrome/browser/task_management/providers/browser_process_task_provider
.h" | 10 #include "chrome/browser/task_management/providers/browser_process_task_provider
.h" |
10 #include "chrome/browser/task_management/providers/child_process_task_provider.h
" | 11 #include "chrome/browser/task_management/providers/child_process_task_provider.h
" |
11 #include "chrome/browser/task_management/providers/web_contents/web_contents_tas
k_provider.h" | 12 #include "chrome/browser/task_management/providers/web_contents/web_contents_tas
k_provider.h" |
12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/gpu_data_manager.h" | 14 #include "content/public/browser/gpu_data_manager.h" |
14 | 15 |
15 #if defined(OS_CHROMEOS) | 16 #if defined(OS_CHROMEOS) |
16 #include "chrome/browser/task_management/providers/arc/arc_process_task_provider
.h" | 17 #include "chrome/browser/task_management/providers/arc/arc_process_task_provider
.h" |
17 #endif // defined(OS_CHROMEOS) | 18 #endif // defined(OS_CHROMEOS) |
18 | 19 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 69 } |
69 | 70 |
70 void TaskManagerImpl::ActivateTask(TaskId task_id) { | 71 void TaskManagerImpl::ActivateTask(TaskId task_id) { |
71 GetTaskByTaskId(task_id)->Activate(); | 72 GetTaskByTaskId(task_id)->Activate(); |
72 } | 73 } |
73 | 74 |
74 double TaskManagerImpl::GetCpuUsage(TaskId task_id) const { | 75 double TaskManagerImpl::GetCpuUsage(TaskId task_id) const { |
75 return GetTaskGroupByTaskId(task_id)->cpu_usage(); | 76 return GetTaskGroupByTaskId(task_id)->cpu_usage(); |
76 } | 77 } |
77 | 78 |
78 int64 TaskManagerImpl::GetPhysicalMemoryUsage(TaskId task_id) const { | 79 int64_t TaskManagerImpl::GetPhysicalMemoryUsage(TaskId task_id) const { |
79 return GetTaskGroupByTaskId(task_id)->physical_bytes(); | 80 return GetTaskGroupByTaskId(task_id)->physical_bytes(); |
80 } | 81 } |
81 | 82 |
82 int64 TaskManagerImpl::GetPrivateMemoryUsage(TaskId task_id) const { | 83 int64_t TaskManagerImpl::GetPrivateMemoryUsage(TaskId task_id) const { |
83 return GetTaskGroupByTaskId(task_id)->private_bytes(); | 84 return GetTaskGroupByTaskId(task_id)->private_bytes(); |
84 } | 85 } |
85 | 86 |
86 int64 TaskManagerImpl::GetSharedMemoryUsage(TaskId task_id) const { | 87 int64_t TaskManagerImpl::GetSharedMemoryUsage(TaskId task_id) const { |
87 return GetTaskGroupByTaskId(task_id)->shared_bytes(); | 88 return GetTaskGroupByTaskId(task_id)->shared_bytes(); |
88 } | 89 } |
89 | 90 |
90 int64 TaskManagerImpl::GetGpuMemoryUsage(TaskId task_id, | 91 int64_t TaskManagerImpl::GetGpuMemoryUsage(TaskId task_id, |
91 bool* has_duplicates) const { | 92 bool* has_duplicates) const { |
92 const TaskGroup* task_group = GetTaskGroupByTaskId(task_id); | 93 const TaskGroup* task_group = GetTaskGroupByTaskId(task_id); |
93 if (has_duplicates) | 94 if (has_duplicates) |
94 *has_duplicates = task_group->gpu_memory_has_duplicates(); | 95 *has_duplicates = task_group->gpu_memory_has_duplicates(); |
95 return task_group->gpu_memory(); | 96 return task_group->gpu_memory(); |
96 } | 97 } |
97 | 98 |
98 int TaskManagerImpl::GetIdleWakeupsPerSecond(TaskId task_id) const { | 99 int TaskManagerImpl::GetIdleWakeupsPerSecond(TaskId task_id) const { |
99 return GetTaskGroupByTaskId(task_id)->idle_wakeups_per_second(); | 100 return GetTaskGroupByTaskId(task_id)->idle_wakeups_per_second(); |
100 } | 101 } |
101 | 102 |
102 int TaskManagerImpl::GetNaClDebugStubPort(TaskId task_id) const { | 103 int TaskManagerImpl::GetNaClDebugStubPort(TaskId task_id) const { |
103 #if !defined(DISABLE_NACL) | 104 #if !defined(DISABLE_NACL) |
104 return GetTaskGroupByTaskId(task_id)->nacl_debug_stub_port(); | 105 return GetTaskGroupByTaskId(task_id)->nacl_debug_stub_port(); |
105 #else | 106 #else |
106 return -2; | 107 return -2; |
107 #endif // !defined(DISABLE_NACL) | 108 #endif // !defined(DISABLE_NACL) |
108 } | 109 } |
109 | 110 |
110 void TaskManagerImpl::GetGDIHandles(TaskId task_id, | 111 void TaskManagerImpl::GetGDIHandles(TaskId task_id, |
111 int64* current, | 112 int64_t* current, |
112 int64* peak) const { | 113 int64_t* peak) const { |
113 #if defined(OS_WIN) | 114 #if defined(OS_WIN) |
114 const TaskGroup* task_group = GetTaskGroupByTaskId(task_id); | 115 const TaskGroup* task_group = GetTaskGroupByTaskId(task_id); |
115 *current = task_group->gdi_current_handles(); | 116 *current = task_group->gdi_current_handles(); |
116 *peak = task_group->gdi_peak_handles(); | 117 *peak = task_group->gdi_peak_handles(); |
117 #else | 118 #else |
118 *current = -1; | 119 *current = -1; |
119 *peak = -1; | 120 *peak = -1; |
120 #endif // defined(OS_WIN) | 121 #endif // defined(OS_WIN) |
121 } | 122 } |
122 | 123 |
123 void TaskManagerImpl::GetUSERHandles(TaskId task_id, | 124 void TaskManagerImpl::GetUSERHandles(TaskId task_id, |
124 int64* current, | 125 int64_t* current, |
125 int64* peak) const { | 126 int64_t* peak) const { |
126 #if defined(OS_WIN) | 127 #if defined(OS_WIN) |
127 const TaskGroup* task_group = GetTaskGroupByTaskId(task_id); | 128 const TaskGroup* task_group = GetTaskGroupByTaskId(task_id); |
128 *current = task_group->user_current_handles(); | 129 *current = task_group->user_current_handles(); |
129 *peak = task_group->user_peak_handles(); | 130 *peak = task_group->user_peak_handles(); |
130 #else | 131 #else |
131 *current = -1; | 132 *current = -1; |
132 *peak = -1; | 133 *peak = -1; |
133 #endif // defined(OS_WIN) | 134 #endif // defined(OS_WIN) |
134 } | 135 } |
135 | 136 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 168 } |
168 | 169 |
169 const base::ProcessId& TaskManagerImpl::GetProcessId(TaskId task_id) const { | 170 const base::ProcessId& TaskManagerImpl::GetProcessId(TaskId task_id) const { |
170 return GetTaskGroupByTaskId(task_id)->process_id(); | 171 return GetTaskGroupByTaskId(task_id)->process_id(); |
171 } | 172 } |
172 | 173 |
173 Task::Type TaskManagerImpl::GetType(TaskId task_id) const { | 174 Task::Type TaskManagerImpl::GetType(TaskId task_id) const { |
174 return GetTaskByTaskId(task_id)->GetType(); | 175 return GetTaskByTaskId(task_id)->GetType(); |
175 } | 176 } |
176 | 177 |
177 int64 TaskManagerImpl::GetNetworkUsage(TaskId task_id) const { | 178 int64_t TaskManagerImpl::GetNetworkUsage(TaskId task_id) const { |
178 return GetTaskByTaskId(task_id)->network_usage(); | 179 return GetTaskByTaskId(task_id)->network_usage(); |
179 } | 180 } |
180 | 181 |
181 int64 TaskManagerImpl::GetProcessTotalNetworkUsage(TaskId task_id) const { | 182 int64_t TaskManagerImpl::GetProcessTotalNetworkUsage(TaskId task_id) const { |
182 return GetTaskGroupByTaskId(task_id)->per_process_network_usage(); | 183 return GetTaskGroupByTaskId(task_id)->per_process_network_usage(); |
183 } | 184 } |
184 | 185 |
185 int64 TaskManagerImpl::GetSqliteMemoryUsed(TaskId task_id) const { | 186 int64_t TaskManagerImpl::GetSqliteMemoryUsed(TaskId task_id) const { |
186 return GetTaskByTaskId(task_id)->GetSqliteMemoryUsed(); | 187 return GetTaskByTaskId(task_id)->GetSqliteMemoryUsed(); |
187 } | 188 } |
188 | 189 |
189 bool TaskManagerImpl::GetV8Memory(TaskId task_id, | 190 bool TaskManagerImpl::GetV8Memory(TaskId task_id, |
190 int64* allocated, | 191 int64_t* allocated, |
191 int64* used) const { | 192 int64_t* used) const { |
192 const Task* task = GetTaskByTaskId(task_id); | 193 const Task* task = GetTaskByTaskId(task_id); |
193 if (!task->ReportsV8Memory()) | 194 if (!task->ReportsV8Memory()) |
194 return false; | 195 return false; |
195 | 196 |
196 *allocated = task->GetV8MemoryAllocated(); | 197 *allocated = task->GetV8MemoryAllocated(); |
197 *used = task->GetV8MemoryUsed(); | 198 *used = task->GetV8MemoryUsed(); |
198 | 199 |
199 return true; | 200 return true; |
200 } | 201 } |
201 | 202 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 DCHECK(ContainsKey(task_groups_by_task_id_, task_id)); | 385 DCHECK(ContainsKey(task_groups_by_task_id_, task_id)); |
385 | 386 |
386 return task_groups_by_task_id_.at(task_id); | 387 return task_groups_by_task_id_.at(task_id); |
387 } | 388 } |
388 | 389 |
389 Task* TaskManagerImpl::GetTaskByTaskId(TaskId task_id) const { | 390 Task* TaskManagerImpl::GetTaskByTaskId(TaskId task_id) const { |
390 return GetTaskGroupByTaskId(task_id)->GetTaskById(task_id); | 391 return GetTaskGroupByTaskId(task_id)->GetTaskById(task_id); |
391 } | 392 } |
392 | 393 |
393 } // namespace task_management | 394 } // namespace task_management |
OLD | NEW |