| 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 <sys/types.h> | 7 #include <sys/types.h> |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 ProcessData process_data; | 113 ProcessData process_data; |
| 114 for (std::vector<pid_t>::const_iterator iter = pids.begin(); | 114 for (std::vector<pid_t>::const_iterator iter = pids.begin(); |
| 115 iter != pids.end(); | 115 iter != pids.end(); |
| 116 ++iter) { | 116 ++iter) { |
| 117 ProcessMemoryInformation pmi; | 117 ProcessMemoryInformation pmi; |
| 118 | 118 |
| 119 pmi.pid = *iter; | 119 pmi.pid = *iter; |
| 120 pmi.num_processes = 1; | 120 pmi.num_processes = 1; |
| 121 | 121 |
| 122 if (pmi.pid == base::GetCurrentProcId()) | 122 if (pmi.pid == base::GetCurrentProcId()) |
| 123 pmi.type = content::PROCESS_TYPE_BROWSER; | 123 pmi.process_type = content::PROCESS_TYPE_BROWSER; |
| 124 else | 124 else |
| 125 pmi.type = content::PROCESS_TYPE_UNKNOWN; | 125 pmi.process_type = content::PROCESS_TYPE_UNKNOWN; |
| 126 | 126 |
| 127 base::ProcessMetrics* metrics = | 127 base::ProcessMetrics* metrics = |
| 128 base::ProcessMetrics::CreateProcessMetrics(*iter); | 128 base::ProcessMetrics::CreateProcessMetrics(*iter); |
| 129 metrics->GetWorkingSetKBytes(&pmi.working_set); | 129 metrics->GetWorkingSetKBytes(&pmi.working_set); |
| 130 delete metrics; | 130 delete metrics; |
| 131 | 131 |
| 132 process_data.processes.push_back(pmi); | 132 process_data.processes.push_back(pmi); |
| 133 } | 133 } |
| 134 return process_data; | 134 return process_data; |
| 135 } | 135 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 199 |
| 200 for (std::vector<ProcessMemoryInformation>::iterator | 200 for (std::vector<ProcessMemoryInformation>::iterator |
| 201 i = current_browser.processes.begin(); | 201 i = current_browser.processes.begin(); |
| 202 i != current_browser.processes.end(); ++i) { | 202 i != current_browser.processes.end(); ++i) { |
| 203 // Check if this is one of the child processes whose data we collected | 203 // Check if this is one of the child processes whose data we collected |
| 204 // on the IO thread, and if so copy over that data. | 204 // on the IO thread, and if so copy over that data. |
| 205 for (size_t child = 0; child < child_info.size(); child++) { | 205 for (size_t child = 0; child < child_info.size(); child++) { |
| 206 if (child_info[child].pid != i->pid) | 206 if (child_info[child].pid != i->pid) |
| 207 continue; | 207 continue; |
| 208 i->titles = child_info[child].titles; | 208 i->titles = child_info[child].titles; |
| 209 i->type = child_info[child].type; | 209 i->process_type = child_info[child].process_type; |
| 210 break; | 210 break; |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 process_data_.push_back(current_browser); | 214 process_data_.push_back(current_browser); |
| 215 | 215 |
| 216 // For each browser process, collect a list of its children and get the | 216 // For each browser process, collect a list of its children and get the |
| 217 // memory usage of each. | 217 // memory usage of each. |
| 218 for (std::set<pid_t>::const_iterator iter = browsers_found.begin(); | 218 for (std::set<pid_t>::const_iterator iter = browsers_found.begin(); |
| 219 iter != browsers_found.end(); | 219 iter != browsers_found.end(); |
| 220 ++iter) { | 220 ++iter) { |
| 221 std::vector<pid_t> browser_processes = GetAllChildren(process_map, *iter); | 221 std::vector<pid_t> browser_processes = GetAllChildren(process_map, *iter); |
| 222 ProcessData browser = GetProcessDataMemoryInformation(browser_processes); | 222 ProcessData browser = GetProcessDataMemoryInformation(browser_processes); |
| 223 | 223 |
| 224 ProcessMap::const_iterator process_iter = process_map.find(*iter); | 224 ProcessMap::const_iterator process_iter = process_map.find(*iter); |
| 225 if (process_iter == process_map.end()) | 225 if (process_iter == process_map.end()) |
| 226 continue; | 226 continue; |
| 227 BrowserType type = GetBrowserType(process_iter->second.name); | 227 BrowserType type = GetBrowserType(process_iter->second.name); |
| 228 if (type != MAX_BROWSERS) | 228 if (type != MAX_BROWSERS) |
| 229 browser.name = ASCIIToUTF16(kBrowserPrettyNames[type]); | 229 browser.name = ASCIIToUTF16(kBrowserPrettyNames[type]); |
| 230 process_data_.push_back(browser); | 230 process_data_.push_back(browser); |
| 231 } | 231 } |
| 232 | 232 |
| 233 // Finally return to the browser thread. | 233 // Finally return to the browser thread. |
| 234 BrowserThread::PostTask( | 234 BrowserThread::PostTask( |
| 235 BrowserThread::UI, FROM_HERE, | 235 BrowserThread::UI, FROM_HERE, |
| 236 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); | 236 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); |
| 237 } | 237 } |
| OLD | NEW |