| 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/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "chrome/browser/task_management/providers/browser_process_task_provider
.h" | 8 #include "chrome/browser/task_management/providers/browser_process_task_provider
.h" |
| 9 #include "chrome/browser/task_management/providers/child_process_task_provider.h
" | 9 #include "chrome/browser/task_management/providers/child_process_task_provider.h
" |
| 10 #include "chrome/browser/task_management/providers/web_contents/web_contents_tas
k_provider.h" | 10 #include "chrome/browser/task_management/providers/web_contents/web_contents_tas
k_provider.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 #if defined(OS_WIN) | 115 #if defined(OS_WIN) |
| 116 const TaskGroup* task_group = GetTaskGroupByTaskId(task_id); | 116 const TaskGroup* task_group = GetTaskGroupByTaskId(task_id); |
| 117 *current = task_group->user_current_handles(); | 117 *current = task_group->user_current_handles(); |
| 118 *peak = task_group->user_peak_handles(); | 118 *peak = task_group->user_peak_handles(); |
| 119 #else | 119 #else |
| 120 *current = -1; | 120 *current = -1; |
| 121 *peak = -1; | 121 *peak = -1; |
| 122 #endif // defined(OS_WIN) | 122 #endif // defined(OS_WIN) |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool TaskManagerImpl::IsTaskOnBackgroundedProcess(TaskId task_id) const { |
| 126 return GetTaskGroupByTaskId(task_id)->is_backgrounded(); |
| 127 } |
| 128 |
| 125 const base::string16& TaskManagerImpl::GetTitle(TaskId task_id) const { | 129 const base::string16& TaskManagerImpl::GetTitle(TaskId task_id) const { |
| 126 return GetTaskByTaskId(task_id)->title(); | 130 return GetTaskByTaskId(task_id)->title(); |
| 127 } | 131 } |
| 128 | 132 |
| 133 const std::string& TaskManagerImpl::GetTaskNameForRappor(TaskId task_id) const { |
| 134 return GetTaskByTaskId(task_id)->rappor_sample_name(); |
| 135 } |
| 136 |
| 129 base::string16 TaskManagerImpl::GetProfileName(TaskId task_id) const { | 137 base::string16 TaskManagerImpl::GetProfileName(TaskId task_id) const { |
| 130 return GetTaskByTaskId(task_id)->GetProfileName(); | 138 return GetTaskByTaskId(task_id)->GetProfileName(); |
| 131 } | 139 } |
| 132 | 140 |
| 133 const gfx::ImageSkia& TaskManagerImpl::GetIcon(TaskId task_id) const { | 141 const gfx::ImageSkia& TaskManagerImpl::GetIcon(TaskId task_id) const { |
| 134 return GetTaskByTaskId(task_id)->icon(); | 142 return GetTaskByTaskId(task_id)->icon(); |
| 135 } | 143 } |
| 136 | 144 |
| 137 const base::ProcessHandle& TaskManagerImpl::GetProcessHandle( | 145 const base::ProcessHandle& TaskManagerImpl::GetProcessHandle( |
| 138 TaskId task_id) const { | 146 TaskId task_id) const { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 for (auto& groups_itr : task_groups_by_proc_id_) { | 306 for (auto& groups_itr : task_groups_by_proc_id_) { |
| 299 groups_itr.second->Refresh(gpu_memory_stats_, | 307 groups_itr.second->Refresh(gpu_memory_stats_, |
| 300 GetCurrentRefreshTime(), | 308 GetCurrentRefreshTime(), |
| 301 enabled_resources_flags()); | 309 enabled_resources_flags()); |
| 302 } | 310 } |
| 303 | 311 |
| 304 NotifyObserversOnRefresh(GetTaskIdsList()); | 312 NotifyObserversOnRefresh(GetTaskIdsList()); |
| 305 } | 313 } |
| 306 | 314 |
| 307 void TaskManagerImpl::StartUpdating() { | 315 void TaskManagerImpl::StartUpdating() { |
| 316 if (is_running_) |
| 317 return; |
| 318 |
| 308 is_running_ = true; | 319 is_running_ = true; |
| 309 | 320 |
| 310 for (auto& provider : task_providers_) | 321 for (auto& provider : task_providers_) |
| 311 provider->SetObserver(this); | 322 provider->SetObserver(this); |
| 312 | 323 |
| 313 io_thread_helper_manager_.reset(new IoThreadHelperManager); | 324 io_thread_helper_manager_.reset(new IoThreadHelperManager); |
| 314 } | 325 } |
| 315 | 326 |
| 316 void TaskManagerImpl::StopUpdating() { | 327 void TaskManagerImpl::StopUpdating() { |
| 328 if (!is_running_) |
| 329 return; |
| 330 |
| 317 is_running_ = false; | 331 is_running_ = false; |
| 318 | 332 |
| 319 io_thread_helper_manager_.reset(); | 333 io_thread_helper_manager_.reset(); |
| 320 | 334 |
| 321 for (auto& provider : task_providers_) | 335 for (auto& provider : task_providers_) |
| 322 provider->ClearObserver(); | 336 provider->ClearObserver(); |
| 323 | 337 |
| 324 STLDeleteValues(&task_groups_by_proc_id_); | 338 STLDeleteValues(&task_groups_by_proc_id_); |
| 325 task_groups_by_task_id_.clear(); | 339 task_groups_by_task_id_.clear(); |
| 326 sorted_task_ids_.clear(); | 340 sorted_task_ids_.clear(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 347 DCHECK(ContainsKey(task_groups_by_task_id_, task_id)); | 361 DCHECK(ContainsKey(task_groups_by_task_id_, task_id)); |
| 348 | 362 |
| 349 return task_groups_by_task_id_.at(task_id); | 363 return task_groups_by_task_id_.at(task_id); |
| 350 } | 364 } |
| 351 | 365 |
| 352 Task* TaskManagerImpl::GetTaskByTaskId(TaskId task_id) const { | 366 Task* TaskManagerImpl::GetTaskByTaskId(TaskId task_id) const { |
| 353 return GetTaskGroupByTaskId(task_id)->GetTaskById(task_id); | 367 return GetTaskGroupByTaskId(task_id)->GetTaskById(task_id); |
| 354 } | 368 } |
| 355 | 369 |
| 356 } // namespace task_management | 370 } // namespace task_management |
| OLD | NEW |