Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: chrome/browser/task_management/sampling/task_group_sampler.cc

Issue 1374283003: Reporting top cpu and memory consumers via rappor on chromeos (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed arbitrary given weights Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698