Chromium Code Reviews| Index: chrome/browser/task_management/sampling/task_group_sampler.cc |
| diff --git a/chrome/browser/task_management/sampling/task_group_sampler.cc b/chrome/browser/task_management/sampling/task_group_sampler.cc |
| index e8999b3e2dcc6af350f320fd06f7fed86819ff08..8f7ddef73e517c93979223da8eac8b2de875cfbc 100644 |
| --- a/chrome/browser/task_management/sampling/task_group_sampler.cc |
| +++ b/chrome/browser/task_management/sampling/task_group_sampler.cc |
| @@ -31,16 +31,20 @@ inline bool IsResourceRefreshEnabled(RefreshType refresh_type, |
| } // namespace |
| TaskGroupSampler::TaskGroupSampler( |
| + base::ProcessId proc_id, |
| base::ProcessHandle proc_handle, |
| const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner, |
| const OnCpuRefreshCallback& on_cpu_refresh, |
| const OnMemoryRefreshCallback& on_memory_refresh, |
| - const OnIdleWakeupsCallback& on_idle_wakeups) |
| + const OnIdleWakeupsCallback& on_idle_wakeups, |
| + const OnProcessPriorityCallback& on_process_priority) |
| : process_metrics_(CreateProcessMetrics(proc_handle)), |
| blocking_pool_runner_(blocking_pool_runner), |
| + process_(base::Process::Open(proc_id)), |
|
ncarter (slow)
2015/11/20 18:44:45
If we're doing base::Process::Open here, that give
afakhry
2015/11/21 01:32:58
Thanks for this suggestion. It matches our decisio
|
| on_cpu_refresh_callback_(on_cpu_refresh), |
| on_memory_refresh_callback_(on_memory_refresh), |
| - on_idle_wakeups_callback_(on_idle_wakeups) { |
| + on_idle_wakeups_callback_(on_idle_wakeups), |
| + on_process_priority_callback_(on_process_priority) { |
| DCHECK(blocking_pool_runner.get()); |
| // This object will be created on the UI thread, however the sequenced checker |
| @@ -78,6 +82,14 @@ void TaskGroupSampler::Refresh(int64 refresh_flags) { |
| on_idle_wakeups_callback_); |
| } |
| #endif // defined(OS_MACOSX) || defined(OS_LINUX) |
| + |
| + if (IsResourceRefreshEnabled(REFRESH_TYPE_PRIORITY, refresh_flags)) { |
| + base::PostTaskAndReplyWithResult( |
| + blocking_pool_runner_.get(), |
| + FROM_HERE, |
| + base::Bind(&TaskGroupSampler::RefreshProcessPriority, this), |
| + on_process_priority_callback_); |
| + } |
| } |
| TaskGroupSampler::~TaskGroupSampler() { |
| @@ -126,4 +138,10 @@ int TaskGroupSampler::RefreshIdleWakeupsPerSecond() { |
| return process_metrics_->GetIdleWakeupsPerSecond(); |
| } |
| +bool TaskGroupSampler::RefreshProcessPriority() { |
| + DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequencedThread()); |
| + |
| + return process_.IsProcessBackgrounded(); |
| +} |
| + |
| } // namespace task_management |