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_util.h" | 5 #include "base/process_util.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <malloc.h> | 8 #include <malloc.h> |
9 #include <sys/time.h> | 9 #include <sys/time.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 // Reads the |field_num|th field from |proc_stats|. | 155 // Reads the |field_num|th field from |proc_stats|. |
156 // Returns an empty string on failure. | 156 // Returns an empty string on failure. |
157 // This version only handles VM_COMM and VM_STATE, which are the only fields | 157 // This version only handles VM_COMM and VM_STATE, which are the only fields |
158 // that are strings. | 158 // that are strings. |
159 std::string GetProcStatsFieldAsString( | 159 std::string GetProcStatsFieldAsString( |
160 const std::vector<std::string>& proc_stats, | 160 const std::vector<std::string>& proc_stats, |
161 ProcStatsFields field_num) { | 161 ProcStatsFields field_num) { |
162 if (field_num < VM_COMM || field_num > VM_STATE) { | 162 if (field_num < VM_COMM || field_num > VM_STATE) { |
163 NOTREACHED(); | 163 NOTREACHED(); |
164 return ""; | 164 return std::string(); |
165 } | 165 } |
166 | 166 |
167 if (proc_stats.size() > static_cast<size_t>(field_num)) | 167 if (proc_stats.size() > static_cast<size_t>(field_num)) |
168 return proc_stats[field_num]; | 168 return proc_stats[field_num]; |
169 | 169 |
170 NOTREACHED(); | 170 NOTREACHED(); |
171 return 0; | 171 return 0; |
172 } | 172 } |
173 | 173 |
174 // Reads /proc/<pid>/cmdline and populates |proc_cmd_line_args| with the command | 174 // Reads /proc/<pid>/cmdline and populates |proc_cmd_line_args| with the command |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 int score_len = static_cast<int>(score_str.length()); | 882 int score_len = static_cast<int>(score_str.length()); |
883 return (score_len == file_util::WriteFile(oom_file, | 883 return (score_len == file_util::WriteFile(oom_file, |
884 score_str.c_str(), | 884 score_str.c_str(), |
885 score_len)); | 885 score_len)); |
886 } | 886 } |
887 | 887 |
888 return false; | 888 return false; |
889 } | 889 } |
890 | 890 |
891 } // namespace base | 891 } // namespace base |
OLD | NEW |