Index: base/process_util.h |
=================================================================== |
--- base/process_util.h (revision 35042) |
+++ base/process_util.h (working copy) |
@@ -317,6 +317,11 @@ |
// priv: Pages mapped only by this process |
// shared: PSS or 0 if the kernel doesn't support this |
// shareable: 0 |
+// |
+// On OS X: TODO(thakis): Revise. |
+// priv: Memory. |
+// shared: 0 |
+// shareable: 0 |
struct WorkingSetKBytes { |
WorkingSetKBytes() : priv(0), shareable(0), shared(0) {} |
size_t priv; |
@@ -359,8 +364,24 @@ |
public: |
// Creates a ProcessMetrics for the specified process. |
// The caller owns the returned object. |
+#if !defined(OS_MACOSX) |
static ProcessMetrics* CreateProcessMetrics(ProcessHandle process); |
+#else |
+ class PortProvider { |
+ public: |
+ // Should return the mach task for |process| if possible, or else 0. Only |
+ // processes that this returns tasks for will have metrics on OS X (except |
+ // for the current process, which always gets metrics). |
+ virtual mach_port_t TaskForPid(ProcessHandle process) const = 0; |
+ }; |
+ // 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); |
+#endif |
+ |
~ProcessMetrics(); |
// Returns the current space allocated for the pagefile, in bytes (these pages |
@@ -407,7 +428,11 @@ |
bool GetIOCounters(IoCounters* io_counters) const; |
private: |
+#if !defined(OS_MACOSX) |
explicit ProcessMetrics(ProcessHandle process); |
+#else |
+ ProcessMetrics(ProcessHandle process, PortProvider* port_provider); |
+#endif |
ProcessHandle process_; |
@@ -423,6 +448,13 @@ |
int last_cpu_; |
#endif |
+#if defined(OS_MACOSX) |
+ // Queries the port provider if it's set. |
+ mach_port_t TaskForPid(ProcessHandle process) const; |
+ |
+ PortProvider* port_provider_; |
+#endif |
+ |
DISALLOW_EVIL_CONSTRUCTORS(ProcessMetrics); |
}; |