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

Side by Side Diff: chrome/browser/task_manager/sampling/task_group.cc

Issue 2573183002: Add process start time and CPU time columns to task manager (Closed)
Patch Set: Fix nits and conflicts. Created 3 years, 11 months 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 unified diff | Download patch
OLDNEW
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"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/task_manager/sampling/shared_sampler.h" 13 #include "chrome/browser/task_manager/sampling/shared_sampler.h"
14 #include "chrome/browser/task_manager/task_manager_observer.h" 14 #include "chrome/browser/task_manager/task_manager_observer.h"
15 #include "components/nacl/browser/nacl_browser.h" 15 #include "components/nacl/browser/nacl_browser.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/memory_coordinator.h" 17 #include "content/public/browser/memory_coordinator.h"
18 #include "content/public/common/content_features.h" 18 #include "content/public/common/content_features.h"
19 #include "gpu/ipc/common/memory_stats.h" 19 #include "gpu/ipc/common/memory_stats.h"
20 20
21 namespace task_manager { 21 namespace task_manager {
22 22
23 namespace { 23 namespace {
24 24
25 // A mask for the refresh types that are done in the background thread. 25 // A mask for the refresh types that are done in the background thread.
26 const int kBackgroundRefreshTypesMask = 26 const int kBackgroundRefreshTypesMask =
27 REFRESH_TYPE_CPU | 27 REFRESH_TYPE_CPU | REFRESH_TYPE_MEMORY | REFRESH_TYPE_IDLE_WAKEUPS |
28 REFRESH_TYPE_MEMORY | 28 #if defined(OS_WIN)
29 REFRESH_TYPE_IDLE_WAKEUPS | 29 REFRESH_TYPE_START_TIME | REFRESH_TYPE_CPU_TIME |
30 #endif // defined(OS_WIN)
30 #if defined(OS_LINUX) 31 #if defined(OS_LINUX)
31 REFRESH_TYPE_FD_COUNT | 32 REFRESH_TYPE_FD_COUNT |
32 #endif // defined(OS_LINUX) 33 #endif // defined(OS_LINUX)
33 REFRESH_TYPE_PRIORITY; 34 REFRESH_TYPE_PRIORITY;
34 35
35 #if defined(OS_WIN) 36 #if defined(OS_WIN)
36 // Gets the GDI and USER Handles on Windows at one shot. 37 // Gets the GDI and USER Handles on Windows at one shot.
37 void GetWindowsHandles(base::ProcessHandle handle, 38 void GetWindowsHandles(base::ProcessHandle handle,
38 int64_t* out_gdi_current, 39 int64_t* out_gdi_current,
39 int64_t* out_gdi_peak, 40 int64_t* out_gdi_peak,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 base::Bind(&TaskGroup::OnOpenFdCountRefreshDone, 111 base::Bind(&TaskGroup::OnOpenFdCountRefreshDone,
111 weak_ptr_factory_.GetWeakPtr()), 112 weak_ptr_factory_.GetWeakPtr()),
112 #endif // defined(OS_LINUX) 113 #endif // defined(OS_LINUX)
113 base::Bind(&TaskGroup::OnProcessPriorityDone, 114 base::Bind(&TaskGroup::OnProcessPriorityDone,
114 weak_ptr_factory_.GetWeakPtr()))); 115 weak_ptr_factory_.GetWeakPtr())));
115 worker_thread_sampler_.swap(sampler); 116 worker_thread_sampler_.swap(sampler);
116 117
117 shared_sampler_->RegisterCallbacks( 118 shared_sampler_->RegisterCallbacks(
118 process_id_, base::Bind(&TaskGroup::OnIdleWakeupsRefreshDone, 119 process_id_, base::Bind(&TaskGroup::OnIdleWakeupsRefreshDone,
119 weak_ptr_factory_.GetWeakPtr()), 120 weak_ptr_factory_.GetWeakPtr()),
120 base::Bind(&TaskGroup::OnPhysicalMemoryUsageRefreshDone, 121 base::Bind(&TaskGroup::OnPhysicalMemoryUsageRefreshDone,
121 weak_ptr_factory_.GetWeakPtr())); 122 weak_ptr_factory_.GetWeakPtr()),
123 base::Bind(&TaskGroup::OnStartTimeRefreshDone,
124 weak_ptr_factory_.GetWeakPtr()),
125 base::Bind(&TaskGroup::OnCpuTimeRefreshDone,
126 weak_ptr_factory_.GetWeakPtr()));
122 } 127 }
123 128
124 TaskGroup::~TaskGroup() { 129 TaskGroup::~TaskGroup() {
125 shared_sampler_->UnregisterCallbacks(process_id_); 130 shared_sampler_->UnregisterCallbacks(process_id_);
126 } 131 }
127 132
128 void TaskGroup::AddTask(Task* task) { 133 void TaskGroup::AddTask(Task* task) {
129 DCHECK(task); 134 DCHECK(task);
130 tasks_.push_back(task); 135 tasks_.push_back(task);
131 } 136 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 #endif // !defined(DISABLE_NACL) 263 #endif // !defined(DISABLE_NACL)
259 } 264 }
260 265
261 void TaskGroup::OnCpuRefreshDone(double cpu_usage) { 266 void TaskGroup::OnCpuRefreshDone(double cpu_usage) {
262 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 267 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
263 268
264 cpu_usage_ = cpu_usage; 269 cpu_usage_ = cpu_usage;
265 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_CPU); 270 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_CPU);
266 } 271 }
267 272
273 void TaskGroup::OnStartTimeRefreshDone(base::Time start_time) {
274 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
275
276 start_time_ = start_time;
277 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_START_TIME);
278 }
279
280 void TaskGroup::OnCpuTimeRefreshDone(base::TimeDelta cpu_time) {
281 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
282
283 cpu_time_ = cpu_time;
284 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_CPU_TIME);
285 }
286
268 void TaskGroup::OnPhysicalMemoryUsageRefreshDone(int64_t physical_bytes) { 287 void TaskGroup::OnPhysicalMemoryUsageRefreshDone(int64_t physical_bytes) {
269 #if defined(OS_WIN) 288 #if defined(OS_WIN)
270 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 289 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
271 290
272 memory_usage_.physical_bytes = physical_bytes; 291 memory_usage_.physical_bytes = physical_bytes;
273 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_PHYSICAL_MEMORY); 292 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_PHYSICAL_MEMORY);
274 #endif // OS_WIN 293 #endif // OS_WIN
275 } 294 }
276 295
277 void TaskGroup::OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage) { 296 void TaskGroup::OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 331
313 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) { 332 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) {
314 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 333 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
315 334
316 current_on_bg_done_flags_ |= finished_refresh_type; 335 current_on_bg_done_flags_ |= finished_refresh_type;
317 if (AreBackgroundCalculationsDone()) 336 if (AreBackgroundCalculationsDone())
318 on_background_calculations_done_.Run(); 337 on_background_calculations_done_.Run();
319 } 338 }
320 339
321 } // namespace task_manager 340 } // namespace task_manager
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/sampling/task_group.h ('k') | chrome/browser/task_manager/sampling/task_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698