| 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_group.h" | 5 #include "chrome/browser/task_manager/sampling/task_group.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 #if defined(OS_LINUX) | 106 #if defined(OS_LINUX) |
| 107 base::Bind(&TaskGroup::OnOpenFdCountRefreshDone, | 107 base::Bind(&TaskGroup::OnOpenFdCountRefreshDone, |
| 108 weak_ptr_factory_.GetWeakPtr()), | 108 weak_ptr_factory_.GetWeakPtr()), |
| 109 #endif // defined(OS_LINUX) | 109 #endif // defined(OS_LINUX) |
| 110 base::Bind(&TaskGroup::OnProcessPriorityDone, | 110 base::Bind(&TaskGroup::OnProcessPriorityDone, |
| 111 weak_ptr_factory_.GetWeakPtr()))); | 111 weak_ptr_factory_.GetWeakPtr()))); |
| 112 worker_thread_sampler_.swap(sampler); | 112 worker_thread_sampler_.swap(sampler); |
| 113 | 113 |
| 114 shared_sampler_->RegisterCallbacks( | 114 shared_sampler_->RegisterCallbacks( |
| 115 process_id_, base::Bind(&TaskGroup::OnIdleWakeupsRefreshDone, | 115 process_id_, base::Bind(&TaskGroup::OnIdleWakeupsRefreshDone, |
| 116 weak_ptr_factory_.GetWeakPtr()), |
| 117 base::Bind(&TaskGroup::OnPhysicalMemoryUsageRefreshDone, |
| 116 weak_ptr_factory_.GetWeakPtr())); | 118 weak_ptr_factory_.GetWeakPtr())); |
| 117 } | 119 } |
| 118 | 120 |
| 119 TaskGroup::~TaskGroup() { | 121 TaskGroup::~TaskGroup() { |
| 120 shared_sampler_->UnregisterCallbacks(process_id_); | 122 shared_sampler_->UnregisterCallbacks(process_id_); |
| 121 } | 123 } |
| 122 | 124 |
| 123 void TaskGroup::AddTask(Task* task) { | 125 void TaskGroup::AddTask(Task* task) { |
| 124 DCHECK(task); | 126 DCHECK(task); |
| 125 tasks_.push_back(task); | 127 tasks_.push_back(task); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 #endif // !defined(DISABLE_NACL) | 246 #endif // !defined(DISABLE_NACL) |
| 245 } | 247 } |
| 246 | 248 |
| 247 void TaskGroup::OnCpuRefreshDone(double cpu_usage) { | 249 void TaskGroup::OnCpuRefreshDone(double cpu_usage) { |
| 248 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 250 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 249 | 251 |
| 250 cpu_usage_ = cpu_usage; | 252 cpu_usage_ = cpu_usage; |
| 251 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_CPU); | 253 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_CPU); |
| 252 } | 254 } |
| 253 | 255 |
| 256 void TaskGroup::OnPhysicalMemoryUsageRefreshDone(int64_t physical_bytes) { |
| 257 #if defined(OS_WIN) |
| 258 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 259 |
| 260 memory_usage_.physical_bytes = physical_bytes; |
| 261 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_PHYSICAL_MEMORY); |
| 262 #endif // OS_WIN |
| 263 } |
| 264 |
| 254 void TaskGroup::OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage) { | 265 void TaskGroup::OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage) { |
| 255 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 266 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 256 | 267 |
| 268 #if defined(OS_WIN) |
| 269 memory_usage_.private_bytes = memory_usage.private_bytes; |
| 270 memory_usage_.shared_bytes = memory_usage.shared_bytes; |
| 271 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_MEMORY_DETAILS); |
| 272 #else |
| 257 memory_usage_ = memory_usage; | 273 memory_usage_ = memory_usage; |
| 258 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_MEMORY); | 274 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_MEMORY); |
| 275 #endif // OS_WIN |
| 259 } | 276 } |
| 260 | 277 |
| 261 void TaskGroup::OnIdleWakeupsRefreshDone(int idle_wakeups_per_second) { | 278 void TaskGroup::OnIdleWakeupsRefreshDone(int idle_wakeups_per_second) { |
| 262 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 279 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 263 | 280 |
| 264 idle_wakeups_per_second_ = idle_wakeups_per_second; | 281 idle_wakeups_per_second_ = idle_wakeups_per_second; |
| 265 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_IDLE_WAKEUPS); | 282 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_IDLE_WAKEUPS); |
| 266 } | 283 } |
| 267 | 284 |
| 268 #if defined(OS_LINUX) | 285 #if defined(OS_LINUX) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 283 | 300 |
| 284 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) { | 301 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) { |
| 285 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 302 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 286 | 303 |
| 287 current_on_bg_done_flags_ |= finished_refresh_type; | 304 current_on_bg_done_flags_ |= finished_refresh_type; |
| 288 if (AreBackgroundCalculationsDone()) | 305 if (AreBackgroundCalculationsDone()) |
| 289 on_background_calculations_done_.Run(); | 306 on_background_calculations_done_.Run(); |
| 290 } | 307 } |
| 291 | 308 |
| 292 } // namespace task_manager | 309 } // namespace task_manager |
| OLD | NEW |