Chromium Code Reviews| Index: chrome/browser/memory_details_linux.cc |
| diff --git a/chrome/browser/memory_details_linux.cc b/chrome/browser/memory_details_linux.cc |
| index 4df1f4f4639b2e90040a6f47e1bccee95c3cd44a..cbcc36c257655e2286e9d4c18d55dbe26e367371 100644 |
| --- a/chrome/browser/memory_details_linux.cc |
| +++ b/chrome/browser/memory_details_linux.cc |
| @@ -31,52 +31,9 @@ using content::BrowserThread; |
| namespace { |
| -// Known browsers which we collect details for. |
| -enum BrowserType { |
| - CHROME = 0, |
| - FIREFOX, |
| - ICEWEASEL, |
| - OPERA, |
| - KONQUEROR, |
| - EPIPHANY, |
| - MIDORI, |
| - MAX_BROWSERS |
| -}; |
| - |
| -// The pretty printed names of those browsers. Matches up with enum |
| -// BrowserType. |
| -const char kBrowserPrettyNames[][10] = { |
| - "Chrome", |
| - "Firefox", |
| - "Iceweasel", |
| - "Opera", |
| - "Konqueror", |
| - "Epiphany", |
| - "Midori", |
| -}; |
| - |
| -// A mapping from process name to the type of browser. |
| -const struct { |
| - const char process_name[17]; |
| - BrowserType browser; |
| -} kBrowserBinaryNames[] = { |
| - { "firefox", FIREFOX }, |
| - { "firefox-3.5", FIREFOX }, |
| - { "firefox-3.0", FIREFOX }, |
| - { "firefox-bin", FIREFOX }, |
| - { "iceweasel", ICEWEASEL }, |
| - { "opera", OPERA }, |
| - { "konqueror", KONQUEROR }, |
| - { "epiphany-browser", EPIPHANY }, |
| - { "epiphany", EPIPHANY }, |
| - { "midori", MIDORI }, |
| - { "", MAX_BROWSERS }, |
| -}; |
| - |
| struct Process { |
| pid_t pid; |
| pid_t parent; |
| - std::string name; |
| }; |
| typedef std::map<pid_t, Process> ProcessMap; |
| @@ -90,23 +47,11 @@ ProcessMap GetProcesses() { |
| Process process; |
| process.pid = process_entry->pid(); |
| process.parent = process_entry->parent_pid(); |
| - process.name = process_entry->exe_file(); |
| map.insert(std::make_pair(process.pid, process)); |
| } |
| return map; |
| } |
| -// Given a process name, return the type of the browser which created that |
| -// process, or |MAX_BROWSERS| if we don't know about it. |
| -BrowserType GetBrowserType(const std::string& process_name) { |
| - for (unsigned i = 0; kBrowserBinaryNames[i].process_name[0]; ++i) { |
| - if (strcmp(process_name.c_str(), kBrowserBinaryNames[i].process_name) == 0) |
| - return kBrowserBinaryNames[i].browser; |
| - } |
| - |
| - return MAX_BROWSERS; |
| -} |
| - |
| // For each of a list of pids, collect memory information about that process. |
| ProcessData GetProcessDataMemoryInformation( |
| const std::vector<pid_t>& pids) { |
| @@ -164,38 +109,12 @@ ProcessData* MemoryDetails::ChromeBrowser() { |
| } |
| void MemoryDetails::CollectProcessData( |
| - CollectionMode mode, |
| const std::vector<ProcessMemoryInformation>& child_info) { |
| DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| ProcessMap process_map = GetProcesses(); |
| std::set<pid_t> browsers_found; |
|
Alexei Svitkine (slow)
2016/04/13 19:17:52
Nit: Remove?
|
| - // For each process on the system, if it appears to be a browser process and |
| - // it's parent isn't a browser process, then record it in |browsers_found|. |
| - for (const auto& entry : process_map) { |
| - const Process& current_process = entry.second; |
| - const BrowserType type = GetBrowserType(current_process.name); |
| - if (type == MAX_BROWSERS) |
| - continue; |
| - if (type != CHROME && mode == FROM_CHROME_ONLY) |
| - continue; |
| - |
| - ProcessMap::const_iterator parent_iter = |
| - process_map.find(current_process.parent); |
| - if (parent_iter == process_map.end()) { |
| - browsers_found.insert(current_process.pid); |
| - continue; |
| - } |
| - |
| - if (GetBrowserType(parent_iter->second.name) != type) { |
| - // We found a process whose type is different from its parent's type. |
| - // That means it is the root process of the browser. |
| - browsers_found.insert(current_process.pid); |
| - continue; |
| - } |
| - } |
| - |
| ProcessData current_browser = |
| GetProcessDataMemoryInformation(GetAllChildren(process_map, getpid())); |
| current_browser.name = l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); |
| @@ -217,21 +136,6 @@ void MemoryDetails::CollectProcessData( |
| process_data_.push_back(current_browser); |
| - // For each browser process, collect a list of its children and get the |
| - // memory usage of each. |
| - for (pid_t pid : browsers_found) { |
| - std::vector<pid_t> browser_processes = GetAllChildren(process_map, pid); |
| - ProcessData browser = GetProcessDataMemoryInformation(browser_processes); |
| - |
| - ProcessMap::const_iterator process_iter = process_map.find(pid); |
| - if (process_iter == process_map.end()) |
| - continue; |
| - BrowserType type = GetBrowserType(process_iter->second.name); |
| - if (type != MAX_BROWSERS) |
| - browser.name = base::ASCIIToUTF16(kBrowserPrettyNames[type]); |
| - process_data_.push_back(browser); |
| - } |
| - |
| #if defined(OS_CHROMEOS) |
| base::GetSwapInfo(&swap_info_); |
| #endif |