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

Unified Diff: chrome/browser/process_info_snapshot_mac.cc

Issue 583193006: mac: Disable parts of ProcessInfoSnapshotMacTest on OSX 10.9+. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit test & logic. Created 6 years, 3 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 | « no previous file | chrome/browser/process_info_snapshot_mac_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/process_info_snapshot_mac.cc
diff --git a/chrome/browser/process_info_snapshot_mac.cc b/chrome/browser/process_info_snapshot_mac.cc
index 36d505c57032ed5d6cb4680c95f293e5fd4fc16e..fba77f88a9f71244d224e7ca1cc56722043f9488 100644
--- a/chrome/browser/process_info_snapshot_mac.cc
+++ b/chrome/browser/process_info_snapshot_mac.cc
@@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
+#include "base/mac/mac_util.h"
#include "base/process/launch.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@@ -167,9 +168,9 @@ static bool GetProcessMemoryInfoUsingPS(
in >> proc_info.vsize;
proc_info.rss *= 1024; // Convert from kilobytes to bytes.
proc_info.vsize *= 1024;
- in.ignore(1, ' '); // Eat the space.
- std::getline(in, proc_info.command); // Get the rest of the line.
- if (!in.good()) {
+
+ // If the fail or bad bits were set, then there was an error reading input.
+ if (in.fail()) {
LOG(ERROR) << "Error parsing output from " << kProgram.value() << ".";
return false;
}
@@ -181,6 +182,9 @@ static bool GetProcessMemoryInfoUsingPS(
// Record the process information.
proc_info_entries[proc_info.pid] = proc_info;
+
+ // Ignore the rest of the line.
+ in.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
return true;
@@ -309,6 +313,13 @@ bool ProcessInfoSnapshot::Sample(std::vector<base::ProcessId> pid_list) {
}
}
+ // In OSX 10.9+, top no longer returns any useful information. 'rshrd' is no
+ // longer supported, and 'rprvt' and 'vsize' return N/A. 'rsize' still works,
+ // but the information is also available from ps.
+ // http://crbug.com/383553
+ if (base::mac::IsOSMavericksOrLater())
+ return GetProcessMemoryInfoUsingPS(pid_list, proc_info_entries_);
+
// Get memory information using top.
bool memory_info_success = GetProcessMemoryInfoUsingTop(proc_info_entries_);
« no previous file with comments | « no previous file | chrome/browser/process_info_snapshot_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698