Index: chrome/browser/memory_details.cc |
diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc |
index d300cdcc530a8d2cfbbad801bf1191a6a91de146..f4897af6e7731dfd5bc32cfb3daf49dd2035a1d4 100644 |
--- a/chrome/browser/memory_details.cc |
+++ b/chrome/browser/memory_details.cc |
@@ -214,11 +214,11 @@ void MemoryDetails::CollectChildInfoOnUIThread() { |
ProcessMemoryInformation& process = |
chrome_browser->processes[index]; |
- for (content::RenderProcessHost::iterator renderer_iter( |
- content::RenderProcessHost::AllHostsIterator()); |
- !renderer_iter.IsAtEnd(); renderer_iter.Advance()) { |
- content::RenderProcessHost* render_process_host = |
- renderer_iter.GetCurrentValue(); |
+ RenderWidgetHost::List widgets = RenderWidgetHost::GetRenderWidgetHosts(); |
+ for (RenderWidgetHost::List::const_iterator it = widgets.begin(); |
+ it != widgets.end(); ++it) { |
jam
2013/06/12 19:59:59
ditto
nasko
2013/06/12 21:18:59
Done.
|
+ const RenderWidgetHost* widget = *it; |
+ content::RenderProcessHost* render_process_host = widget->GetProcess(); |
DCHECK(render_process_host); |
// Ignore processes that don't have a connection, such as crashed tabs. |
if (!render_process_host->HasConnection() || |
@@ -238,106 +238,101 @@ void MemoryDetails::CollectChildInfoOnUIThread() { |
// The RenderProcessHost may host multiple WebContentses. Any |
// of them which contain diagnostics information make the whole |
// process be considered a diagnostics process. |
- content::RenderProcessHost::RenderWidgetHostsIterator iter( |
- render_process_host->GetRenderWidgetHostsIterator()); |
- for (; !iter.IsAtEnd(); iter.Advance()) { |
- const RenderWidgetHost* widget = iter.GetCurrentValue(); |
- DCHECK(widget); |
- if (!widget || !widget->IsRenderView()) |
- continue; |
+ if (!widget->IsRenderView()) |
+ continue; |
- RenderViewHost* host = |
- RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); |
- WebContents* contents = WebContents::FromRenderViewHost(host); |
- GURL url; |
- if (contents) |
- url = contents->GetURL(); |
- extensions::ViewType type = extensions::GetViewType(contents); |
- if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) { |
- process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME; |
- } else if (extension_process_map && |
- extension_process_map->Contains(host->GetProcess()->GetID())) { |
- // For our purposes, don't count processes containing only hosted apps |
- // as extension processes. See also: crbug.com/102533. |
- std::set<std::string> extension_ids = |
- extension_process_map->GetExtensionsInProcess( |
- host->GetProcess()->GetID()); |
- for (std::set<std::string>::iterator iter = extension_ids.begin(); |
- iter != extension_ids.end(); ++iter) { |
- const Extension* extension = |
- extension_service->GetExtensionById(*iter, false); |
- if (extension && !extension->is_hosted_app()) { |
- process.renderer_type = |
- ProcessMemoryInformation::RENDERER_EXTENSION; |
- break; |
- } |
- } |
- } |
- if (extension_process_map && |
- extension_process_map->Contains(host->GetProcess()->GetID())) { |
+ RenderViewHost* host = |
+ RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); |
+ WebContents* contents = WebContents::FromRenderViewHost(host); |
+ GURL url; |
+ if (contents) |
+ url = contents->GetURL(); |
+ extensions::ViewType type = extensions::GetViewType(contents); |
+ if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) { |
+ process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME; |
+ } else if (extension_process_map && |
+ extension_process_map->Contains(host->GetProcess()->GetID())) { |
+ // For our purposes, don't count processes containing only hosted apps |
+ // as extension processes. See also: crbug.com/102533. |
+ std::set<std::string> extension_ids = |
+ extension_process_map->GetExtensionsInProcess( |
+ host->GetProcess()->GetID()); |
+ for (std::set<std::string>::iterator iter = extension_ids.begin(); |
+ iter != extension_ids.end(); ++iter) { |
const Extension* extension = |
- extension_service->extensions()->GetByID(url.host()); |
- if (extension) { |
- string16 title = UTF8ToUTF16(extension->name()); |
- process.titles.push_back(title); |
+ extension_service->GetExtensionById(*iter, false); |
+ if (extension && !extension->is_hosted_app()) { |
process.renderer_type = |
ProcessMemoryInformation::RENDERER_EXTENSION; |
- continue; |
+ break; |
} |
} |
- |
- if (!contents) { |
+ } |
+ if (extension_process_map && |
+ extension_process_map->Contains(host->GetProcess()->GetID())) { |
+ const Extension* extension = |
+ extension_service->extensions()->GetByID(url.host()); |
+ if (extension) { |
+ string16 title = UTF8ToUTF16(extension->name()); |
+ process.titles.push_back(title); |
process.renderer_type = |
- ProcessMemoryInformation::RENDERER_INTERSTITIAL; |
+ ProcessMemoryInformation::RENDERER_EXTENSION; |
continue; |
} |
+ } |
- if (type == extensions::VIEW_TYPE_BACKGROUND_CONTENTS) { |
- process.titles.push_back(UTF8ToUTF16(url.spec())); |
- process.renderer_type = |
- ProcessMemoryInformation::RENDERER_BACKGROUND_APP; |
- continue; |
- } |
+ if (!contents) { |
+ process.renderer_type = |
+ ProcessMemoryInformation::RENDERER_INTERSTITIAL; |
+ continue; |
+ } |
- if (type == extensions::VIEW_TYPE_NOTIFICATION) { |
- process.titles.push_back(UTF8ToUTF16(url.spec())); |
- process.renderer_type = |
- ProcessMemoryInformation::RENDERER_NOTIFICATION; |
- continue; |
- } |
+ if (type == extensions::VIEW_TYPE_BACKGROUND_CONTENTS) { |
+ process.titles.push_back(UTF8ToUTF16(url.spec())); |
+ process.renderer_type = |
+ ProcessMemoryInformation::RENDERER_BACKGROUND_APP; |
+ continue; |
+ } |
+ |
+ if (type == extensions::VIEW_TYPE_NOTIFICATION) { |
+ process.titles.push_back(UTF8ToUTF16(url.spec())); |
+ process.renderer_type = |
+ ProcessMemoryInformation::RENDERER_NOTIFICATION; |
+ continue; |
+ } |
- // Since we have a WebContents and and the renderer type hasn't been |
- // set yet, it must be a normal tabbed renderer. |
- if (process.renderer_type == ProcessMemoryInformation::RENDERER_UNKNOWN) |
- process.renderer_type = ProcessMemoryInformation::RENDERER_NORMAL; |
- |
- string16 title = contents->GetTitle(); |
- if (!title.length()) |
- title = l10n_util::GetStringUTF16(IDS_DEFAULT_TAB_TITLE); |
- process.titles.push_back(title); |
- |
- // We need to check the pending entry as well as the virtual_url to |
- // see if it's a chrome://memory URL (we don't want to count these in |
- // the total memory usage of the browser). |
- // |
- // When we reach here, chrome://memory will be the pending entry since |
- // we haven't responded with any data such that it would be committed. |
- // If you have another chrome://memory tab open (which would be |
- // committed), we don't want to count it either, so we also check the |
- // last committed entry. |
- // |
- // Either the pending or last committed entries can be NULL. |
- const NavigationEntry* pending_entry = |
- contents->GetController().GetPendingEntry(); |
- const NavigationEntry* last_committed_entry = |
- contents->GetController().GetLastCommittedEntry(); |
- if ((last_committed_entry && |
- LowerCaseEqualsASCII(last_committed_entry->GetVirtualURL().spec(), |
- chrome::kChromeUIMemoryURL)) || |
- (pending_entry && |
- LowerCaseEqualsASCII(pending_entry->GetVirtualURL().spec(), |
- chrome::kChromeUIMemoryURL))) |
- process.is_diagnostics = true; |
+ // Since we have a WebContents and and the renderer type hasn't been |
+ // set yet, it must be a normal tabbed renderer. |
+ if (process.renderer_type == ProcessMemoryInformation::RENDERER_UNKNOWN) |
+ process.renderer_type = ProcessMemoryInformation::RENDERER_NORMAL; |
+ |
+ string16 title = contents->GetTitle(); |
+ if (!title.length()) |
+ title = l10n_util::GetStringUTF16(IDS_DEFAULT_TAB_TITLE); |
+ process.titles.push_back(title); |
+ |
+ // We need to check the pending entry as well as the virtual_url to |
+ // see if it's a chrome://memory URL (we don't want to count these in |
+ // the total memory usage of the browser). |
+ // |
+ // When we reach here, chrome://memory will be the pending entry since |
+ // we haven't responded with any data such that it would be committed. |
+ // If you have another chrome://memory tab open (which would be |
+ // committed), we don't want to count it either, so we also check the |
+ // last committed entry. |
+ // |
+ // Either the pending or last committed entries can be NULL. |
+ const NavigationEntry* pending_entry = |
+ contents->GetController().GetPendingEntry(); |
+ const NavigationEntry* last_committed_entry = |
+ contents->GetController().GetLastCommittedEntry(); |
+ if ((last_committed_entry && |
+ LowerCaseEqualsASCII(last_committed_entry->GetVirtualURL().spec(), |
+ chrome::kChromeUIMemoryURL)) || |
+ (pending_entry && |
+ LowerCaseEqualsASCII(pending_entry->GetVirtualURL().spec(), |
+ chrome::kChromeUIMemoryURL))) { |
+ process.is_diagnostics = true; |
} |
} |