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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 std::vector<std::string>* proc_stats) { | 68 std::vector<std::string>* proc_stats) { |
69 // The stat file is formatted as: | 69 // The stat file is formatted as: |
70 // pid (process name) data1 data2 .... dataN | 70 // pid (process name) data1 data2 .... dataN |
71 // Look for the closing paren by scanning backwards, to avoid being fooled by | 71 // Look for the closing paren by scanning backwards, to avoid being fooled by |
72 // processes with ')' in the name. | 72 // processes with ')' in the name. |
73 size_t open_parens_idx = stats_data.find(" ("); | 73 size_t open_parens_idx = stats_data.find(" ("); |
74 size_t close_parens_idx = stats_data.rfind(") "); | 74 size_t close_parens_idx = stats_data.rfind(") "); |
75 if (open_parens_idx == std::string::npos || | 75 if (open_parens_idx == std::string::npos || |
76 close_parens_idx == std::string::npos || | 76 close_parens_idx == std::string::npos || |
77 open_parens_idx > close_parens_idx) { | 77 open_parens_idx > close_parens_idx) { |
| 78 DLOG(WARNING) << "Failed to find matched parens in '" << stats_data << "'"; |
78 NOTREACHED(); | 79 NOTREACHED(); |
79 return false; | 80 return false; |
80 } | 81 } |
81 open_parens_idx++; | 82 open_parens_idx++; |
82 | 83 |
83 proc_stats->clear(); | 84 proc_stats->clear(); |
84 // PID. | 85 // PID. |
85 proc_stats->push_back(stats_data.substr(0, open_parens_idx)); | 86 proc_stats->push_back(stats_data.substr(0, open_parens_idx)); |
86 // Process name without parentheses. | 87 // Process name without parentheses. |
87 proc_stats->push_back( | 88 proc_stats->push_back( |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 int score_len = static_cast<int>(score_str.length()); | 817 int score_len = static_cast<int>(score_str.length()); |
817 return (score_len == file_util::WriteFile(oom_file, | 818 return (score_len == file_util::WriteFile(oom_file, |
818 score_str.c_str(), | 819 score_str.c_str(), |
819 score_len)); | 820 score_len)); |
820 } | 821 } |
821 | 822 |
822 return false; | 823 return false; |
823 } | 824 } |
824 | 825 |
825 } // namespace base | 826 } // namespace base |
OLD | NEW |