Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: base/process/process_linux.cc

Issue 1474483002: Fix split in base::ProcessIsProcessBackgrounded() (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Added tests Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/process/process_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | base/process/process_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698