| 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 "build/build_config.h" |
| 10 #include "chrome/browser/task_management/providers/browser_process_task_provider
.h" | 10 #include "chrome/browser/task_management/providers/browser_process_task_provider
.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 172 } |
| 173 | 173 |
| 174 const base::ProcessId& TaskManagerImpl::GetProcessId(TaskId task_id) const { | 174 const base::ProcessId& TaskManagerImpl::GetProcessId(TaskId task_id) const { |
| 175 return GetTaskGroupByTaskId(task_id)->process_id(); | 175 return GetTaskGroupByTaskId(task_id)->process_id(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 Task::Type TaskManagerImpl::GetType(TaskId task_id) const { | 178 Task::Type TaskManagerImpl::GetType(TaskId task_id) const { |
| 179 return GetTaskByTaskId(task_id)->GetType(); | 179 return GetTaskByTaskId(task_id)->GetType(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 int TaskManagerImpl::GetTabId(TaskId task_id) const { |
| 183 return GetTaskByTaskId(task_id)->GetTabId(); |
| 184 } |
| 185 |
| 186 int TaskManagerImpl::GetChildProcessUniqueId(TaskId task_id) const { |
| 187 return GetTaskByTaskId(task_id)->GetChildProcessUniqueID(); |
| 188 } |
| 189 |
| 190 void TaskManagerImpl::GetTerminationStatus(TaskId task_id, |
| 191 base::TerminationStatus* out_status, |
| 192 int* out_error_code) const { |
| 193 GetTaskByTaskId(task_id)->GetTerminationStatus(out_status, out_error_code); |
| 194 } |
| 195 |
| 182 int64_t TaskManagerImpl::GetNetworkUsage(TaskId task_id) const { | 196 int64_t TaskManagerImpl::GetNetworkUsage(TaskId task_id) const { |
| 183 return GetTaskByTaskId(task_id)->network_usage(); | 197 return GetTaskByTaskId(task_id)->network_usage(); |
| 184 } | 198 } |
| 185 | 199 |
| 186 int64_t TaskManagerImpl::GetProcessTotalNetworkUsage(TaskId task_id) const { | 200 int64_t TaskManagerImpl::GetProcessTotalNetworkUsage(TaskId task_id) const { |
| 187 return GetTaskGroupByTaskId(task_id)->per_process_network_usage(); | 201 return GetTaskGroupByTaskId(task_id)->per_process_network_usage(); |
| 188 } | 202 } |
| 189 | 203 |
| 190 int64_t TaskManagerImpl::GetSqliteMemoryUsed(TaskId task_id) const { | 204 int64_t TaskManagerImpl::GetSqliteMemoryUsed(TaskId task_id) const { |
| 191 return GetTaskByTaskId(task_id)->GetSqliteMemoryUsed(); | 205 return GetTaskByTaskId(task_id)->GetSqliteMemoryUsed(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 if (groups_pair.second == browser_group) | 247 if (groups_pair.second == browser_group) |
| 234 continue; | 248 continue; |
| 235 | 249 |
| 236 groups_pair.second->AppendSortedTaskIds(&sorted_task_ids_); | 250 groups_pair.second->AppendSortedTaskIds(&sorted_task_ids_); |
| 237 } | 251 } |
| 238 } | 252 } |
| 239 | 253 |
| 240 return sorted_task_ids_; | 254 return sorted_task_ids_; |
| 241 } | 255 } |
| 242 | 256 |
| 257 TaskIdList TaskManagerImpl::GetIdsOfTasksSharingSameProcess( |
| 258 TaskId task_id) const { |
| 259 DCHECK(is_running_) << "Task manager is not running. You must observe the " |
| 260 "task manager for it to start running"; |
| 261 |
| 262 TaskIdList result; |
| 263 GetTaskGroupByTaskId(task_id)->AppendSortedTaskIds(&result); |
| 264 return result; |
| 265 } |
| 266 |
| 243 size_t TaskManagerImpl::GetNumberOfTasksOnSameProcess(TaskId task_id) const { | 267 size_t TaskManagerImpl::GetNumberOfTasksOnSameProcess(TaskId task_id) const { |
| 244 return GetTaskGroupByTaskId(task_id)->num_tasks(); | 268 return GetTaskGroupByTaskId(task_id)->num_tasks(); |
| 245 } | 269 } |
| 246 | 270 |
| 247 void TaskManagerImpl::TaskAdded(Task* task) { | 271 void TaskManagerImpl::TaskAdded(Task* task) { |
| 248 DCHECK(task); | 272 DCHECK(task); |
| 249 | 273 |
| 250 TaskGroup* task_group = nullptr; | 274 TaskGroup* task_group = nullptr; |
| 251 const base::ProcessId proc_id = task->process_id(); | 275 const base::ProcessId proc_id = task->process_id(); |
| 252 const TaskId task_id = task->task_id(); | 276 const TaskId task_id = task->task_id(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 313 |
| 290 // Invalidate the cached sorted IDs by clearing the list. | 314 // Invalidate the cached sorted IDs by clearing the list. |
| 291 sorted_task_ids_.clear(); | 315 sorted_task_ids_.clear(); |
| 292 | 316 |
| 293 if (task_group->empty()) { | 317 if (task_group->empty()) { |
| 294 task_groups_by_proc_id_.erase(proc_id); | 318 task_groups_by_proc_id_.erase(proc_id); |
| 295 delete task_group; | 319 delete task_group; |
| 296 } | 320 } |
| 297 } | 321 } |
| 298 | 322 |
| 323 void TaskManagerImpl::TaskUnresponsive(Task* task) { |
| 324 DCHECK(task); |
| 325 NotifyObserversOnTaskUnresponsive(task->task_id()); |
| 326 } |
| 327 |
| 299 void TaskManagerImpl::OnVideoMemoryUsageStatsUpdate( | 328 void TaskManagerImpl::OnVideoMemoryUsageStatsUpdate( |
| 300 const content::GPUVideoMemoryUsageStats& gpu_memory_stats) { | 329 const content::GPUVideoMemoryUsageStats& gpu_memory_stats) { |
| 301 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 330 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 302 | 331 |
| 303 gpu_memory_stats_ = gpu_memory_stats; | 332 gpu_memory_stats_ = gpu_memory_stats; |
| 304 } | 333 } |
| 305 | 334 |
| 306 // static | 335 // static |
| 307 void TaskManagerImpl::OnMultipleBytesReadUI( | 336 void TaskManagerImpl::OnMultipleBytesReadUI( |
| 308 std::vector<BytesReadParam>* params) { | 337 std::vector<BytesReadParam>* params) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 DCHECK(ContainsKey(task_groups_by_task_id_, task_id)); | 418 DCHECK(ContainsKey(task_groups_by_task_id_, task_id)); |
| 390 | 419 |
| 391 return task_groups_by_task_id_.at(task_id); | 420 return task_groups_by_task_id_.at(task_id); |
| 392 } | 421 } |
| 393 | 422 |
| 394 Task* TaskManagerImpl::GetTaskByTaskId(TaskId task_id) const { | 423 Task* TaskManagerImpl::GetTaskByTaskId(TaskId task_id) const { |
| 395 return GetTaskGroupByTaskId(task_id)->GetTaskById(task_id); | 424 return GetTaskGroupByTaskId(task_id)->GetTaskById(task_id); |
| 396 } | 425 } |
| 397 | 426 |
| 398 } // namespace task_management | 427 } // namespace task_management |
| OLD | NEW |