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