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

Side by Side Diff: base/process/process_metrics_linux.cc

Issue 2839733004: Fill in PlatformPrivateFootprint on Linux (Closed)
Patch Set: update for parent patch changes Created 3 years, 8 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/process/process_metrics.h" 5 #include "base/process/process_metrics.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 target_counter = &io_counters->WriteTransferCount; 287 target_counter = &io_counters->WriteTransferCount;
288 if (!target_counter) 288 if (!target_counter)
289 continue; 289 continue;
290 bool converted = StringToUint64(value_str, target_counter); 290 bool converted = StringToUint64(value_str, target_counter);
291 DCHECK(converted); 291 DCHECK(converted);
292 } 292 }
293 return true; 293 return true;
294 } 294 }
295 295
296 #if defined(OS_LINUX) 296 #if defined(OS_LINUX)
297
298 uint64_t ProcessMetrics::GetVmSwapBytes() const {
299 return ReadProcStatusAndGetFieldAsSizeT(process_, "VmSwap") * 1024;
300 }
301
302 uint64_t ProcessMetrics::GetRssAnonBytes() const {
303 size_t private_bytes;
304 size_t shared_bytes;
305 bool ret = GetMemoryBytes(&private_bytes, &shared_bytes);
306 if (!ret)
307 return 0;
308 return private_bytes;
309 }
310
297 int ProcessMetrics::GetOpenFdCount() const { 311 int ProcessMetrics::GetOpenFdCount() const {
298 // Use /proc/<pid>/fd to count the number of entries there. 312 // Use /proc/<pid>/fd to count the number of entries there.
299 FilePath fd_path = internal::GetProcPidDir(process_).Append("fd"); 313 FilePath fd_path = internal::GetProcPidDir(process_).Append("fd");
300 314
301 DirReaderPosix dir_reader(fd_path.value().c_str()); 315 DirReaderPosix dir_reader(fd_path.value().c_str());
302 if (!dir_reader.IsValid()) 316 if (!dir_reader.IsValid())
303 return -1; 317 return -1;
304 318
305 int total_count = 0; 319 int total_count = 0;
306 for (; dir_reader.Next(); ) { 320 for (; dir_reader.Next(); ) {
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 #if defined(OS_LINUX) 974 #if defined(OS_LINUX)
961 int ProcessMetrics::GetIdleWakeupsPerSecond() { 975 int ProcessMetrics::GetIdleWakeupsPerSecond() {
962 uint64_t wake_ups; 976 uint64_t wake_ups;
963 const char kWakeupStat[] = "se.statistics.nr_wakeups"; 977 const char kWakeupStat[] = "se.statistics.nr_wakeups";
964 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? 978 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ?
965 CalculateIdleWakeupsPerSecond(wake_ups) : 0; 979 CalculateIdleWakeupsPerSecond(wake_ups) : 0;
966 } 980 }
967 #endif // defined(OS_LINUX) 981 #endif // defined(OS_LINUX)
968 982
969 } // namespace base 983 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698