Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| OLD | NEW |