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

Unified Diff: base/process/process_info_linux.cc

Issue 22594007: Implement CurrentProcessInfo::CreationTime() for Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add a ScopedAllowIO 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/base.gypi ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « base/base.gypi ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698