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

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: Move ticks-Time and ticks-TimeDelta conversions to shared_sampler_win.cc Created 4 years 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 "gpu/ipc/common/memory_stats.h" 17 #include "gpu/ipc/common/memory_stats.h"
18 18
19 namespace task_manager { 19 namespace task_manager {
20 20
21 namespace { 21 namespace {
22 22
23 // A mask for the refresh types that are done in the background thread. 23 // A mask for the refresh types that are done in the background thread.
24 const int kBackgroundRefreshTypesMask = 24 const int kBackgroundRefreshTypesMask =
25 REFRESH_TYPE_CPU | 25 REFRESH_TYPE_CPU | REFRESH_TYPE_MEMORY | REFRESH_TYPE_IDLE_WAKEUPS |
26 REFRESH_TYPE_MEMORY | 26 #if defined(OS_WIN)
27 REFRESH_TYPE_IDLE_WAKEUPS | 27 REFRESH_TYPE_START_TIME | REFRESH_TYPE_CPU_TIME |
28 #endif // defined(OS_WIN)
28 #if defined(OS_LINUX) 29 #if defined(OS_LINUX)
29 REFRESH_TYPE_FD_COUNT | 30 REFRESH_TYPE_FD_COUNT |
30 #endif // defined(OS_LINUX) 31 #endif // defined(OS_LINUX)
31 REFRESH_TYPE_PRIORITY; 32 REFRESH_TYPE_PRIORITY;
32 33
33 #if defined(OS_WIN) 34 #if defined(OS_WIN)
34 // Gets the GDI and USER Handles on Windows at one shot. 35 // Gets the GDI and USER Handles on Windows at one shot.
35 void GetWindowsHandles(base::ProcessHandle handle, 36 void GetWindowsHandles(base::ProcessHandle handle,
36 int64_t* out_gdi_current, 37 int64_t* out_gdi_current,
37 int64_t* out_gdi_peak, 38 int64_t* out_gdi_peak,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 base::Bind(&TaskGroup::OnOpenFdCountRefreshDone, 108 base::Bind(&TaskGroup::OnOpenFdCountRefreshDone,
108 weak_ptr_factory_.GetWeakPtr()), 109 weak_ptr_factory_.GetWeakPtr()),
109 #endif // defined(OS_LINUX) 110 #endif // defined(OS_LINUX)
110 base::Bind(&TaskGroup::OnProcessPriorityDone, 111 base::Bind(&TaskGroup::OnProcessPriorityDone,
111 weak_ptr_factory_.GetWeakPtr()))); 112 weak_ptr_factory_.GetWeakPtr())));
112 worker_thread_sampler_.swap(sampler); 113 worker_thread_sampler_.swap(sampler);
113 114
114 shared_sampler_->RegisterCallbacks( 115 shared_sampler_->RegisterCallbacks(
115 process_id_, base::Bind(&TaskGroup::OnIdleWakeupsRefreshDone, 116 process_id_, base::Bind(&TaskGroup::OnIdleWakeupsRefreshDone,
116 weak_ptr_factory_.GetWeakPtr()), 117 weak_ptr_factory_.GetWeakPtr()),
117 base::Bind(&TaskGroup::OnPhysicalMemoryUsageRefreshDone, 118 base::Bind(&TaskGroup::OnPhysicalMemoryUsageRefreshDone,
118 weak_ptr_factory_.GetWeakPtr())); 119 weak_ptr_factory_.GetWeakPtr()),
120 base::Bind(&TaskGroup::OnStartTimeRefreshDone,
121 weak_ptr_factory_.GetWeakPtr()),
122 base::Bind(&TaskGroup::OnCpuTimeRefreshDone,
123 weak_ptr_factory_.GetWeakPtr()));
119 } 124 }
120 125
121 TaskGroup::~TaskGroup() { 126 TaskGroup::~TaskGroup() {
122 shared_sampler_->UnregisterCallbacks(process_id_); 127 shared_sampler_->UnregisterCallbacks(process_id_);
123 } 128 }
124 129
125 void TaskGroup::AddTask(Task* task) { 130 void TaskGroup::AddTask(Task* task) {
126 DCHECK(task); 131 DCHECK(task);
127 tasks_.push_back(task); 132 tasks_.push_back(task);
128 } 133 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 #endif // !defined(DISABLE_NACL) 251 #endif // !defined(DISABLE_NACL)
247 } 252 }
248 253
249 void TaskGroup::OnCpuRefreshDone(double cpu_usage) { 254 void TaskGroup::OnCpuRefreshDone(double cpu_usage) {
250 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 255 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
251 256
252 cpu_usage_ = cpu_usage; 257 cpu_usage_ = cpu_usage;
253 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_CPU); 258 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_CPU);
254 } 259 }
255 260
261 void TaskGroup::OnStartTimeRefreshDone(base::Time start_time) {
262 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
263
264 start_time_ = start_time;
265 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_START_TIME);
266 }
267
268 void TaskGroup::OnCpuTimeRefreshDone(base::TimeDelta cpu_time) {
269 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
270
271 cpu_time_ = cpu_time;
272 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_CPU_TIME);
273 }
274
256 void TaskGroup::OnPhysicalMemoryUsageRefreshDone(int64_t physical_bytes) { 275 void TaskGroup::OnPhysicalMemoryUsageRefreshDone(int64_t physical_bytes) {
257 #if defined(OS_WIN) 276 #if defined(OS_WIN)
258 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 277 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
259 278
260 memory_usage_.physical_bytes = physical_bytes; 279 memory_usage_.physical_bytes = physical_bytes;
261 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_PHYSICAL_MEMORY); 280 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_PHYSICAL_MEMORY);
262 #endif // OS_WIN 281 #endif // OS_WIN
263 } 282 }
264 283
265 void TaskGroup::OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage) { 284 void TaskGroup::OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 319
301 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) { 320 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) {
302 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 321 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
303 322
304 current_on_bg_done_flags_ |= finished_refresh_type; 323 current_on_bg_done_flags_ |= finished_refresh_type;
305 if (AreBackgroundCalculationsDone()) 324 if (AreBackgroundCalculationsDone())
306 on_background_calculations_done_.Run(); 325 on_background_calculations_done_.Run();
307 } 326 }
308 327
309 } // namespace task_manager 328 } // namespace task_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698