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

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

Issue 1439213004: Fix various TaskManager bugs and add new enhancements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: auto*& --> auto* 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 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_management/sampling/task_group.h" 5 #include "chrome/browser/task_management/sampling/task_group.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/task_management/task_manager_observer.h" 10 #include "chrome/browser/task_management/task_manager_observer.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 base::ProcessHandle proc_handle, 56 base::ProcessHandle proc_handle,
57 base::ProcessId proc_id, 57 base::ProcessId proc_id,
58 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner) 58 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner)
59 : process_handle_(proc_handle), 59 : process_handle_(proc_handle),
60 process_id_(proc_id), 60 process_id_(proc_id),
61 worker_thread_sampler_(nullptr), 61 worker_thread_sampler_(nullptr),
62 tasks_(), 62 tasks_(),
63 cpu_usage_(0.0), 63 cpu_usage_(0.0),
64 memory_usage_(), 64 memory_usage_(),
65 gpu_memory_(-1), 65 gpu_memory_(-1),
66 per_process_network_usage_(-1),
66 #if defined(OS_WIN) 67 #if defined(OS_WIN)
67 gdi_current_handles_(-1), 68 gdi_current_handles_(-1),
68 gdi_peak_handles_(-1), 69 gdi_peak_handles_(-1),
69 user_current_handles_(-1), 70 user_current_handles_(-1),
70 user_peak_handles_(-1), 71 user_peak_handles_(-1),
71 #endif // defined(OS_WIN) 72 #endif // defined(OS_WIN)
72 #if !defined(DISABLE_NACL) 73 #if !defined(DISABLE_NACL)
73 nacl_debug_stub_port_(-1), 74 nacl_debug_stub_port_(-1),
74 #endif // !defined(DISABLE_NACL) 75 #endif // !defined(DISABLE_NACL)
75 idle_wakeups_per_second_(-1), 76 idle_wakeups_per_second_(-1),
(...skipping 29 matching lines...) Expand all
105 tasks_.erase(task->task_id()); 106 tasks_.erase(task->task_id());
106 } 107 }
107 108
108 void TaskGroup::Refresh( 109 void TaskGroup::Refresh(
109 const content::GPUVideoMemoryUsageStats& gpu_memory_stats, 110 const content::GPUVideoMemoryUsageStats& gpu_memory_stats,
110 base::TimeDelta update_interval, 111 base::TimeDelta update_interval,
111 int64 refresh_flags) { 112 int64 refresh_flags) {
112 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 113 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
113 114
114 // First refresh the enabled non-expensive resources usages on the UI thread. 115 // First refresh the enabled non-expensive resources usages on the UI thread.
115 // 1- Refresh all the tasks. 116 // 1- Refresh all the tasks as well as the total network usage (if enabled).
116 for (auto& task_pair : tasks_) 117 const bool network_usage_refresh_enabled =
117 task_pair.second->Refresh(update_interval, refresh_flags); 118 IsResourceRefreshEnabled(REFRESH_TYPE_NETWORK_USAGE, refresh_flags);
119 per_process_network_usage_ = network_usage_refresh_enabled ? 0 : -1;
120 for (auto& task_pair : tasks_) {
121 Task* task = task_pair.second;
122 task->Refresh(update_interval, refresh_flags);
123
124 if (network_usage_refresh_enabled && task->ReportsNetworkUsage()) {
125 per_process_network_usage_ += task->network_usage();
126 }
127 }
118 128
119 // 2- Refresh GPU memory (if enabled). 129 // 2- Refresh GPU memory (if enabled).
120 if (IsResourceRefreshEnabled(REFRESH_TYPE_GPU_MEMORY, refresh_flags)) 130 if (IsResourceRefreshEnabled(REFRESH_TYPE_GPU_MEMORY, refresh_flags))
121 RefreshGpuMemory(gpu_memory_stats); 131 RefreshGpuMemory(gpu_memory_stats);
122 132
123 // 3- Refresh Windows handles (if enabled). 133 // 3- Refresh Windows handles (if enabled).
124 #if defined(OS_WIN) 134 #if defined(OS_WIN)
125 if (IsResourceRefreshEnabled(REFRESH_TYPE_HANDLES, refresh_flags)) 135 if (IsResourceRefreshEnabled(REFRESH_TYPE_HANDLES, refresh_flags))
126 RefreshWindowsHandles(); 136 RefreshWindowsHandles();
127 #endif // defined(OS_WIN) 137 #endif // defined(OS_WIN)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 memory_usage_ = memory_usage; 209 memory_usage_ = memory_usage;
200 } 210 }
201 211
202 void TaskGroup::OnIdleWakeupsRefreshDone(int idle_wakeups_per_second) { 212 void TaskGroup::OnIdleWakeupsRefreshDone(int idle_wakeups_per_second) {
203 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 213 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
204 214
205 idle_wakeups_per_second_ = idle_wakeups_per_second; 215 idle_wakeups_per_second_ = idle_wakeups_per_second;
206 } 216 }
207 217
208 } // namespace task_management 218 } // namespace task_management
OLDNEW
« no previous file with comments | « chrome/browser/task_management/sampling/task_group.h ('k') | chrome/browser/task_management/sampling/task_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698