| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/process/internal_linux.h" | 5 #include "base/process/internal_linux.h" |
| 6 | 6 |
| 7 #include <unistd.h> | 7 #include <unistd.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 proc_stats->clear(); | 91 proc_stats->clear(); |
| 92 // PID. | 92 // PID. |
| 93 proc_stats->push_back(stats_data.substr(0, open_parens_idx)); | 93 proc_stats->push_back(stats_data.substr(0, open_parens_idx)); |
| 94 // Process name without parentheses. | 94 // Process name without parentheses. |
| 95 proc_stats->push_back( | 95 proc_stats->push_back( |
| 96 stats_data.substr(open_parens_idx + 1, | 96 stats_data.substr(open_parens_idx + 1, |
| 97 close_parens_idx - (open_parens_idx + 1))); | 97 close_parens_idx - (open_parens_idx + 1))); |
| 98 | 98 |
| 99 // Split the rest. | 99 // Split the rest. |
| 100 std::vector<std::string> other_stats; | 100 std::vector<std::string> other_stats = SplitString( |
| 101 SplitString(stats_data.substr(close_parens_idx + 2), ' ', &other_stats); | 101 stats_data.substr(close_parens_idx + 2), " ", |
| 102 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 102 for (size_t i = 0; i < other_stats.size(); ++i) | 103 for (size_t i = 0; i < other_stats.size(); ++i) |
| 103 proc_stats->push_back(other_stats[i]); | 104 proc_stats->push_back(other_stats[i]); |
| 104 return true; | 105 return true; |
| 105 } | 106 } |
| 106 | 107 |
| 107 typedef std::map<std::string, std::string> ProcStatMap; | 108 typedef std::map<std::string, std::string> ProcStatMap; |
| 108 void ParseProcStat(const std::string& contents, ProcStatMap* output) { | 109 void ParseProcStat(const std::string& contents, ProcStatMap* output) { |
| 109 StringPairs key_value_pairs; | 110 StringPairs key_value_pairs; |
| 110 SplitStringIntoKeyValuePairs(contents, ' ', '\n', &key_value_pairs); | 111 SplitStringIntoKeyValuePairs(contents, ' ', '\n', &key_value_pairs); |
| 111 for (size_t i = 0; i < key_value_pairs.size(); ++i) { | 112 for (size_t i = 0; i < key_value_pairs.size(); ++i) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // which means the answer is 100. | 179 // which means the answer is 100. |
| 179 // It may be the case that this value is always 100. | 180 // It may be the case that this value is always 100. |
| 180 static const int kHertz = sysconf(_SC_CLK_TCK); | 181 static const int kHertz = sysconf(_SC_CLK_TCK); |
| 181 | 182 |
| 182 return TimeDelta::FromMicroseconds( | 183 return TimeDelta::FromMicroseconds( |
| 183 Time::kMicrosecondsPerSecond * clock_ticks / kHertz); | 184 Time::kMicrosecondsPerSecond * clock_ticks / kHertz); |
| 184 } | 185 } |
| 185 | 186 |
| 186 } // namespace internal | 187 } // namespace internal |
| 187 } // namespace base | 188 } // namespace base |
| OLD | NEW |