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 = SplitString( | 100 std::vector<std::string> other_stats; |
101 stats_data.substr(close_parens_idx + 2), " ", | 101 SplitString(stats_data.substr(close_parens_idx + 2), ' ', &other_stats); |
102 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | |
103 for (size_t i = 0; i < other_stats.size(); ++i) | 102 for (size_t i = 0; i < other_stats.size(); ++i) |
104 proc_stats->push_back(other_stats[i]); | 103 proc_stats->push_back(other_stats[i]); |
105 return true; | 104 return true; |
106 } | 105 } |
107 | 106 |
108 typedef std::map<std::string, std::string> ProcStatMap; | 107 typedef std::map<std::string, std::string> ProcStatMap; |
109 void ParseProcStat(const std::string& contents, ProcStatMap* output) { | 108 void ParseProcStat(const std::string& contents, ProcStatMap* output) { |
110 StringPairs key_value_pairs; | 109 StringPairs key_value_pairs; |
111 SplitStringIntoKeyValuePairs(contents, ' ', '\n', &key_value_pairs); | 110 SplitStringIntoKeyValuePairs(contents, ' ', '\n', &key_value_pairs); |
112 for (size_t i = 0; i < key_value_pairs.size(); ++i) { | 111 for (size_t i = 0; i < key_value_pairs.size(); ++i) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // which means the answer is 100. | 178 // which means the answer is 100. |
180 // It may be the case that this value is always 100. | 179 // It may be the case that this value is always 100. |
181 static const int kHertz = sysconf(_SC_CLK_TCK); | 180 static const int kHertz = sysconf(_SC_CLK_TCK); |
182 | 181 |
183 return TimeDelta::FromMicroseconds( | 182 return TimeDelta::FromMicroseconds( |
184 Time::kMicrosecondsPerSecond * clock_ticks / kHertz); | 183 Time::kMicrosecondsPerSecond * clock_ticks / kHertz); |
185 } | 184 } |
186 | 185 |
187 } // namespace internal | 186 } // namespace internal |
188 } // namespace base | 187 } // namespace base |
OLD | NEW |