Index: base/process/process_info_linux.cc |
diff --git a/base/process/process_info_linux.cc b/base/process/process_info_linux.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6d10543562e740fa9e7df8120c649e327ed2ecda |
--- /dev/null |
+++ b/base/process/process_info_linux.cc |
@@ -0,0 +1,45 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/process/process_info.h" |
+ |
+#include <sys/types.h> |
+#include <unistd.h> |
+ |
+#include "base/file_util.h" |
+#include "base/files/file_path.h" |
+#include "base/platform_file.h" |
+#include "base/strings/stringprintf.h" |
+#include "base/threading/thread_restrictions.h" |
+#include "base/time/time.h" |
+ |
+using base::Time; |
+ |
+namespace { |
+ |
+// Returns the process creation time, or NULL if an error occurred. |
+Time* ProcessCreationTimeInternal() { |
+ const base::FilePath pid_path(base::StringPrintf("/proc/%d", getpid())); |
+ base::PlatformFileInfo file_info; |
+ |
+ { |
+ base::ThreadRestrictions::ScopedAllowIO nonblocking_stat_of_proc_subdir; |
+ if (!file_util::GetFileInfo(pid_path, &file_info)) |
darin (slow to review)
2013/08/07 22:30:34
maybe the code that complains about GetFileInfo be
|
+ return NULL; |
+ } |
+ |
+ return new Time(file_info.creation_time); |
+} |
+ |
+} // namespace |
+ |
+namespace base { |
+ |
+// static |
+const Time* CurrentProcessInfo::CreationTime() { |
+ static Time* process_creation_time = ProcessCreationTimeInternal(); |
+ return process_creation_time; |
+} |
+ |
+} // namespace base |