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

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

Issue 2740423002: mac: Fix calulation for number of resident pages in a process. (Closed)
Patch Set: comments from mark. Created 3 years, 9 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_sampler.h" 5 #include "chrome/browser/task_manager/sampling/task_group_sampler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequence()); 119 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequence());
120 120
121 return process_metrics_->GetCPUUsage(); 121 return process_metrics_->GetCPUUsage();
122 } 122 }
123 123
124 MemoryUsageStats TaskGroupSampler::RefreshMemoryUsage() { 124 MemoryUsageStats TaskGroupSampler::RefreshMemoryUsage() {
125 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequence()); 125 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequence());
126 126
127 MemoryUsageStats memory_usage; 127 MemoryUsageStats memory_usage;
128 #if defined(OS_MACOSX) 128 #if defined(OS_MACOSX)
129 memory_usage.physical_bytes =
130 static_cast<int64_t>(process_metrics_->GetWorkingSetSize());
131
132 size_t private_bytes = 0; 129 size_t private_bytes = 0;
133 size_t shared_bytes = 0; 130 size_t shared_bytes = 0;
134 if (process_metrics_->GetMemoryBytes(&private_bytes, &shared_bytes)) { 131 size_t resident_bytes = 0;
132 if (process_metrics_->GetMemoryBytes(&private_bytes, &shared_bytes,
133 &resident_bytes)) {
135 memory_usage.private_bytes = static_cast<int64_t>(private_bytes); 134 memory_usage.private_bytes = static_cast<int64_t>(private_bytes);
136 memory_usage.shared_bytes = static_cast<int64_t>(shared_bytes); 135 memory_usage.shared_bytes = static_cast<int64_t>(shared_bytes);
136 memory_usage.physical_bytes = resident_bytes;
137 } 137 }
138 #else 138 #else
139 // Refreshing the physical/private/shared memory at one shot. 139 // Refreshing the physical/private/shared memory at one shot.
140 base::WorkingSetKBytes ws_usage; 140 base::WorkingSetKBytes ws_usage;
141 if (process_metrics_->GetWorkingSetKBytes(&ws_usage)) { 141 if (process_metrics_->GetWorkingSetKBytes(&ws_usage)) {
142 memory_usage.private_bytes = static_cast<int64_t>(ws_usage.priv * 1024); 142 memory_usage.private_bytes = static_cast<int64_t>(ws_usage.priv * 1024);
143 memory_usage.shared_bytes = static_cast<int64_t>(ws_usage.shared * 1024); 143 memory_usage.shared_bytes = static_cast<int64_t>(ws_usage.shared * 1024);
144 #if defined(OS_LINUX) 144 #if defined(OS_LINUX)
145 // On Linux private memory is also resident. Just use it. 145 // On Linux private memory is also resident. Just use it.
146 memory_usage.physical_bytes = memory_usage.private_bytes; 146 memory_usage.physical_bytes = memory_usage.private_bytes;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequence()); 183 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequence());
184 #if defined(OS_MACOSX) 184 #if defined(OS_MACOSX)
185 return process_.IsProcessBackgrounded( 185 return process_.IsProcessBackgrounded(
186 content::BrowserChildProcessHost::GetPortProvider()); 186 content::BrowserChildProcessHost::GetPortProvider());
187 #else 187 #else
188 return process_.IsProcessBackgrounded(); 188 return process_.IsProcessBackgrounded();
189 #endif // defined(OS_MACOSX) 189 #endif // defined(OS_MACOSX)
190 } 190 }
191 191
192 } // namespace task_manager 192 } // namespace task_manager
OLDNEW
« no previous file with comments | « base/process/process_metrics_win.cc ('k') | components/tracing/common/process_metrics_memory_dump_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698