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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/base.gypi ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/process/process_info.h"
6
7 #include <sys/types.h>
8 #include <unistd.h>
9
10 #include "base/file_util.h"
11 #include "base/files/file_path.h"
12 #include "base/platform_file.h"
13 #include "base/strings/stringprintf.h"
14 #include "base/threading/thread_restrictions.h"
15 #include "base/time/time.h"
16
17 using base::Time;
18
19 namespace {
20
21 // Returns the process creation time, or NULL if an error occurred.
22 Time* ProcessCreationTimeInternal() {
23 const base::FilePath pid_path(base::StringPrintf("/proc/%d", getpid()));
24 base::PlatformFileInfo file_info;
25
26 {
27 base::ThreadRestrictions::ScopedAllowIO nonblocking_stat_of_proc_subdir;
28 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
29 return NULL;
30 }
31
32 return new Time(file_info.creation_time);
33 }
34
35 } // namespace
36
37 namespace base {
38
39 // static
40 const Time* CurrentProcessInfo::CreationTime() {
41 static Time* process_creation_time = ProcessCreationTimeInternal();
42 return process_creation_time;
43 }
44
45 } // namespace base
OLDNEW
« 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