Fill in PlatformPrivateFootprint on Linux 2/2
This CL populates the vm_swap_bytes field of the PlatformPrivateFootprint
struct on Linux.
The struct contains platform specific numbers that will be used by the
memory-infra service to compute the private memory footprint of the
process.
BUG=707019
Review-Url: https://codereview.chromium.org/2866723002
Cr-Commit-Position: refs/heads/master@{#472321}
CrOS-Libchrome-Original-Commit: bae6b3bcfa9dccd18b061beafcb17d0dbd39a7c9
diff --git a/base/process/process_metrics.h b/base/process/process_metrics.h
index 9747a1c..fbbdb88 100644
--- a/base/process/process_metrics.h
+++ b/base/process/process_metrics.h
@@ -225,6 +225,11 @@
int GetOpenFdSoftLimit() const;
#endif // defined(OS_LINUX) || defined(OS_AIX)
+#if defined(OS_LINUX) || defined(OS_ANDROID)
+ // Bytes of swap as reported by /proc/[pid]/status.
+ uint64_t GetVmSwapBytes() const;
+#endif // defined(OS_LINUX) || defined(OS_ANDROID)
+
private:
#if !defined(OS_MACOSX) || defined(OS_IOS)
explicit ProcessMetrics(ProcessHandle process);
diff --git a/base/process/process_metrics_linux.cc b/base/process/process_metrics_linux.cc
index 1dde0d9..7f2897e 100644
--- a/base/process/process_metrics_linux.cc
+++ b/base/process/process_metrics_linux.cc
@@ -289,6 +289,12 @@
return true;
}
+#if defined(OS_LINUX) || defined(OS_ANDROID)
+uint64_t ProcessMetrics::GetVmSwapBytes() const {
+ return ReadProcStatusAndGetFieldAsSizeT(process_, "VmSwap") * 1024;
+}
+#endif // defined(OS_LINUX) || defined(OS_ANDROID)
+
#if defined(OS_LINUX) || defined(OS_AIX)
int ProcessMetrics::GetOpenFdCount() const {
// Use /proc/<pid>/fd to count the number of entries there.