Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 } // namespace | 156 } // namespace |
| 157 | 157 |
| 158 MemoryDetails::MemoryDetails() { | 158 MemoryDetails::MemoryDetails() { |
| 159 } | 159 } |
| 160 | 160 |
| 161 ProcessData* MemoryDetails::ChromeBrowser() { | 161 ProcessData* MemoryDetails::ChromeBrowser() { |
| 162 return &process_data_[0]; | 162 return &process_data_[0]; |
| 163 } | 163 } |
| 164 | 164 |
| 165 void MemoryDetails::CollectProcessData( | 165 void MemoryDetails::CollectProcessData( |
| 166 CollectionMode mode, | |
| 167 const std::vector<ProcessMemoryInformation>& child_info) { | 166 const std::vector<ProcessMemoryInformation>& child_info) { |
| 168 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 167 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| 169 | 168 |
| 170 ProcessMap process_map = GetProcesses(); | 169 ProcessMap process_map = GetProcesses(); |
| 171 std::set<pid_t> browsers_found; | 170 std::set<pid_t> browsers_found; |
| 172 | 171 |
| 173 // For each process on the system, if it appears to be a browser process and | 172 // For each process on the system, if it appears to be a browser process and |
| 174 // it's parent isn't a browser process, then record it in |browsers_found|. | 173 // it's parent isn't a browser process, then record it in |browsers_found|. |
|
Nico
2016/04/08 19:47:44
It kind of feels like there's more than can be sim
Elly Fong-Jones
2016/04/13 17:18:24
Done.
Because of the way GetBrowserType is implem
| |
| 175 for (const auto& entry : process_map) { | 174 for (const auto& entry : process_map) { |
| 176 const Process& current_process = entry.second; | 175 const Process& current_process = entry.second; |
| 177 const BrowserType type = GetBrowserType(current_process.name); | 176 const BrowserType type = GetBrowserType(current_process.name); |
| 178 if (type == MAX_BROWSERS) | 177 if (type == MAX_BROWSERS) |
| 179 continue; | 178 continue; |
| 180 if (type != CHROME && mode == FROM_CHROME_ONLY) | 179 if (type != CHROME) |
| 181 continue; | 180 continue; |
| 182 | 181 |
| 183 ProcessMap::const_iterator parent_iter = | 182 ProcessMap::const_iterator parent_iter = |
| 184 process_map.find(current_process.parent); | 183 process_map.find(current_process.parent); |
| 185 if (parent_iter == process_map.end()) { | 184 if (parent_iter == process_map.end()) { |
| 186 browsers_found.insert(current_process.pid); | 185 browsers_found.insert(current_process.pid); |
| 187 continue; | 186 continue; |
| 188 } | 187 } |
| 189 | 188 |
| 190 if (GetBrowserType(parent_iter->second.name) != type) { | 189 if (GetBrowserType(parent_iter->second.name) != type) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 | 232 |
| 234 #if defined(OS_CHROMEOS) | 233 #if defined(OS_CHROMEOS) |
| 235 base::GetSwapInfo(&swap_info_); | 234 base::GetSwapInfo(&swap_info_); |
| 236 #endif | 235 #endif |
| 237 | 236 |
| 238 // Finally return to the browser thread. | 237 // Finally return to the browser thread. |
| 239 BrowserThread::PostTask( | 238 BrowserThread::PostTask( |
| 240 BrowserThread::UI, FROM_HERE, | 239 BrowserThread::UI, FROM_HERE, |
| 241 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); | 240 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); |
| 242 } | 241 } |
| OLD | NEW |