| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 void MemoryDetails::CollectChildInfoOnUIThread() { | 222 void MemoryDetails::CollectChildInfoOnUIThread() { |
| 223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 224 ProcessData* const chrome_browser = ChromeBrowser(); | 224 ProcessData* const chrome_browser = ChromeBrowser(); |
| 225 | 225 |
| 226 // First pass, collate the widgets by process ID. | 226 // First pass, collate the widgets by process ID. |
| 227 std::map<base::ProcessId, std::vector<RenderWidgetHost*>> widgets_by_pid; | 227 std::map<base::ProcessId, std::vector<RenderWidgetHost*>> widgets_by_pid; |
| 228 std::unique_ptr<content::RenderWidgetHostIterator> widget_it( | 228 std::unique_ptr<content::RenderWidgetHostIterator> widget_it( |
| 229 RenderWidgetHost::GetRenderWidgetHosts()); | 229 RenderWidgetHost::GetRenderWidgetHosts()); |
| 230 while (content::RenderWidgetHost* widget = widget_it->GetNextHost()) { | 230 while (content::RenderWidgetHost* widget = widget_it->GetNextHost()) { |
| 231 // Ignore processes that don't have a connection, such as crashed tabs. | 231 // Ignore processes that don't have a connection, such as crashed tabs, |
| 232 if (!widget->GetProcess()->HasConnection()) | 232 // or processes that are still launching. |
| 233 if (!widget->GetProcess()->IsReady()) |
| 233 continue; | 234 continue; |
| 234 base::ProcessId pid = base::GetProcId(widget->GetProcess()->GetHandle()); | 235 base::ProcessId pid = base::GetProcId(widget->GetProcess()->GetHandle()); |
| 235 widgets_by_pid[pid].push_back(widget); | 236 widgets_by_pid[pid].push_back(widget); |
| 236 } | 237 } |
| 237 | 238 |
| 238 // Get more information about the process. | 239 // Get more information about the process. |
| 239 for (ProcessMemoryInformation& process : chrome_browser->processes) { | 240 for (ProcessMemoryInformation& process : chrome_browser->processes) { |
| 240 // If there's at least one widget in the process, it is some kind of | 241 // If there's at least one widget in the process, it is some kind of |
| 241 // renderer process belonging to this browser. All these widgets will share | 242 // renderer process belonging to this browser. All these widgets will share |
| 242 // a RenderProcessHost. | 243 // a RenderProcessHost. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 // Get rid of other Chrome processes that are from a different profile. | 353 // Get rid of other Chrome processes that are from a different profile. |
| 353 auto is_unknown = [](ProcessMemoryInformation& process) { | 354 auto is_unknown = [](ProcessMemoryInformation& process) { |
| 354 return process.process_type == content::PROCESS_TYPE_UNKNOWN; | 355 return process.process_type == content::PROCESS_TYPE_UNKNOWN; |
| 355 }; | 356 }; |
| 356 auto& vector = chrome_browser->processes; | 357 auto& vector = chrome_browser->processes; |
| 357 vector.erase(std::remove_if(vector.begin(), vector.end(), is_unknown), | 358 vector.erase(std::remove_if(vector.begin(), vector.end(), is_unknown), |
| 358 vector.end()); | 359 vector.end()); |
| 359 | 360 |
| 360 OnDetailsAvailable(); | 361 OnDetailsAvailable(); |
| 361 } | 362 } |
| OLD | NEW |