| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/process.h" | 5 #include "base/process/process.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sys/resource.h> | 8 #include <sys/resource.h> |
| 9 | 9 |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 DPCHECK(result == 0); | 133 DPCHECK(result == 0); |
| 134 return result == 0; | 134 return result == 0; |
| 135 } | 135 } |
| 136 | 136 |
| 137 #if defined(OS_CHROMEOS) | 137 #if defined(OS_CHROMEOS) |
| 138 bool IsProcessBackgroundedCGroup(const StringPiece& cgroup_contents) { | 138 bool IsProcessBackgroundedCGroup(const StringPiece& cgroup_contents) { |
| 139 // The process can be part of multiple control groups, and for each cgroup | 139 // The process can be part of multiple control groups, and for each cgroup |
| 140 // hierarchy there's an entry in the file. We look for a control group | 140 // hierarchy there's an entry in the file. We look for a control group |
| 141 // named "/chrome_renderers/background" to determine if the process is | 141 // named "/chrome_renderers/background" to determine if the process is |
| 142 // backgrounded. crbug.com/548818. | 142 // backgrounded. crbug.com/548818. |
| 143 std::vector<StringPiece> lines = | 143 std::vector<StringPiece> lines = SplitStringPiece( |
| 144 SplitStringPiece(cgroup_contents, "\n", TRIM_WHITESPACE, SPLIT_WANT_ALL); | 144 cgroup_contents, "\n", TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY); |
| 145 for (const auto& line : lines) { | 145 for (const auto& line : lines) { |
| 146 std::vector<StringPiece> fields = | 146 std::vector<StringPiece> fields = |
| 147 SplitStringPiece(line, ":", TRIM_WHITESPACE, SPLIT_WANT_ALL); | 147 SplitStringPiece(line, ":", TRIM_WHITESPACE, SPLIT_WANT_ALL); |
| 148 if (fields.size() != 3U) { | 148 if (fields.size() != 3U) { |
| 149 NOTREACHED(); | 149 NOTREACHED(); |
| 150 continue; | 150 continue; |
| 151 } | 151 } |
| 152 if (fields[2] == kBackground) | 152 if (fields[2] == kBackground) |
| 153 return true; | 153 return true; |
| 154 } | 154 } |
| 155 | 155 |
| 156 return false; | 156 return false; |
| 157 } | 157 } |
| 158 #endif // defined(OS_CHROMEOS) | 158 #endif // defined(OS_CHROMEOS) |
| 159 | 159 |
| 160 } // namespace base | 160 } // namespace base |
| OLD | NEW |