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