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

Side by Side Diff: base/process/internal_linux.h

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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/base.gypi ('k') | base/process/internal_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains internal routines that are called by other files in 5 // This file contains internal routines that are called by other files in
6 // base/process/. 6 // base/process/.
7 7
8 #ifndef BASE_PROCESS_LINUX_INTERNAL_H_ 8 #ifndef BASE_PROCESS_LINUX_INTERNAL_H_
9 #define BASE_PROCESS_LINUX_INTERNAL_H_ 9 #define BASE_PROCESS_LINUX_INTERNAL_H_
10 10
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 12
13 namespace base { 13 namespace base {
14
15 class Time;
16 class TimeDelta;
17
14 namespace internal { 18 namespace internal {
15 19
16 // "/proc" 20 // "/proc"
17 extern const char kProcDir[]; 21 extern const char kProcDir[];
18 22
19 // "stat" 23 // "stat"
20 extern const char kStatFile[]; 24 extern const char kStatFile[];
21 25
22 // Returns a FilePath to "/proc/pid". 26 // Returns a FilePath to "/proc/pid".
23 base::FilePath GetProcPidDir(pid_t pid); 27 base::FilePath GetProcPidDir(pid_t pid);
(...skipping 18 matching lines...) Expand all
42 // If the ordering ever changes, carefully review functions that use these 46 // If the ordering ever changes, carefully review functions that use these
43 // values. 47 // values.
44 enum ProcStatsFields { 48 enum ProcStatsFields {
45 VM_COMM = 1, // Filename of executable, without parentheses. 49 VM_COMM = 1, // Filename of executable, without parentheses.
46 VM_STATE = 2, // Letter indicating the state of the process. 50 VM_STATE = 2, // Letter indicating the state of the process.
47 VM_PPID = 3, // PID of the parent. 51 VM_PPID = 3, // PID of the parent.
48 VM_PGRP = 4, // Process group id. 52 VM_PGRP = 4, // Process group id.
49 VM_UTIME = 13, // Time scheduled in user mode in clock ticks. 53 VM_UTIME = 13, // Time scheduled in user mode in clock ticks.
50 VM_STIME = 14, // Time scheduled in kernel mode in clock ticks. 54 VM_STIME = 14, // Time scheduled in kernel mode in clock ticks.
51 VM_NUMTHREADS = 19, // Number of threads. 55 VM_NUMTHREADS = 19, // Number of threads.
56 VM_STARTTIME = 21, // The time the process started in clock ticks.
52 VM_VSIZE = 22, // Virtual memory size in bytes. 57 VM_VSIZE = 22, // Virtual memory size in bytes.
53 VM_RSS = 23, // Resident Set Size in pages. 58 VM_RSS = 23, // Resident Set Size in pages.
54 }; 59 };
55 60
56 // Reads the |field_num|th field from |proc_stats|. Returns 0 on failure. 61 // Reads the |field_num|th field from |proc_stats|. Returns 0 on failure.
57 // This version does not handle the first 3 values, since the first value is 62 // This version does not handle the first 3 values, since the first value is
58 // simply |pid|, and the next two values are strings. 63 // simply |pid|, and the next two values are strings.
59 int GetProcStatsFieldAsInt(const std::vector<std::string>& proc_stats, 64 int GetProcStatsFieldAsInt(const std::vector<std::string>& proc_stats,
60 ProcStatsFields field_num); 65 ProcStatsFields field_num);
61 66
62 // Same as GetProcStatsFieldAsInt(), but for size_t values. 67 // Same as GetProcStatsFieldAsInt(), but for size_t values.
63 size_t GetProcStatsFieldAsSizeT(const std::vector<std::string>& proc_stats, 68 size_t GetProcStatsFieldAsSizeT(const std::vector<std::string>& proc_stats,
64 ProcStatsFields field_num); 69 ProcStatsFields field_num);
65 70
66 // Convenience wrapper around GetProcStatsFieldAsInt(), ParseProcStats() and 71 // Convenience wrapper around GetProcStatsFieldAsInt(), ParseProcStats() and
67 // ReadProcStats(). See GetProcStatsFieldAsInt() for details. 72 // ReadProcStats(). See GetProcStatsFieldAsInt() for details.
68 int ReadProcStatsAndGetFieldAsInt(pid_t pid, 73 int ReadProcStatsAndGetFieldAsInt(pid_t pid,
69 ProcStatsFields field_num); 74 ProcStatsFields field_num);
70 75
71 // Same as ReadProcStatsAndGetFieldAsInt() but for size_t values. 76 // Same as ReadProcStatsAndGetFieldAsInt() but for size_t values.
72 size_t ReadProcStatsAndGetFieldAsSizeT(pid_t pid, 77 size_t ReadProcStatsAndGetFieldAsSizeT(pid_t pid,
73 ProcStatsFields field_num); 78 ProcStatsFields field_num);
74 79
80 // Returns the time that the OS started. Clock ticks are relative to this.
81 Time GetBootTime();
82
83 // Converts Linux clock ticks to a wall time delta.
84 TimeDelta ClockTicksToTimeDelta(int clock_ticks);
85
75 } // namespace internal 86 } // namespace internal
76 } // namespace base 87 } // namespace base
77 88
78 #endif // BASE_PROCESS_LINUX_INTERNAL_H_ 89 #endif // BASE_PROCESS_LINUX_INTERNAL_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/process/internal_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698