summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-15 22:08:55 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-15 22:08:55 +0000
commita425003c6df626407c31625e2ac9a62f311b9a16 (patch)
treeb2ad21d2c11e045bf362a8c8498c8d59005406d3 /base
parent056419155bdb4bd477c340293fd449d276fa9e3a (diff)
downloadchromium_src-a425003c6df626407c31625e2ac9a62f311b9a16.zip
chromium_src-a425003c6df626407c31625e2ac9a62f311b9a16.tar.gz
chromium_src-a425003c6df626407c31625e2ac9a62f311b9a16.tar.bz2
Linux: Allow IO in ProcessMetrics::GetWorkingSetKBytes().
BUG=61340 TEST=Opening up the task manager on Linux in debug mode does not assert. Review URL: http://codereview.chromium.org/5928001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69331 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/process_util_linux.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc
index 4627aa5..ff5e9316 100644
--- a/base/process_util_linux.cc
+++ b/base/process_util_linux.cc
@@ -319,13 +319,20 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const {
// 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 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const {
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;