Chromium Code Reviews| 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_manager/sampling/task_manager_impl.h" | 5 #include "chrome/browser/task_manager/sampling/task_manager_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 #include <unordered_set> | 10 #include <unordered_set> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/bit_cast.h" | |
| 13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 14 #include "base/containers/adapters.h" | 15 #include "base/containers/adapters.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 16 #include "chrome/browser/task_manager/providers/browser_process_task_provider.h" | 17 #include "chrome/browser/task_manager/providers/browser_process_task_provider.h" |
| 17 #include "chrome/browser/task_manager/providers/child_process_task_provider.h" | 18 #include "chrome/browser/task_manager/providers/child_process_task_provider.h" |
| 18 #include "chrome/browser/task_manager/providers/web_contents/web_contents_task_p rovider.h" | 19 #include "chrome/browser/task_manager/providers/web_contents/web_contents_task_p rovider.h" |
| 19 #include "chrome/browser/task_manager/sampling/shared_sampler.h" | 20 #include "chrome/browser/task_manager/sampling/shared_sampler.h" |
| 20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/gpu_data_manager.h" | 22 #include "content/public/browser/gpu_data_manager.h" |
| 22 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 } | 87 } |
| 87 | 88 |
| 88 void TaskManagerImpl::KillTask(TaskId task_id) { | 89 void TaskManagerImpl::KillTask(TaskId task_id) { |
| 89 GetTaskByTaskId(task_id)->Kill(); | 90 GetTaskByTaskId(task_id)->Kill(); |
| 90 } | 91 } |
| 91 | 92 |
| 92 double TaskManagerImpl::GetCpuUsage(TaskId task_id) const { | 93 double TaskManagerImpl::GetCpuUsage(TaskId task_id) const { |
| 93 return GetTaskGroupByTaskId(task_id)->cpu_usage(); | 94 return GetTaskGroupByTaskId(task_id)->cpu_usage(); |
| 94 } | 95 } |
| 95 | 96 |
| 97 base::Time TaskManagerImpl::GetStartTime(TaskId task_id) const { | |
| 98 #if defined(OS_WIN) | |
| 99 uint64_t time_in_100ns = GetTaskGroupByTaskId(task_id)->start_time(); | |
| 100 if (time_in_100ns == 0) | |
| 101 return base::Time(); | |
| 102 FILETIME ft = bit_cast<FILETIME, int64_t>(time_in_100ns); | |
| 103 return base::Time::FromFileTime(ft); | |
|
afakhry
2016/12/22 00:28:14
I'm wondering why we don't do this calculation in
chengx
2016/12/22 21:42:55
Thanks for the suggestion! I have moved the ticks-
| |
| 104 #else | |
| 105 return base::Time(); | |
| 106 #endif | |
| 107 } | |
| 108 | |
| 109 base::TimeDelta TaskManagerImpl::GetCpuTime(TaskId task_id) const { | |
| 110 #if defined(OS_WIN) | |
| 111 uint64_t time_in_100ns = GetTaskGroupByTaskId(task_id)->cpu_time(); | |
| 112 if (time_in_100ns == 0) | |
| 113 return base::TimeDelta(); | |
| 114 return base::TimeDelta::FromMicroseconds(time_in_100ns / 10); | |
| 115 #else | |
| 116 return base::TimeDelta(); | |
| 117 #endif | |
| 118 } | |
| 119 | |
| 96 int64_t TaskManagerImpl::GetPhysicalMemoryUsage(TaskId task_id) const { | 120 int64_t TaskManagerImpl::GetPhysicalMemoryUsage(TaskId task_id) const { |
| 97 return GetTaskGroupByTaskId(task_id)->physical_bytes(); | 121 return GetTaskGroupByTaskId(task_id)->physical_bytes(); |
| 98 } | 122 } |
| 99 | 123 |
| 100 int64_t TaskManagerImpl::GetPrivateMemoryUsage(TaskId task_id) const { | 124 int64_t TaskManagerImpl::GetPrivateMemoryUsage(TaskId task_id) const { |
| 101 return GetTaskGroupByTaskId(task_id)->private_bytes(); | 125 return GetTaskGroupByTaskId(task_id)->private_bytes(); |
| 102 } | 126 } |
| 103 | 127 |
| 104 int64_t TaskManagerImpl::GetSharedMemoryUsage(TaskId task_id) const { | 128 int64_t TaskManagerImpl::GetSharedMemoryUsage(TaskId task_id) const { |
| 105 return GetTaskGroupByTaskId(task_id)->shared_bytes(); | 129 return GetTaskGroupByTaskId(task_id)->shared_bytes(); |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 groups_itr.second->AreBackgroundCalculationsDone(); | 564 groups_itr.second->AreBackgroundCalculationsDone(); |
| 541 } | 565 } |
| 542 if (are_all_processes_data_ready) { | 566 if (are_all_processes_data_ready) { |
| 543 NotifyObserversOnRefreshWithBackgroundCalculations(GetTaskIdsList()); | 567 NotifyObserversOnRefreshWithBackgroundCalculations(GetTaskIdsList()); |
| 544 for (const auto& groups_itr : task_groups_by_proc_id_) | 568 for (const auto& groups_itr : task_groups_by_proc_id_) |
| 545 groups_itr.second->ClearCurrentBackgroundCalculationsFlags(); | 569 groups_itr.second->ClearCurrentBackgroundCalculationsFlags(); |
| 546 } | 570 } |
| 547 } | 571 } |
| 548 | 572 |
| 549 } // namespace task_manager | 573 } // namespace task_manager |
| OLD | NEW |