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

Unified Diff: base/process_util_linux.cc

Issue 5928001: Linux: Allow IO in ProcessMetrics::GetWorkingSetKBytes().... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_linux.cc
===================================================================
--- base/process_util_linux.cc (revision 69306)
+++ base/process_util_linux.cc (working copy)
@@ -319,13 +319,20 @@
// Synchronously reading files in /proc is safe.
base::ThreadRestrictions::ScopedAllowIO allow_io;
- FilePath stat_file =
- FilePath("/proc").Append(base::IntToString(process_)).Append("smaps");
+ FilePath proc_dir = FilePath("/proc").Append(base::IntToString(process_));
std::string smaps;
int private_kb = 0;
int pss_kb = 0;
bool have_pss = false;
- if (file_util::ReadFileToString(stat_file, &smaps) && smaps.length() > 0) {
+ bool ret;
+
+ {
+ FilePath smaps_file = proc_dir.Append("smaps");
+ // Synchronously reading files in /proc is safe.
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
+ ret = file_util::ReadFileToString(smaps_file, &smaps);
+ }
+ if (ret && smaps.length() > 0) {
const std::string private_prefix = "Private_";
const std::string pss_prefix = "Pss";
StringTokenizer tokenizer(smaps, ":\n");
@@ -363,10 +370,14 @@
if (page_size_kb <= 0)
return false;
- stat_file =
- FilePath("/proc").Append(base::IntToString(process_)).Append("statm");
std::string statm;
- if (!file_util::ReadFileToString(stat_file, &statm) || statm.length() == 0)
+ {
+ FilePath statm_file = proc_dir.Append("statm");
+ // Synchronously reading files in /proc is safe.
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
+ ret = file_util::ReadFileToString(statm_file, &statm);
+ }
+ if (!ret || statm.length() == 0)
return false;
std::vector<std::string> statm_vec;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698