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

Unified Diff: base/process_util.h

Issue 500118: Fix cpu/memory measurements on OS X. (Closed)
Patch Set: foobar Created 11 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/process_util_mac.mm » ('j') | base/process_util_mac.mm » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util.h
diff --git a/base/process_util.h b/base/process_util.h
index 1122de7fadab782e0bb3972734316b5e2e0cb6f7..2d330bab871d47660b9959eab9f725d9c551ca0c 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -317,6 +317,11 @@ class NamedProcessIterator {
// 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,7 +364,23 @@ class ProcessMetrics {
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 0 else. Only
Mark Mentovai 2009/12/18 22:18:24 move words around: , or else 0. , or otherwise 0.
Nico 2009/12/18 22:46:52 Done.
+ // 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. If NULL is passed as provider, only metrics for the current process
Mark Mentovai 2009/12/18 22:18:24 returned by this? That seems like English, but it
Nico 2009/12/18 22:46:52 Done.
+ // are
+ static ProcessMetrics* CreateProcessMetrics(ProcessHandle process,
+ PortProvider* port_provider);
+#endif
~ProcessMetrics();
@@ -407,7 +428,11 @@ class ProcessMetrics {
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 @@ class ProcessMetrics {
int last_cpu_;
#endif
+#if defined(OS_MACOSX)
+ PortProvider* port_provider_;
+
+ // Queries the port provider if it's set.
+ mach_port_t TaskForPid(ProcessHandle process) const;
Mark Mentovai 2009/12/18 22:18:24 Put functions before data members. I'd say it's O
Nico 2009/12/18 22:46:52 Done.
+#endif
+
DISALLOW_EVIL_CONSTRUCTORS(ProcessMetrics);
};
« no previous file with comments | « no previous file | base/process_util_mac.mm » ('j') | base/process_util_mac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698