summaryrefslogtreecommitdiff
path: root/base/process/process_metrics.h
diff options
context:
space:
mode:
authorJay Civelli <jcivelli@google.com>2017-07-26 02:01:17 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-07-26 02:01:17 +0000
commitca61a35797e9323748ace7b78ee93e192eae0048 (patch)
treece481b397e704599e05c63cc5856d4d63389026c /base/process/process_metrics.h
parent11599ae47dfe0591c6bd4e91ac25f5e8acf2e906 (diff)
parenta29e6994243913703862fdbe17c059150c9ae149 (diff)
downloadlibchrome-ca61a35797e9323748ace7b78ee93e192eae0048.tar.gz
libchrome: Uprev the library to r456626 from Chromium am: 0601274935 am: 0457669b85
am: a29e699424 Change-Id: Ida7cdb6a099062c27bb5e0e57767e5f1f5274432
Diffstat (limited to 'base/process/process_metrics.h')
-rw-r--r--base/process/process_metrics.h32
1 files changed, 21 insertions, 11 deletions
diff --git a/base/process/process_metrics.h b/base/process/process_metrics.h
index 57cb3abec0..71d6042e00 100644
--- a/base/process/process_metrics.h
+++ b/base/process/process_metrics.h
@@ -11,6 +11,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include <string>
#include "base/base_export.h"
@@ -103,22 +104,22 @@ class BASE_EXPORT ProcessMetrics {
~ProcessMetrics();
// Creates a ProcessMetrics for the specified process.
- // The caller owns the returned object.
#if !defined(OS_MACOSX) || defined(OS_IOS)
- static ProcessMetrics* CreateProcessMetrics(ProcessHandle process);
+ static std::unique_ptr<ProcessMetrics> CreateProcessMetrics(
+ ProcessHandle process);
#else
// The port provider needs to outlive the ProcessMetrics object returned by
// this function. If NULL is passed as provider, the returned object
// only returns valid metrics if |process| is the current process.
- static ProcessMetrics* CreateProcessMetrics(ProcessHandle process,
- PortProvider* port_provider);
+ static std::unique_ptr<ProcessMetrics> CreateProcessMetrics(
+ ProcessHandle process,
+ PortProvider* port_provider);
#endif // !defined(OS_MACOSX) || defined(OS_IOS)
// Creates a ProcessMetrics for the current process. This a cross-platform
// convenience wrapper for CreateProcessMetrics().
- // The caller owns the returned object.
- static ProcessMetrics* CreateCurrentProcessMetrics();
+ static std::unique_ptr<ProcessMetrics> CreateCurrentProcessMetrics();
// Returns the current space allocated for the pagefile, in bytes (these pages
// may or may not be in memory). On Linux, this returns the total virtual
@@ -135,8 +136,7 @@ class BASE_EXPORT ProcessMetrics {
// memory currently allocated to a process that cannot be shared. Returns
// false on platform specific error conditions. Note: |private_bytes|
// returns 0 on unsupported OSes: prior to XP SP2.
- bool GetMemoryBytes(size_t* private_bytes,
- size_t* shared_bytes);
+ bool GetMemoryBytes(size_t* private_bytes, size_t* shared_bytes) const;
// Fills a CommittedKBytes with both resident and paged
// memory usage as per definition of CommittedBytes.
void GetCommittedKBytes(CommittedKBytes* usage) const;
@@ -144,6 +144,9 @@ class BASE_EXPORT ProcessMetrics {
// usage in bytes, as per definition of WorkingSetBytes. Note that this
// function is somewhat expensive on Windows (a few ms per process).
bool GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const;
+ // Computes pss (proportional set size) of a process. Note that this
+ // function is somewhat expensive on Windows (a few ms per process).
+ bool GetProportionalSetSizeBytes(uint64_t* pss_bytes) const;
#if defined(OS_MACOSX)
// Fills both CommitedKBytes and WorkingSetKBytes in a single operation. This
@@ -151,6 +154,10 @@ class BASE_EXPORT ProcessMetrics {
// system call.
bool GetCommittedAndWorkingSetKBytes(CommittedKBytes* usage,
WorkingSetKBytes* ws_usage) const;
+ // Returns private, shared, and total resident bytes.
+ bool GetMemoryBytes(size_t* private_bytes,
+ size_t* shared_bytes,
+ size_t* resident_bytes) const;
#endif
// Returns the CPU usage in percent since the last time this method or
@@ -295,9 +302,9 @@ struct BASE_EXPORT SystemMemoryInfoKB {
int dirty;
// vmstats data.
- int pswpin;
- int pswpout;
- int pgmajfault;
+ unsigned long pswpin;
+ unsigned long pswpout;
+ unsigned long pgmajfault;
#endif // defined(OS_ANDROID) || defined(OS_LINUX)
#if defined(OS_CHROMEOS)
@@ -374,6 +381,9 @@ BASE_EXPORT bool IsValidDiskName(const std::string& candidate);
// Retrieves data from /proc/diskstats about system-wide disk I/O.
// Fills in the provided |diskinfo| structure. Returns true on success.
BASE_EXPORT bool GetSystemDiskInfo(SystemDiskInfo* diskinfo);
+
+// Returns the amount of time spent in user space since boot across all CPUs.
+BASE_EXPORT TimeDelta GetUserCpuTimeSinceBoot();
#endif // defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_CHROMEOS)