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

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

Issue 1545223002: Switch to standard integer types in chrome/browser/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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_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 "build/build_config.h"
10 #include "chrome/browser/task_management/task_manager_observer.h" 11 #include "chrome/browser/task_management/task_manager_observer.h"
11 #include "components/nacl/browser/nacl_browser.h" 12 #include "components/nacl/browser/nacl_browser.h"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
13 14
14 namespace task_management { 15 namespace task_management {
15 16
16 namespace { 17 namespace {
17 18
18 inline bool IsResourceRefreshEnabled(RefreshType refresh_type, 19 inline bool IsResourceRefreshEnabled(RefreshType refresh_type,
19 int refresh_flags) { 20 int refresh_flags) {
20 return (refresh_flags & refresh_type) != 0; 21 return (refresh_flags & refresh_type) != 0;
21 } 22 }
22 23
23 #if defined(OS_WIN) 24 #if defined(OS_WIN)
24 // Gets the GDI and USER Handles on Windows at one shot. 25 // Gets the GDI and USER Handles on Windows at one shot.
25 void GetWindowsHandles(base::ProcessHandle handle, 26 void GetWindowsHandles(base::ProcessHandle handle,
26 int64* out_gdi_current, 27 int64_t* out_gdi_current,
27 int64* out_gdi_peak, 28 int64_t* out_gdi_peak,
28 int64* out_user_current, 29 int64_t* out_user_current,
29 int64* out_user_peak) { 30 int64_t* out_user_peak) {
30 *out_gdi_current = 0; 31 *out_gdi_current = 0;
31 *out_gdi_peak = 0; 32 *out_gdi_peak = 0;
32 *out_user_current = 0; 33 *out_user_current = 0;
33 *out_user_peak = 0; 34 *out_user_peak = 0;
34 // Get a handle to |process| that has PROCESS_QUERY_INFORMATION rights. 35 // Get a handle to |process| that has PROCESS_QUERY_INFORMATION rights.
35 HANDLE current_process = GetCurrentProcess(); 36 HANDLE current_process = GetCurrentProcess();
36 HANDLE process_with_query_rights; 37 HANDLE process_with_query_rights;
37 if (DuplicateHandle(current_process, handle, current_process, 38 if (DuplicateHandle(current_process, handle, current_process,
38 &process_with_query_rights, PROCESS_QUERY_INFORMATION, 39 &process_with_query_rights, PROCESS_QUERY_INFORMATION,
39 false, 0)) { 40 false, 0)) {
40 *out_gdi_current = static_cast<int64>( 41 *out_gdi_current = static_cast<int64_t>(
41 GetGuiResources(process_with_query_rights, GR_GDIOBJECTS)); 42 GetGuiResources(process_with_query_rights, GR_GDIOBJECTS));
42 *out_gdi_peak = static_cast<int64>( 43 *out_gdi_peak = static_cast<int64_t>(
43 GetGuiResources(process_with_query_rights, GR_GDIOBJECTS_PEAK)); 44 GetGuiResources(process_with_query_rights, GR_GDIOBJECTS_PEAK));
44 *out_user_current = static_cast<int64>( 45 *out_user_current = static_cast<int64_t>(
45 GetGuiResources(process_with_query_rights, GR_USEROBJECTS)); 46 GetGuiResources(process_with_query_rights, GR_USEROBJECTS));
46 *out_user_peak = static_cast<int64>( 47 *out_user_peak = static_cast<int64_t>(
47 GetGuiResources(process_with_query_rights, GR_USEROBJECTS_PEAK)); 48 GetGuiResources(process_with_query_rights, GR_USEROBJECTS_PEAK));
48 CloseHandle(process_with_query_rights); 49 CloseHandle(process_with_query_rights);
49 } 50 }
50 } 51 }
51 #endif // defined(OS_WIN) 52 #endif // defined(OS_WIN)
52 53
53 } // namespace 54 } // namespace
54 55
55 TaskGroup::TaskGroup( 56 TaskGroup::TaskGroup(
56 base::ProcessHandle proc_handle, 57 base::ProcessHandle proc_handle,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 void TaskGroup::RemoveTask(Task* task) { 113 void TaskGroup::RemoveTask(Task* task) {
113 DCHECK(task); 114 DCHECK(task);
114 DCHECK(ContainsKey(tasks_, task->task_id())); 115 DCHECK(ContainsKey(tasks_, task->task_id()));
115 116
116 tasks_.erase(task->task_id()); 117 tasks_.erase(task->task_id());
117 } 118 }
118 119
119 void TaskGroup::Refresh( 120 void TaskGroup::Refresh(
120 const content::GPUVideoMemoryUsageStats& gpu_memory_stats, 121 const content::GPUVideoMemoryUsageStats& gpu_memory_stats,
121 base::TimeDelta update_interval, 122 base::TimeDelta update_interval,
122 int64 refresh_flags) { 123 int64_t refresh_flags) {
123 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 124 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
124 125
125 // First refresh the enabled non-expensive resources usages on the UI thread. 126 // First refresh the enabled non-expensive resources usages on the UI thread.
126 // 1- Refresh all the tasks as well as the total network usage (if enabled). 127 // 1- Refresh all the tasks as well as the total network usage (if enabled).
127 const bool network_usage_refresh_enabled = 128 const bool network_usage_refresh_enabled =
128 IsResourceRefreshEnabled(REFRESH_TYPE_NETWORK_USAGE, refresh_flags); 129 IsResourceRefreshEnabled(REFRESH_TYPE_NETWORK_USAGE, refresh_flags);
129 per_process_network_usage_ = network_usage_refresh_enabled ? 0 : -1; 130 per_process_network_usage_ = network_usage_refresh_enabled ? 0 : -1;
130 for (auto& task_pair : tasks_) { 131 for (auto& task_pair : tasks_) {
131 Task* task = task_pair.second; 132 Task* task = task_pair.second;
132 task->Refresh(update_interval, refresh_flags); 133 task->Refresh(update_interval, refresh_flags);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 181
181 void TaskGroup::RefreshGpuMemory( 182 void TaskGroup::RefreshGpuMemory(
182 const content::GPUVideoMemoryUsageStats& gpu_memory_stats) { 183 const content::GPUVideoMemoryUsageStats& gpu_memory_stats) {
183 auto itr = gpu_memory_stats.process_map.find(process_id_); 184 auto itr = gpu_memory_stats.process_map.find(process_id_);
184 if (itr == gpu_memory_stats.process_map.end()) { 185 if (itr == gpu_memory_stats.process_map.end()) {
185 gpu_memory_ = -1; 186 gpu_memory_ = -1;
186 gpu_memory_has_duplicates_ = false; 187 gpu_memory_has_duplicates_ = false;
187 return; 188 return;
188 } 189 }
189 190
190 gpu_memory_ = static_cast<int64>(itr->second.video_memory); 191 gpu_memory_ = static_cast<int64_t>(itr->second.video_memory);
191 gpu_memory_has_duplicates_ = itr->second.has_duplicates; 192 gpu_memory_has_duplicates_ = itr->second.has_duplicates;
192 } 193 }
193 194
194 void TaskGroup::RefreshWindowsHandles() { 195 void TaskGroup::RefreshWindowsHandles() {
195 #if defined(OS_WIN) 196 #if defined(OS_WIN)
196 GetWindowsHandles(process_handle_, 197 GetWindowsHandles(process_handle_,
197 &gdi_current_handles_, 198 &gdi_current_handles_,
198 &gdi_peak_handles_, 199 &gdi_peak_handles_,
199 &user_current_handles_, 200 &user_current_handles_,
200 &user_peak_handles_); 201 &user_peak_handles_);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 236 }
236 #endif // defined(OS_LINUX) 237 #endif // defined(OS_LINUX)
237 238
238 void TaskGroup::OnProcessPriorityDone(bool is_backgrounded) { 239 void TaskGroup::OnProcessPriorityDone(bool is_backgrounded) {
239 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 240 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
240 241
241 is_backgrounded_ = is_backgrounded; 242 is_backgrounded_ = is_backgrounded;
242 } 243 }
243 244
244 } // namespace task_management 245 } // namespace task_management
OLDNEW
« no previous file with comments | « chrome/browser/task_management/sampling/task_group.h ('k') | chrome/browser/task_management/sampling/task_group_sampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698