diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-19 01:57:39 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-19 01:57:39 +0000 |
commit | d2ed2383f5820e1fc26c9ac709b00bc8cdc8d086 (patch) | |
tree | 361278c499794f39d2b5c3c218fc59a7a98f7016 /base/process_util_posix.cc | |
parent | c2788ecbcd5c443fb129f63b7b86f83e944b4950 (diff) | |
download | chromium_src-d2ed2383f5820e1fc26c9ac709b00bc8cdc8d086.zip chromium_src-d2ed2383f5820e1fc26c9ac709b00bc8cdc8d086.tar.gz chromium_src-d2ed2383f5820e1fc26c9ac709b00bc8cdc8d086.tar.bz2 |
linux: implement GetCPUUsage() so the task manager shows CPU
Discussed in part here:
http://groups.google.com/group/chromium-dev/browse_thread/thread/8e91f66f9af6ccec
This implements option 3, which turned out to be pretty simple.
BUG=19864
Review URL: http://codereview.chromium.org/215020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26647 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_posix.cc')
-rw-r--r-- | base/process_util_posix.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index a26b4d3..235456b 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -305,7 +305,11 @@ bool LaunchApp(const CommandLine& cl, ProcessMetrics::ProcessMetrics(ProcessHandle process) : process_(process), last_time_(0), - last_system_time_(0) { + last_system_time_(0) +#if defined(OS_LINUX) + , last_cpu_(0) +#endif +{ processor_count_ = base::SysInfo::NumberOfProcessors(); } @@ -463,14 +467,13 @@ bool CrashAwareSleep(ProcessHandle handle, int64 wait_milliseconds) { } } -namespace { - int64 TimeValToMicroseconds(const struct timeval& tv) { return tv.tv_sec * kMicrosecondsPerSecond + tv.tv_usec; } -} - +#if defined(OS_MACOSX) +// TODO(port): this function only returns the *current* CPU's usage; +// we want to return this->process_'s CPU usage. int ProcessMetrics::GetCPUUsage() { struct timeval now; struct rusage usage; @@ -509,6 +512,7 @@ int ProcessMetrics::GetCPUUsage() { return cpu; } +#endif bool GetAppOutput(const CommandLine& cl, std::string* output) { int pipe_fd[2]; |