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

Unified Diff: base/process/process_metrics_linux.cc

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 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/process_metrics.h ('k') | base/process/process_metrics_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/process_metrics_linux.cc
diff --git a/base/process/process_metrics_linux.cc b/base/process/process_metrics_linux.cc
index c564a6798baa6623a3646c35822b5041e1e5ad47..0da1ec3e1adb3003e0617729dcefcf1e1cad2075 100644
--- a/base/process/process_metrics_linux.cc
+++ b/base/process/process_metrics_linux.cc
@@ -563,17 +563,15 @@ bool ParseProcMeminfo(const std::string& meminfo_data,
// MemTotal value
meminfo->total = 0;
- std::vector<std::string> meminfo_lines;
- Tokenize(meminfo_data, "\n", &meminfo_lines);
- for (std::vector<std::string>::iterator it = meminfo_lines.begin();
- it != meminfo_lines.end(); ++it) {
- std::vector<std::string> tokens;
- SplitStringAlongWhitespace(*it, &tokens);
+ for (const StringPiece& line : SplitStringPiece(
+ meminfo_data, "\n", KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY)) {
+ std::vector<StringPiece> tokens = SplitStringPiece(
+ line, kWhitespaceASCII, TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY);
// HugePages_* only has a number and no suffix so we can't rely on
// there being exactly 3 tokens.
if (tokens.size() <= 1) {
DLOG(WARNING) << "meminfo: tokens: " << tokens.size()
- << " malformed line: " << *it;
+ << " malformed line: " << line.as_string();
continue;
}
@@ -630,12 +628,10 @@ bool ParseProcVmstat(const std::string& vmstat_data,
// We iterate through the whole file because the position of the
// fields are dependent on the kernel version and configuration.
- std::vector<std::string> vmstat_lines;
- Tokenize(vmstat_data, "\n", &vmstat_lines);
- for (std::vector<std::string>::iterator it = vmstat_lines.begin();
- it != vmstat_lines.end(); ++it) {
- std::vector<std::string> tokens;
- SplitString(*it, ' ', &tokens);
+ for (const StringPiece& line : SplitStringPiece(
+ vmstat_data, "\n", KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY)) {
+ std::vector<StringPiece> tokens =
+ SplitStringPiece(line, " ", KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY);
if (tokens.size() != 2)
continue;
@@ -792,9 +788,9 @@ bool GetSystemDiskInfo(SystemDiskInfo* diskinfo) {
return false;
}
- std::vector<std::string> diskinfo_lines;
- size_t line_count = Tokenize(diskinfo_data, "\n", &diskinfo_lines);
- if (line_count == 0) {
+ std::vector<StringPiece> diskinfo_lines = SplitStringPiece(
+ diskinfo_data, "\n", KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY);
+ if (diskinfo_lines.size() == 0) {
DLOG(WARNING) << "No lines found";
return false;
}
@@ -823,12 +819,12 @@ bool GetSystemDiskInfo(SystemDiskInfo* diskinfo) {
uint64 io_time = 0;
uint64 weighted_io_time = 0;
- for (size_t i = 0; i < line_count; i++) {
- std::vector<std::string> disk_fields;
- SplitStringAlongWhitespace(diskinfo_lines[i], &disk_fields);
+ for (const StringPiece& line : diskinfo_lines) {
+ std::vector<StringPiece> disk_fields = SplitStringPiece(
+ line, kWhitespaceASCII, TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY);
// Fields may have overflowed and reset to zero.
- if (IsValidDiskName(disk_fields[kDiskDriveName])) {
+ if (IsValidDiskName(disk_fields[kDiskDriveName].as_string())) {
StringToUint64(disk_fields[kDiskReads], &reads);
StringToUint64(disk_fields[kDiskReadsMerged], &reads_merged);
StringToUint64(disk_fields[kDiskSectorsRead], &sectors_read);
« no previous file with comments | « base/process/process_metrics.h ('k') | base/process/process_metrics_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698