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 "chrome/browser/memory_details.h" | 5 #include "chrome/browser/memory_details.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 for (size_t index = CHROME_BROWSER; index < MAX_BROWSERS; index++) { | 203 for (size_t index = CHROME_BROWSER; index < MAX_BROWSERS; index++) { |
204 base::NamedProcessIterator process_it( | 204 base::NamedProcessIterator process_it( |
205 base::UTF16ToUTF8(process_data_[index].process_name), NULL); | 205 base::UTF16ToUTF8(process_data_[index].process_name), NULL); |
206 | 206 |
207 while (const base::ProcessEntry* entry = process_it.NextProcessEntry()) { | 207 while (const base::ProcessEntry* entry = process_it.NextProcessEntry()) { |
208 pids_by_browser[index].push_back(entry->pid()); | 208 pids_by_browser[index].push_back(entry->pid()); |
209 all_pids.push_back(entry->pid()); | 209 all_pids.push_back(entry->pid()); |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 // The helper might show up as these different flavors depending on the | 213 // Get PIDs of the helper. |
Mark Mentovai
2015/09/17 23:48:29
The comment was correct before, “helpers,” because
| |
214 // executable flags required. | |
215 std::vector<std::string> helper_names; | |
216 helper_names.push_back(chrome::kHelperProcessExecutableName); | |
217 for (const char* const* suffix = chrome::kHelperFlavorSuffixes; | |
218 *suffix; | |
219 ++suffix) { | |
220 std::string helper_name = chrome::kHelperProcessExecutableName; | |
221 helper_name.append(1, ' '); | |
222 helper_name.append(*suffix); | |
223 helper_names.push_back(helper_name); | |
224 } | |
225 | |
226 // Get PIDs of helpers. | |
227 std::vector<base::ProcessId> helper_pids; | 214 std::vector<base::ProcessId> helper_pids; |
228 for (size_t i = 0; i < helper_names.size(); ++i) { | 215 base::NamedProcessIterator helper_it(chrome::kHelperProcessExecutableName, |
229 std::string helper_name = helper_names[i]; | 216 NULL); |
Mark Mentovai
2015/09/17 23:48:29
Use nullptr in new code.
| |
230 base::NamedProcessIterator helper_it(helper_name, NULL); | 217 while (const base::ProcessEntry* entry = helper_it.NextProcessEntry()) { |
231 while (const base::ProcessEntry* entry = helper_it.NextProcessEntry()) { | 218 helper_pids.push_back(entry->pid()); |
232 helper_pids.push_back(entry->pid()); | 219 all_pids.push_back(entry->pid()); |
233 all_pids.push_back(entry->pid()); | |
234 } | |
235 } | 220 } |
236 | 221 |
237 if (mode == FROM_ALL_BROWSERS) { | 222 if (mode == FROM_ALL_BROWSERS) { |
238 CollectProcessDataAboutNonChromeProcesses(all_pids, pids_by_browser, | 223 CollectProcessDataAboutNonChromeProcesses(all_pids, pids_by_browser, |
239 &process_data_); | 224 &process_data_); |
240 } | 225 } |
241 | 226 |
242 ProcessMemoryInformationList* chrome_processes = | 227 ProcessMemoryInformationList* chrome_processes = |
243 &process_data_[CHROME_BROWSER].processes; | 228 &process_data_[CHROME_BROWSER].processes; |
244 | 229 |
245 // Collect data about Chrome/Chromium. | 230 // Collect data about Chrome/Chromium. |
246 for (const base::ProcessId& pid : pids_by_browser[CHROME_BROWSER]) | 231 for (const base::ProcessId& pid : pids_by_browser[CHROME_BROWSER]) |
247 CollectProcessDataForChromeProcess(child_info, pid, chrome_processes); | 232 CollectProcessDataForChromeProcess(child_info, pid, chrome_processes); |
248 | 233 |
249 // And collect data about the helpers. | 234 // And collect data about the helpers. |
250 for (const base::ProcessId& pid : helper_pids) | 235 for (const base::ProcessId& pid : helper_pids) |
251 CollectProcessDataForChromeProcess(child_info, pid, chrome_processes); | 236 CollectProcessDataForChromeProcess(child_info, pid, chrome_processes); |
252 | 237 |
253 // Finally return to the browser thread. | 238 // Finally return to the browser thread. |
254 BrowserThread::PostTask( | 239 BrowserThread::PostTask( |
255 BrowserThread::UI, FROM_HERE, | 240 BrowserThread::UI, FROM_HERE, |
256 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); | 241 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); |
257 } | 242 } |
OLD | NEW |