Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7509)

Unified Diff: chrome/browser/memory_details.cc

Issue 5981007: fix about:memory and memory histograms to show extensions more clearly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/memory_details.cc
diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc
index 6f83083ae526997d76867a2bd638314fe3fd63c1..9cad3ce8ec138af45158597fc90a3bc05a1eb7b2 100644
--- a/chrome/browser/memory_details.cc
+++ b/chrome/browser/memory_details.cc
@@ -12,11 +12,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"
#include "grit/generated_resources.h"
@@ -30,7 +33,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() {}
@@ -90,6 +94,7 @@ void MemoryDetails::CollectChildInfoOnIOThread() {
continue;
info.type = iter->type();
+ info.renderer_type = iter->renderer_type();
info.titles.push_back(WideToUTF16Hack(iter->name()));
child_info.push_back(info);
}
@@ -113,19 +118,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();
Mike Belshe 2010/12/24 00:50:53 nit: I have to think when I see "rph" as to what
Erik does not do reviews 2010/12/28 16:59:18 Done.
+ 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;
@@ -136,8 +141,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());
@@ -146,11 +150,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;
+ }
+
string16 title = contents->GetTitle();
if (!title.length())
title = l10n_util::GetStringUTF16(IDS_DEFAULT_TAB_TITLE);
@@ -212,7 +234,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);
@@ -221,9 +247,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:
Mike Belshe 2010/12/24 00:50:53 should there be a DCHECK in the RENDERER_UNKNOWN c
Erik does not do reviews 2010/12/28 16:59:18 Done.
+ 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++;
@@ -234,21 +278,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();
@@ -259,7 +309,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?

Powered by Google App Engine
This is Rietveld 408576698