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

Unified Diff: base/process/process_info_mac.cc

Issue 21302005: Add CurrentProcessInfo::CreationTime() for Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac Created 7 years, 4 months 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 | « base/process/process_info_linux.cc ('k') | base/process/process_info_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/process_info_mac.cc
diff --git a/base/process/process_info_mac.cc b/base/process/process_info_mac.cc
index d83acd11a128ec0c30dc498e021687f16a16d66c..ab8394b891d65a7ae032201b18f41ea43692a876 100644
--- a/base/process/process_info_mac.cc
+++ b/base/process/process_info_mac.cc
@@ -12,32 +12,20 @@
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
-namespace {
-
-using base::Time;
+namespace base {
-// Returns the process creation time, or NULL if an error occurred.
-Time* ProcessCreationTimeInternal() {
+//static
+const Time CurrentProcessInfo::CreationTime() {
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
size_t len = 0;
if (sysctl(mib, arraysize(mib), NULL, &len, NULL, 0) < 0)
- return NULL;
+ return Time();
scoped_ptr_malloc<struct kinfo_proc>
proc(static_cast<struct kinfo_proc*>(malloc(len)));
if (sysctl(mib, arraysize(mib), proc.get(), &len, NULL, 0) < 0)
- return NULL;
- return new Time(Time::FromTimeVal(proc->kp_proc.p_un.__p_starttime));
-}
-
-} // namespace
-
-namespace base {
-
-//static
-const Time* CurrentProcessInfo::CreationTime() {
- static Time* process_creation_time = ProcessCreationTimeInternal();
- return process_creation_time;
+ return Time();
+ return Time::FromTimeVal(proc->kp_proc.p_un.__p_starttime);
}
} // namespace base
« no previous file with comments | « base/process/process_info_linux.cc ('k') | base/process/process_info_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698