Fix virtual memory column on chrome://memory on Mac.
This got broken by:
https://codereview.chromium.org/857063002/
Which stopped querying the metrics for Chrome processes
using PS/TOP.
This CL restores getting committed memory usage info,
but does it through ProcessMetrics (I verified that the
new approach returns the same values as the previous
code path that used PS/TOP).
Implements getting committed private memory in the Mac
implementation of ProcessMetrics and adds a new call -
GetCommittedAndWorkingSetKBytes() - that allows querying
both committed and working set memory in a single call.
Since the underlying implementation for both is done
using the same system call, this is more efficient as
we don't need to query the same info from the system twice.
BUG=451061
TEST=Open chrome://memory and verify that the "Virtual"
column has actual values in it for Chrome processes.
Review URL: https://codereview.chromium.org/865983002
Cr-Commit-Position: refs/heads/master@{#312736}
CrOS-Libchrome-Original-Commit: 57e53d315e9cc18680580c9249486ae8f9d888e3
diff --git a/base/process/process_metrics.h b/base/process/process_metrics.h
index d011958..5916b94 100644
--- a/base/process/process_metrics.h
+++ b/base/process/process_metrics.h
@@ -143,6 +143,14 @@
// usage in bytes, as per definition of WorkingSetBytes.
bool GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const;
+#if defined(OS_MACOSX)
+ // Fills both CommitedKBytes and WorkingSetKBytes in a single operation. This
+ // is more efficient on Mac OS X, as the two can be retrieved with a single
+ // system call.
+ bool GetCommittedAndWorkingSetKBytes(CommittedKBytes* usage,
+ WorkingSetKBytes* ws_usage) const;
+#endif
+
// Returns the CPU usage in percent since the last time this method or
// GetPlatformIndependentCPUUsage() was called. The first time this method
// is called it returns 0 and will return the actual CPU info on subsequent