summaryrefslogtreecommitdiffstats
path: root/base/process_util.h
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-19 04:50:04 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-19 04:50:04 +0000
commit3740cb9b54f6a5d28c3501b650b7c179101568eb (patch)
tree848c46b9b75018e0fc60edf715e068bf5cc87c24 /base/process_util.h
parent0ec9512a65f8d7f15dbddd902363994660d85ffb (diff)
downloadchromium_src-3740cb9b54f6a5d28c3501b650b7c179101568eb.zip
chromium_src-3740cb9b54f6a5d28c3501b650b7c179101568eb.tar.gz
chromium_src-3740cb9b54f6a5d28c3501b650b7c179101568eb.tar.bz2
Revert 35025 - Revert 34994, maybe it regressed startup perf Fix cpu/memory measurements on OS X.
Right now, this only works for the current process; support for child processes will be added in a later CL. BUG=13156,25454 TEST=Hook up task manager (connect menu item to commandDispatch:, give it the right tag). Stats for the browser process should now be right, and %cpu should be 0 (for now) for all other processes. Review URL: http://codereview.chromium.org/500118 TBR=thakis@chromium.org Review URL: http://codereview.chromium.org/504068 TBR=thakis@chromium.org Review URL: http://codereview.chromium.org/505056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35043 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util.h')
-rw-r--r--base/process_util.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/base/process_util.h b/base/process_util.h
index 1122de7..2bb5396 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 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();
@@ -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)
+ // Queries the port provider if it's set.
+ mach_port_t TaskForPid(ProcessHandle process) const;
+
+ PortProvider* port_provider_;
+#endif
+
DISALLOW_EVIL_CONSTRUCTORS(ProcessMetrics);
};