| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 203 |
| 204 // Now go do expensive memory lookups on the blocking pool. | 204 // Now go do expensive memory lookups on the blocking pool. |
| 205 BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior( | 205 BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior( |
| 206 FROM_HERE, | 206 FROM_HERE, |
| 207 base::Bind(&MemoryDetails::CollectProcessData, this, mode, child_info), | 207 base::Bind(&MemoryDetails::CollectProcessData, this, mode, child_info), |
| 208 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 208 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void MemoryDetails::CollectChildInfoOnUIThread() { | 211 void MemoryDetails::CollectChildInfoOnUIThread() { |
| 212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 213 | |
| 214 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | |
| 215 const pid_t zygote_pid = content::ZygoteHost::GetInstance()->GetPid(); | |
| 216 #endif | |
| 217 | |
| 218 ProcessData* const chrome_browser = ChromeBrowser(); | 213 ProcessData* const chrome_browser = ChromeBrowser(); |
| 219 | 214 |
| 220 // First pass, collate the widgets by process ID. | 215 // First pass, collate the widgets by process ID. |
| 221 std::map<base::ProcessId, std::vector<RenderWidgetHost*>> widgets_by_pid; | 216 std::map<base::ProcessId, std::vector<RenderWidgetHost*>> widgets_by_pid; |
| 222 scoped_ptr<content::RenderWidgetHostIterator> widget_it( | 217 scoped_ptr<content::RenderWidgetHostIterator> widget_it( |
| 223 RenderWidgetHost::GetRenderWidgetHosts()); | 218 RenderWidgetHost::GetRenderWidgetHosts()); |
| 224 while (content::RenderWidgetHost* widget = widget_it->GetNextHost()) { | 219 while (content::RenderWidgetHost* widget = widget_it->GetNextHost()) { |
| 225 // Ignore processes that don't have a connection, such as crashed tabs. | 220 // Ignore processes that don't have a connection, such as crashed tabs. |
| 226 if (!widget->GetProcess()->HasConnection()) | 221 if (!widget->GetProcess()->HasConnection()) |
| 227 continue; | 222 continue; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 chrome::kChromeUIMemoryURL)) || | 354 chrome::kChromeUIMemoryURL)) || |
| 360 (pending_entry && | 355 (pending_entry && |
| 361 base::LowerCaseEqualsASCII( | 356 base::LowerCaseEqualsASCII( |
| 362 pending_entry->GetVirtualURL().spec(), | 357 pending_entry->GetVirtualURL().spec(), |
| 363 chrome::kChromeUIMemoryURL))) { | 358 chrome::kChromeUIMemoryURL))) { |
| 364 process.is_diagnostics = true; | 359 process.is_diagnostics = true; |
| 365 } | 360 } |
| 366 } | 361 } |
| 367 | 362 |
| 368 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 363 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 369 if (process.pid == zygote_pid) { | 364 if (content::ZygoteHost::GetInstance()->IsZygotePid(process.pid)) { |
| 370 process.process_type = content::PROCESS_TYPE_ZYGOTE; | 365 process.process_type = content::PROCESS_TYPE_ZYGOTE; |
| 371 } | 366 } |
| 372 #endif | 367 #endif |
| 373 } | 368 } |
| 374 | 369 |
| 375 // Get rid of other Chrome processes that are from a different profile. | 370 // Get rid of other Chrome processes that are from a different profile. |
| 376 auto is_unknown = [](ProcessMemoryInformation& process) { | 371 auto is_unknown = [](ProcessMemoryInformation& process) { |
| 377 return process.process_type == content::PROCESS_TYPE_UNKNOWN; | 372 return process.process_type == content::PROCESS_TYPE_UNKNOWN; |
| 378 }; | 373 }; |
| 379 auto& vector = chrome_browser->processes; | 374 auto& vector = chrome_browser->processes; |
| 380 vector.erase(std::remove_if(vector.begin(), vector.end(), is_unknown), | 375 vector.erase(std::remove_if(vector.begin(), vector.end(), is_unknown), |
| 381 vector.end()); | 376 vector.end()); |
| 382 | 377 |
| 383 OnDetailsAvailable(); | 378 OnDetailsAvailable(); |
| 384 } | 379 } |
| OLD | NEW |