| Index: chrome/browser/memory_details.cc
|
| diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc
|
| index cd72b258cef458972966dcf362ae3aba6c58aace..38a6076e1a69ddddbc156996c39043ab80705631 100644
|
| --- a/chrome/browser/memory_details.cc
|
| +++ b/chrome/browser/memory_details.cc
|
| @@ -11,11 +11,14 @@
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/browser/browser_child_process_host.h"
|
| #include "chrome/browser/browser_thread.h"
|
| +#include "chrome/browser/extensions/extension_host.h"
|
| #include "chrome/browser/renderer_host/backing_store_manager.h"
|
| #include "chrome/browser/renderer_host/render_process_host.h"
|
| #include "chrome/browser/renderer_host/render_view_host.h"
|
| #include "chrome/browser/tab_contents/navigation_entry.h"
|
| #include "chrome/browser/tab_contents/tab_contents.h"
|
| +#include "chrome/common/bindings_policy.h"
|
| +#include "chrome/common/extensions/extension.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "grit/chromium_strings.h"
|
|
|
| @@ -28,7 +31,8 @@ ProcessMemoryInformation::ProcessMemoryInformation()
|
| : pid(0),
|
| num_processes(0),
|
| is_diagnostics(false),
|
| - type(ChildProcessInfo::UNKNOWN_PROCESS) {
|
| + type(ChildProcessInfo::UNKNOWN_PROCESS),
|
| + renderer_type(ChildProcessInfo::RENDERER_UNKNOWN) {
|
| }
|
|
|
| ProcessMemoryInformation::~ProcessMemoryInformation() {}
|
| @@ -88,6 +92,7 @@ void MemoryDetails::CollectChildInfoOnIOThread() {
|
| continue;
|
|
|
| info.type = iter->type();
|
| + info.renderer_type = iter->renderer_type();
|
| info.titles.push_back(iter->name());
|
| child_info.push_back(info);
|
| }
|
| @@ -111,19 +116,19 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
|
| for (size_t index = 0; index < chrome_browser->processes.size();
|
| index++) {
|
| // Check if it's a renderer, if so get the list of page titles in it and
|
| - // check if it's a diagnostics-related process. We skip all diagnostics
|
| - // pages (e.g. "about:xxx" URLs). Iterate the RenderProcessHosts to find
|
| - // the tab contents.
|
| + // check if it's a diagnostics-related process. We skip about:memory pages.
|
| + // Iterate the RenderProcessHosts to find the tab contents.
|
| ProcessMemoryInformation& process =
|
| chrome_browser->processes[index];
|
|
|
| for (RenderProcessHost::iterator renderer_iter(
|
| RenderProcessHost::AllHostsIterator()); !renderer_iter.IsAtEnd();
|
| renderer_iter.Advance()) {
|
| - DCHECK(renderer_iter.GetCurrentValue());
|
| + RenderProcessHost* rph = renderer_iter.GetCurrentValue();
|
| + DCHECK(rph);
|
| // Ignore processes that don't have a connection, such as crashed tabs.
|
| - if (!renderer_iter.GetCurrentValue()->HasConnection() || process.pid !=
|
| - base::GetProcId(renderer_iter.GetCurrentValue()->GetHandle())) {
|
| + if (!rph->HasConnection() ||
|
| + process.pid != base::GetProcId(rph->GetHandle())) {
|
| continue;
|
| }
|
| process.type = ChildProcessInfo::RENDER_PROCESS;
|
| @@ -134,8 +139,7 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
|
| // NOTE: This is a bit dangerous. We know that for now, listeners
|
| // are always RenderWidgetHosts. But in theory, they don't
|
| // have to be.
|
| - RenderProcessHost::listeners_iterator iter(
|
| - renderer_iter.GetCurrentValue()->ListenersIterator());
|
| + RenderProcessHost::listeners_iterator iter(rph->ListenersIterator());
|
| for (; !iter.IsAtEnd(); iter.Advance()) {
|
| const RenderWidgetHost* widget =
|
| static_cast<const RenderWidgetHost*>(iter.GetCurrentValue());
|
| @@ -144,11 +148,29 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
|
| continue;
|
|
|
| const RenderViewHost* host = static_cast<const RenderViewHost*>(widget);
|
| + if (host->enabled_bindings() && BindingsPolicy::EXTENSION) {
|
| + process.renderer_type = ChildProcessInfo::RENDERER_EXTENSION;
|
| + } else if (host->enabled_bindings() && BindingsPolicy::DOM_UI) {
|
| + process.renderer_type = ChildProcessInfo::RENDERER_CHROME;
|
| + } else {
|
| + process.renderer_type = ChildProcessInfo::RENDERER_NORMAL;
|
| + }
|
| TabContents* contents = NULL;
|
| if (host->delegate())
|
| contents = host->delegate()->GetAsTabContents();
|
| - if (!contents)
|
| + if (!contents) {
|
| + if (host->is_extension_process()) {
|
| + // TODO(erikkay) should we just add GetAsExtensionHost to
|
| + // TabContents?
|
| + ExtensionHost* eh = static_cast<ExtensionHost*>(host->delegate());
|
| + std::wstring title = UTF8ToWide(eh->extension()->name());
|
| + process.titles.push_back(title);
|
| + } else {
|
| + process.renderer_type = ChildProcessInfo::RENDERER_UNKNOWN;
|
| + }
|
| continue;
|
| + }
|
| +
|
| std::wstring title = UTF16ToWideHack(contents->GetTitle());
|
| if (!title.length())
|
| title = L"Untitled";
|
| @@ -210,7 +232,11 @@ void MemoryDetails::UpdateHistograms() {
|
|
|
| const ProcessData& browser = *ChromeBrowser();
|
| size_t aggregate_memory = 0;
|
| + int chrome_count = 0;
|
| + int extension_count = 0;
|
| int plugin_count = 0;
|
| + int renderer_count = 0;
|
| + int other_count = 0;
|
| int worker_count = 0;
|
| for (size_t index = 0; index < browser.processes.size(); index++) {
|
| int sample = static_cast<int>(browser.processes[index].working_set.priv);
|
| @@ -219,9 +245,27 @@ void MemoryDetails::UpdateHistograms() {
|
| case ChildProcessInfo::BROWSER_PROCESS:
|
| UMA_HISTOGRAM_MEMORY_KB("Memory.Browser", sample);
|
| break;
|
| - case ChildProcessInfo::RENDER_PROCESS:
|
| - UMA_HISTOGRAM_MEMORY_KB("Memory.Renderer", sample);
|
| + case ChildProcessInfo::RENDER_PROCESS: {
|
| + ChildProcessInfo::RendererProcessType renderer_type =
|
| + browser.processes[index].renderer_type;
|
| + switch (renderer_type) {
|
| + case ChildProcessInfo::RENDERER_EXTENSION:
|
| + UMA_HISTOGRAM_MEMORY_KB("Memory.Extension", sample);
|
| + extension_count++;
|
| + break;
|
| + case ChildProcessInfo::RENDERER_CHROME:
|
| + UMA_HISTOGRAM_MEMORY_KB("Memory.Chrome", sample);
|
| + chrome_count++;
|
| + break;
|
| + case ChildProcessInfo::RENDERER_UNKNOWN:
|
| + case ChildProcessInfo::RENDERER_NORMAL:
|
| + default:
|
| + UMA_HISTOGRAM_MEMORY_KB("Memory.Renderer", sample);
|
| + renderer_count++;
|
| + break;
|
| + }
|
| break;
|
| + }
|
| case ChildProcessInfo::PLUGIN_PROCESS:
|
| UMA_HISTOGRAM_MEMORY_KB("Memory.Plugin", sample);
|
| plugin_count++;
|
| @@ -232,21 +276,27 @@ void MemoryDetails::UpdateHistograms() {
|
| break;
|
| case ChildProcessInfo::UTILITY_PROCESS:
|
| UMA_HISTOGRAM_MEMORY_KB("Memory.Utility", sample);
|
| + other_count++;
|
| break;
|
| case ChildProcessInfo::ZYGOTE_PROCESS:
|
| UMA_HISTOGRAM_MEMORY_KB("Memory.Zygote", sample);
|
| + other_count++;
|
| break;
|
| case ChildProcessInfo::SANDBOX_HELPER_PROCESS:
|
| UMA_HISTOGRAM_MEMORY_KB("Memory.SandboxHelper", sample);
|
| + other_count++;
|
| break;
|
| case ChildProcessInfo::NACL_LOADER_PROCESS:
|
| UMA_HISTOGRAM_MEMORY_KB("Memory.NativeClient", sample);
|
| + other_count++;
|
| break;
|
| case ChildProcessInfo::NACL_BROKER_PROCESS:
|
| UMA_HISTOGRAM_MEMORY_KB("Memory.NativeClientBroker", sample);
|
| + other_count++;
|
| break;
|
| case ChildProcessInfo::GPU_PROCESS:
|
| UMA_HISTOGRAM_MEMORY_KB("Memory.Gpu", sample);
|
| + other_count++;
|
| break;
|
| default:
|
| NOTREACHED();
|
| @@ -257,7 +307,11 @@ void MemoryDetails::UpdateHistograms() {
|
|
|
| UMA_HISTOGRAM_COUNTS_100("Memory.ProcessCount",
|
| static_cast<int>(browser.processes.size()));
|
| + UMA_HISTOGRAM_COUNTS_100("Memory.ChromeProcessCount", chrome_count);
|
| + UMA_HISTOGRAM_COUNTS_100("Memory.ExtensionProcessCount", extension_count);
|
| + UMA_HISTOGRAM_COUNTS_100("Memory.OtherProcessCount", other_count);
|
| UMA_HISTOGRAM_COUNTS_100("Memory.PluginProcessCount", plugin_count);
|
| + UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count);
|
| UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count);
|
| // TODO(viettrungluu): Do we want separate counts for the other
|
| // (platform-specific) process types?
|
|
|