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

Unified Diff: base/process/internal_linux.cc

Issue 2715583002: base/process: Use /proc/self/stat to read startup time. (Closed)
Patch Set: Address jln comments. Created 3 years, 10 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/process/internal_linux.h ('k') | base/process/process_info_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/internal_linux.cc
diff --git a/base/process/internal_linux.cc b/base/process/internal_linux.cc
index e9ed641dc02909c4b4edea18be5508c630c5527f..c7820040ceccd4b8839f11ef808b23358fe2a8a9 100644
--- a/base/process/internal_linux.cc
+++ b/base/process/internal_linux.cc
@@ -133,9 +133,10 @@ size_t GetProcStatsFieldAsSizeT(const std::vector<std::string>& proc_stats,
return StringToSizeT(proc_stats[field_num], &value) ? value : 0;
}
-int64_t ReadProcStatsAndGetFieldAsInt64(pid_t pid, ProcStatsFields field_num) {
+int64_t ReadStatFileAndGetFieldAsInt64(const FilePath& stat_file,
+ ProcStatsFields field_num) {
std::string stats_data;
- if (!ReadProcStats(pid, &stats_data))
+ if (!ReadProcFile(stat_file, &stats_data))
return 0;
std::vector<std::string> proc_stats;
if (!ParseProcStats(stats_data, &proc_stats))
@@ -143,6 +144,16 @@ int64_t ReadProcStatsAndGetFieldAsInt64(pid_t pid, ProcStatsFields field_num) {
return GetProcStatsFieldAsInt64(proc_stats, field_num);
}
+int64_t ReadProcStatsAndGetFieldAsInt64(pid_t pid, ProcStatsFields field_num) {
+ FilePath stat_file = internal::GetProcPidDir(pid).Append(kStatFile);
+ return ReadStatFileAndGetFieldAsInt64(stat_file, field_num);
+}
+
+int64_t ReadProcSelfStatsAndGetFieldAsInt64(ProcStatsFields field_num) {
+ FilePath stat_file = FilePath(kProcDir).Append("self").Append(kStatFile);
+ return ReadStatFileAndGetFieldAsInt64(stat_file, field_num);
+}
+
size_t ReadProcStatsAndGetFieldAsSizeT(pid_t pid,
ProcStatsFields field_num) {
std::string stats_data;
« no previous file with comments | « base/process/internal_linux.h ('k') | base/process/process_info_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698