blob: ea3985c7d61fb47c4c2c43d73cbb8a4f54c16397 [file] [log] [blame]
[email protected]b0b67cfe2012-01-18 21:59:571// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
5#include "chrome/browser/memory_details.h"
initial.commit09911bf2008-07-26 23:55:296
[email protected]24d69692011-10-21 18:26:517#include "base/bind.h"
initial.commit09911bf2008-07-26 23:55:298#include "base/file_version_info.h"
[email protected]835d7c82010-10-14 04:38:389#include "base/metrics/histogram.h"
[email protected]76543b92009-08-31 17:27:4510#include "base/process_util.h"
[email protected]33b9df42010-07-29 06:46:3911#include "base/string_util.h"
[email protected]64048bd2010-03-08 23:28:5812#include "base/utf_string_conversions.h"
[email protected]8add5412011-10-01 21:02:1413#include "chrome/browser/extensions/extension_process_manager.h"
[email protected]79dc42cd2011-01-08 21:43:3514#include "chrome/browser/extensions/extension_service.h"
15#include "chrome/browser/profiles/profile.h"
[email protected]14afc012011-12-01 01:04:3916#include "chrome/common/chrome_view_type.h"
[email protected]fcf79352010-12-28 20:13:2017#include "chrome/common/extensions/extension.h"
[email protected]cd3d7892009-03-04 23:55:0618#include "chrome/common/url_constants.h"
[email protected]4967f792012-01-20 22:14:4019#include "content/public/browser/browser_child_process_host_iterator.h"
20#include "content/public/browser/child_process_data.h"
[email protected]a01efd22011-03-01 00:38:3221#include "content/browser/renderer_host/backing_store_manager.h"
[email protected]a01efd22011-03-01 00:38:3222#include "content/browser/renderer_host/render_view_host.h"
[email protected]c38831a12011-10-28 12:44:4923#include "content/public/browser/browser_thread.h"
[email protected]a53209b2012-01-20 16:48:1624#include "content/public/browser/navigation_controller.h"
[email protected]022af742011-12-28 18:37:2525#include "content/public/browser/navigation_entry.h"
[email protected]f3b1a082011-11-18 00:34:3026#include "content/public/browser/render_process_host.h"
[email protected]b0b67cfe2012-01-18 21:59:5727#include "content/public/browser/render_view_host_delegate.h"
[email protected]83ff91c2012-01-05 20:54:1328#include "content/public/browser/web_contents.h"
[email protected]e091df82011-10-11 18:13:2129#include "content/public/common/bindings_policy.h"
[email protected]a54311142011-12-01 05:13:4130#include "content/public/common/process_type.h"
[email protected]ae5ca892009-07-30 18:00:4731#include "grit/chromium_strings.h"
[email protected]4f260d02010-12-23 18:35:4232#include "grit/generated_resources.h"
[email protected]c051a1b2011-01-21 23:30:1733#include "ui/base/l10n/l10n_util.h"
initial.commit09911bf2008-07-26 23:55:2934
[email protected]1fd5302c2011-05-28 04:06:4335#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]a01efd22011-03-01 00:38:3236#include "content/browser/renderer_host/render_sandbox_host_linux.h"
[email protected]c2c68b1f2012-02-25 00:29:1537#include "content/public/browser/zygote_host_linux.h"
[email protected]54fd1d32009-09-01 00:12:5838#endif
initial.commit09911bf2008-07-26 23:55:2939
[email protected]4967f792012-01-20 22:14:4040using content::BrowserChildProcessHostIterator;
[email protected]631bb742011-11-02 11:29:3941using content::BrowserThread;
[email protected]10f417c52011-12-28 21:04:2342using content::NavigationEntry;
[email protected]83ff91c2012-01-05 20:54:1343using content::WebContents;
[email protected]631bb742011-11-02 11:29:3944
[email protected]2c1978a2011-11-29 17:02:3945// static
46std::string ProcessMemoryInformation::GetRendererTypeNameInEnglish(
47 RendererProcessType type) {
48 switch (type) {
49 case RENDERER_NORMAL:
50 return "Tab";
51 case RENDERER_CHROME:
52 return "Tab (Chrome)";
53 case RENDERER_EXTENSION:
54 return "Extension";
55 case RENDERER_DEVTOOLS:
56 return "Devtools";
57 case RENDERER_INTERSTITIAL:
58 return "Interstitial";
59 case RENDERER_NOTIFICATION:
60 return "Notification";
61 case RENDERER_BACKGROUND_APP:
62 return "Background App";
63 case RENDERER_UNKNOWN:
64 default:
65 NOTREACHED() << "Unknown renderer process type!";
66 return "Unknown";
67 }
68}
69
70// static
71std::string ProcessMemoryInformation::GetFullTypeNameInEnglish(
[email protected]bd5d6cf2011-12-01 00:39:1272 content::ProcessType type,
[email protected]2c1978a2011-11-29 17:02:3973 RendererProcessType rtype) {
[email protected]bd5d6cf2011-12-01 00:39:1274 if (type == content::PROCESS_TYPE_RENDERER)
[email protected]2c1978a2011-11-29 17:02:3975 return GetRendererTypeNameInEnglish(rtype);
[email protected]a54311142011-12-01 05:13:4176 return content::GetProcessTypeNameInEnglish(type);
[email protected]2c1978a2011-11-29 17:02:3977}
78
[email protected]8e383412010-10-19 16:57:0379ProcessMemoryInformation::ProcessMemoryInformation()
80 : pid(0),
81 num_processes(0),
82 is_diagnostics(false),
[email protected]bd5d6cf2011-12-01 00:39:1283 type(content::PROCESS_TYPE_UNKNOWN),
[email protected]2c1978a2011-11-29 17:02:3984 renderer_type(RENDERER_UNKNOWN) {
[email protected]8e383412010-10-19 16:57:0385}
86
87ProcessMemoryInformation::~ProcessMemoryInformation() {}
88
[email protected]93aa89c72010-10-20 21:32:0489ProcessData::ProcessData() {}
90
91ProcessData::ProcessData(const ProcessData& rhs)
92 : name(rhs.name),
93 process_name(rhs.process_name),
94 processes(rhs.processes) {
95}
96
97ProcessData::~ProcessData() {}
98
99ProcessData& ProcessData::operator=(const ProcessData& rhs) {
100 name = rhs.name;
101 process_name = rhs.process_name;
102 processes = rhs.processes;
103 return *this;
104}
105
initial.commit09911bf2008-07-26 23:55:29106// About threading:
107//
108// This operation will hit no fewer than 3 threads.
109//
[email protected]a436d922009-02-13 23:16:42110// The ChildProcessInfo::Iterator can only be accessed from the IO thread.
initial.commit09911bf2008-07-26 23:55:29111//
112// The RenderProcessHostIterator can only be accessed from the UI thread.
113//
114// This operation can take 30-100ms to complete. We never want to have
115// one task run for that long on the UI or IO threads. So, we run the
116// expensive parts of this operation over on the file thread.
117//
initial.commit09911bf2008-07-26 23:55:29118void MemoryDetails::StartFetch() {
[email protected]9bb480ee2011-08-03 21:41:16119 // This might get called from the UI or FILE threads, but should not be
120 // getting called from the IO thread.
[email protected]f8b3ef82010-10-11 02:45:52121 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
initial.commit09911bf2008-07-26 23:55:29122
123 // In order to process this request, we need to use the plugin information.
124 // However, plugin process information is only available from the IO thread.
[email protected]f8b3ef82010-10-11 02:45:52125 BrowserThread::PostTask(
126 BrowserThread::IO, FROM_HERE,
[email protected]24d69692011-10-21 18:26:51127 base::Bind(&MemoryDetails::CollectChildInfoOnIOThread, this));
initial.commit09911bf2008-07-26 23:55:29128}
129
[email protected]8e383412010-10-19 16:57:03130MemoryDetails::~MemoryDetails() {}
131
[email protected]a27a9382009-02-11 23:55:10132void MemoryDetails::CollectChildInfoOnIOThread() {
[email protected]f8b3ef82010-10-11 02:45:52133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
initial.commit09911bf2008-07-26 23:55:29134
[email protected]a27a9382009-02-11 23:55:10135 std::vector<ProcessMemoryInformation> child_info;
136
[email protected]a436d922009-02-13 23:16:42137 // Collect the list of child processes.
[email protected]4967f792012-01-20 22:14:40138 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) {
[email protected]a27a9382009-02-11 23:55:10139 ProcessMemoryInformation info;
[email protected]4967f792012-01-20 22:14:40140 info.pid = base::GetProcId(iter.GetData().handle);
[email protected]a27a9382009-02-11 23:55:10141 if (!info.pid)
142 continue;
143
[email protected]4967f792012-01-20 22:14:40144 info.type = iter.GetData().type;
[email protected]2c1978a2011-11-29 17:02:39145 info.renderer_type = ProcessMemoryInformation::RENDERER_UNKNOWN;
[email protected]4967f792012-01-20 22:14:40146 info.titles.push_back(iter.GetData().name);
[email protected]a27a9382009-02-11 23:55:10147 child_info.push_back(info);
initial.commit09911bf2008-07-26 23:55:29148 }
149
150 // Now go do expensive memory lookups from the file thread.
[email protected]f8b3ef82010-10-11 02:45:52151 BrowserThread::PostTask(
152 BrowserThread::FILE, FROM_HERE,
[email protected]24d69692011-10-21 18:26:51153 base::Bind(&MemoryDetails::CollectProcessData, this, child_info));
initial.commit09911bf2008-07-26 23:55:29154}
155
[email protected]a27a9382009-02-11 23:55:10156void MemoryDetails::CollectChildInfoOnUIThread() {
[email protected]f8b3ef82010-10-11 02:45:52157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
initial.commit09911bf2008-07-26 23:55:29158
[email protected]1fd5302c2011-05-28 04:06:43159#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]c2c68b1f2012-02-25 00:29:15160 const pid_t zygote_pid = content::ZygoteHost::GetInstance()->GetPid();
[email protected]d3c6c0d72010-12-09 08:15:04161 const pid_t sandbox_helper_pid = RenderSandboxHostLinux::GetInstance()->pid();
[email protected]54fd1d32009-09-01 00:12:58162#endif
163
164 ProcessData* const chrome_browser = ChromeBrowser();
[email protected]a27a9382009-02-11 23:55:10165 // Get more information about the process.
[email protected]54fd1d32009-09-01 00:12:58166 for (size_t index = 0; index < chrome_browser->processes.size();
initial.commit09911bf2008-07-26 23:55:29167 index++) {
[email protected]a27a9382009-02-11 23:55:10168 // Check if it's a renderer, if so get the list of page titles in it and
[email protected]fcf79352010-12-28 20:13:20169 // check if it's a diagnostics-related process. We skip about:memory pages.
170 // Iterate the RenderProcessHosts to find the tab contents.
[email protected]54fd1d32009-09-01 00:12:58171 ProcessMemoryInformation& process =
172 chrome_browser->processes[index];
173
[email protected]f3b1a082011-11-18 00:34:30174 for (content::RenderProcessHost::iterator renderer_iter(
175 content::RenderProcessHost::AllHostsIterator());
176 !renderer_iter.IsAtEnd(); renderer_iter.Advance()) {
177 content::RenderProcessHost* render_process_host =
178 renderer_iter.GetCurrentValue();
[email protected]fcf79352010-12-28 20:13:20179 DCHECK(render_process_host);
[email protected]8a34e6602010-10-02 17:29:43180 // Ignore processes that don't have a connection, such as crashed tabs.
[email protected]fcf79352010-12-28 20:13:20181 if (!render_process_host->HasConnection() ||
182 process.pid != base::GetProcId(render_process_host->GetHandle())) {
[email protected]a27a9382009-02-11 23:55:10183 continue;
[email protected]201b2732009-11-13 18:57:46184 }
[email protected]bd5d6cf2011-12-01 00:39:12185 process.type = content::PROCESS_TYPE_RENDERER;
[email protected]9b62ecf2011-07-27 20:23:08186 Profile* profile =
[email protected]f3b1a082011-11-18 00:34:30187 Profile::FromBrowserContext(
188 render_process_host->GetBrowserContext());
[email protected]79dc42cd2011-01-08 21:43:35189 ExtensionService* extension_service = profile->GetExtensionService();
[email protected]6f371442011-11-09 06:45:46190 extensions::ProcessMap* extension_process_map =
191 extension_service->process_map();
[email protected]79dc42cd2011-01-08 21:43:35192
[email protected]a27a9382009-02-11 23:55:10193 // The RenderProcessHost may host multiple TabContents. Any
194 // of them which contain diagnostics information make the whole
195 // process be considered a diagnostics process.
196 //
197 // NOTE: This is a bit dangerous. We know that for now, listeners
198 // are always RenderWidgetHosts. But in theory, they don't
199 // have to be.
[email protected]f3b1a082011-11-18 00:34:30200 content::RenderProcessHost::listeners_iterator iter(
[email protected]fcf79352010-12-28 20:13:20201 render_process_host->ListenersIterator());
[email protected]9de09f82009-08-17 20:13:53202 for (; !iter.IsAtEnd(); iter.Advance()) {
203 const RenderWidgetHost* widget =
[email protected]fd1ff072012-02-23 14:48:22204 RenderWidgetHost::FromIPCChannelListener(iter.GetCurrentValue());
[email protected]a27a9382009-02-11 23:55:10205 DCHECK(widget);
206 if (!widget || !widget->IsRenderView())
207 continue;
initial.commit09911bf2008-07-26 23:55:29208
[email protected]9de09f82009-08-17 20:13:53209 const RenderViewHost* host = static_cast<const RenderViewHost*>(widget);
[email protected]b0b67cfe2012-01-18 21:59:57210 content::RenderViewHostDelegate* host_delegate = host->delegate();
[email protected]4e6ffde2011-03-11 00:59:27211 DCHECK(host_delegate);
[email protected]fcf79352010-12-28 20:13:20212 GURL url = host_delegate->GetURL();
[email protected]da4dfc42011-10-12 15:53:56213 content::ViewType type = host_delegate->GetRenderViewType();
[email protected]e091df82011-10-11 18:13:21214 if (host->enabled_bindings() & content::BINDINGS_POLICY_WEB_UI) {
[email protected]fcf79352010-12-28 20:13:20215 // TODO(erikkay) the type for devtools doesn't actually appear to
216 // be set.
[email protected]da4dfc42011-10-12 15:53:56217 if (type == content::VIEW_TYPE_DEV_TOOLS_UI)
[email protected]2c1978a2011-11-29 17:02:39218 process.renderer_type = ProcessMemoryInformation::RENDERER_DEVTOOLS;
[email protected]fcf79352010-12-28 20:13:20219 else
[email protected]2c1978a2011-11-29 17:02:39220 process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME;
[email protected]f3b1a082011-11-18 00:34:30221 } else if (extension_process_map->Contains(host->process()->GetID())) {
[email protected]6f371442011-11-09 06:45:46222 // For our purposes, don't count processes containing only hosted apps
223 // as extension processes. See also: crbug.com/102533.
224 std::set<std::string> extension_ids =
225 extension_process_map->GetExtensionsInProcess(
[email protected]f3b1a082011-11-18 00:34:30226 host->process()->GetID());
[email protected]6f371442011-11-09 06:45:46227 for (std::set<std::string>::iterator iter = extension_ids.begin();
228 iter != extension_ids.end(); ++iter) {
229 const Extension* extension =
230 extension_service->GetExtensionById(*iter, false);
231 if (extension && !extension->is_hosted_app()) {
[email protected]2c1978a2011-11-29 17:02:39232 process.renderer_type =
233 ProcessMemoryInformation::RENDERER_EXTENSION;
[email protected]6f371442011-11-09 06:45:46234 break;
235 }
236 }
[email protected]fcf79352010-12-28 20:13:20237 }
[email protected]83ff91c2012-01-05 20:54:13238 WebContents* contents = host_delegate->GetAsWebContents();
[email protected]fcf79352010-12-28 20:13:20239 if (!contents) {
[email protected]f3b1a082011-11-18 00:34:30240 if (extension_process_map->Contains(host->process()->GetID())) {
[email protected]79dc42cd2011-01-08 21:43:35241 const Extension* extension =
[email protected]615d88f2011-12-13 01:47:44242 extension_service->extensions()->GetByID(url.host());
[email protected]79dc42cd2011-01-08 21:43:35243 if (extension) {
244 string16 title = UTF8ToUTF16(extension->name());
245 process.titles.push_back(title);
246 }
[email protected]fcf79352010-12-28 20:13:20247 } else if (process.renderer_type ==
[email protected]2c1978a2011-11-29 17:02:39248 ProcessMemoryInformation::RENDERER_UNKNOWN) {
[email protected]fcf79352010-12-28 20:13:20249 process.titles.push_back(UTF8ToUTF16(url.spec()));
250 switch (type) {
[email protected]da4dfc42011-10-12 15:53:56251 case chrome::VIEW_TYPE_BACKGROUND_CONTENTS:
[email protected]fcf79352010-12-28 20:13:20252 process.renderer_type =
[email protected]2c1978a2011-11-29 17:02:39253 ProcessMemoryInformation::RENDERER_BACKGROUND_APP;
[email protected]fcf79352010-12-28 20:13:20254 break;
[email protected]da4dfc42011-10-12 15:53:56255 case content::VIEW_TYPE_INTERSTITIAL_PAGE:
[email protected]2c1978a2011-11-29 17:02:39256 process.renderer_type =
257 ProcessMemoryInformation::RENDERER_INTERSTITIAL;
[email protected]fcf79352010-12-28 20:13:20258 break;
[email protected]da4dfc42011-10-12 15:53:56259 case chrome::VIEW_TYPE_NOTIFICATION:
[email protected]2c1978a2011-11-29 17:02:39260 process.renderer_type =
261 ProcessMemoryInformation::RENDERER_NOTIFICATION;
[email protected]fcf79352010-12-28 20:13:20262 break;
263 default:
[email protected]2c1978a2011-11-29 17:02:39264 process.renderer_type =
265 ProcessMemoryInformation::RENDERER_UNKNOWN;
[email protected]fcf79352010-12-28 20:13:20266 break;
267 }
268 }
[email protected]a27a9382009-02-11 23:55:10269 continue;
[email protected]fcf79352010-12-28 20:13:20270 }
271
[email protected]83ff91c2012-01-05 20:54:13272 // Since We have a WebContents and and the renderer type hasn't been
[email protected]fcf79352010-12-28 20:13:20273 // set yet, it must be a normal tabbed renderer.
[email protected]2c1978a2011-11-29 17:02:39274 if (process.renderer_type == ProcessMemoryInformation::RENDERER_UNKNOWN)
275 process.renderer_type = ProcessMemoryInformation::RENDERER_NORMAL;
[email protected]fcf79352010-12-28 20:13:20276
[email protected]4f260d02010-12-23 18:35:42277 string16 title = contents->GetTitle();
[email protected]a27a9382009-02-11 23:55:10278 if (!title.length())
[email protected]4f260d02010-12-23 18:35:42279 title = l10n_util::GetStringUTF16(IDS_DEFAULT_TAB_TITLE);
[email protected]a27a9382009-02-11 23:55:10280 process.titles.push_back(title);
[email protected]cd3d7892009-03-04 23:55:06281
[email protected]ebe89e062009-08-13 23:16:54282 // We need to check the pending entry as well as the virtual_url to
[email protected]37ae3f22011-07-12 03:56:14283 // see if it's a chrome://memory URL (we don't want to count these in
284 // the total memory usage of the browser).
[email protected]cd3d7892009-03-04 23:55:06285 //
[email protected]37ae3f22011-07-12 03:56:14286 // When we reach here, chrome://memory will be the pending entry since
287 // we haven't responded with any data such that it would be committed.
288 // If you have another chrome://memory tab open (which would be
289 // committed), we don't want to count it either, so we also check the
290 // last committed entry.
[email protected]cd3d7892009-03-04 23:55:06291 //
292 // Either the pending or last committed entries can be NULL.
[email protected]10f417c52011-12-28 21:04:23293 const NavigationEntry* pending_entry =
[email protected]022af742011-12-28 18:37:25294 contents->GetController().GetPendingEntry();
[email protected]10f417c52011-12-28 21:04:23295 const NavigationEntry* last_committed_entry =
[email protected]f5fa20e2011-12-21 22:35:56296 contents->GetController().GetLastCommittedEntry();
[email protected]cd3d7892009-03-04 23:55:06297 if ((last_committed_entry &&
[email protected]36fc0392011-12-25 03:59:51298 LowerCaseEqualsASCII(last_committed_entry->GetVirtualURL().spec(),
[email protected]37ae3f22011-07-12 03:56:14299 chrome::kChromeUIMemoryURL)) ||
[email protected]cd3d7892009-03-04 23:55:06300 (pending_entry &&
[email protected]36fc0392011-12-25 03:59:51301 LowerCaseEqualsASCII(pending_entry->GetVirtualURL().spec(),
[email protected]37ae3f22011-07-12 03:56:14302 chrome::kChromeUIMemoryURL)))
[email protected]a27a9382009-02-11 23:55:10303 process.is_diagnostics = true;
initial.commit09911bf2008-07-26 23:55:29304 }
305 }
[email protected]54fd1d32009-09-01 00:12:58306
[email protected]1fd5302c2011-05-28 04:06:43307#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]54fd1d32009-09-01 00:12:58308 if (process.pid == zygote_pid) {
[email protected]bd5d6cf2011-12-01 00:39:12309 process.type = content::PROCESS_TYPE_ZYGOTE;
[email protected]54fd1d32009-09-01 00:12:58310 } else if (process.pid == sandbox_helper_pid) {
[email protected]bd5d6cf2011-12-01 00:39:12311 process.type = content::PROCESS_TYPE_SANDBOX_HELPER;
[email protected]54fd1d32009-09-01 00:12:58312 }
313#endif
initial.commit09911bf2008-07-26 23:55:29314 }
315
[email protected]a27a9382009-02-11 23:55:10316 // Get rid of other Chrome processes that are from a different profile.
[email protected]54fd1d32009-09-01 00:12:58317 for (size_t index = 0; index < chrome_browser->processes.size();
[email protected]a27a9382009-02-11 23:55:10318 index++) {
[email protected]54fd1d32009-09-01 00:12:58319 if (chrome_browser->processes[index].type ==
[email protected]bd5d6cf2011-12-01 00:39:12320 content::PROCESS_TYPE_UNKNOWN) {
[email protected]54fd1d32009-09-01 00:12:58321 chrome_browser->processes.erase(
322 chrome_browser->processes.begin() + index);
[email protected]a436d922009-02-13 23:16:42323 index--;
[email protected]a27a9382009-02-11 23:55:10324 }
325 }
326
initial.commit09911bf2008-07-26 23:55:29327 UpdateHistograms();
328
329 OnDetailsAvailable();
330}
331
332void MemoryDetails::UpdateHistograms() {
333 // Reports a set of memory metrics to UMA.
[email protected]57c4b852009-08-17 21:59:29334 // Memory is measured in KB.
initial.commit09911bf2008-07-26 23:55:29335
[email protected]54fd1d32009-09-01 00:12:58336 const ProcessData& browser = *ChromeBrowser();
initial.commit09911bf2008-07-26 23:55:29337 size_t aggregate_memory = 0;
[email protected]fcf79352010-12-28 20:13:20338 int chrome_count = 0;
339 int extension_count = 0;
[email protected]a27a9382009-02-11 23:55:10340 int plugin_count = 0;
[email protected]eef348fb2011-08-01 21:11:08341 int pepper_plugin_count = 0;
[email protected]fcf79352010-12-28 20:13:20342 int renderer_count = 0;
343 int other_count = 0;
[email protected]a27a9382009-02-11 23:55:10344 int worker_count = 0;
initial.commit09911bf2008-07-26 23:55:29345 for (size_t index = 0; index < browser.processes.size(); index++) {
[email protected]921cd0cc2008-10-21 22:30:55346 int sample = static_cast<int>(browser.processes[index].working_set.priv);
347 aggregate_memory += sample;
[email protected]a27a9382009-02-11 23:55:10348 switch (browser.processes[index].type) {
[email protected]bd5d6cf2011-12-01 00:39:12349 case content::PROCESS_TYPE_BROWSER:
[email protected]f164cea2009-11-05 23:37:40350 UMA_HISTOGRAM_MEMORY_KB("Memory.Browser", sample);
351 break;
[email protected]bd5d6cf2011-12-01 00:39:12352 case content::PROCESS_TYPE_RENDERER: {
[email protected]2c1978a2011-11-29 17:02:39353 ProcessMemoryInformation::RendererProcessType renderer_type =
[email protected]fcf79352010-12-28 20:13:20354 browser.processes[index].renderer_type;
355 switch (renderer_type) {
[email protected]2c1978a2011-11-29 17:02:39356 case ProcessMemoryInformation::RENDERER_EXTENSION:
[email protected]fcf79352010-12-28 20:13:20357 UMA_HISTOGRAM_MEMORY_KB("Memory.Extension", sample);
358 extension_count++;
359 break;
[email protected]2c1978a2011-11-29 17:02:39360 case ProcessMemoryInformation::RENDERER_CHROME:
[email protected]fcf79352010-12-28 20:13:20361 UMA_HISTOGRAM_MEMORY_KB("Memory.Chrome", sample);
362 chrome_count++;
363 break;
[email protected]2c1978a2011-11-29 17:02:39364 case ProcessMemoryInformation::RENDERER_UNKNOWN:
[email protected]fcf79352010-12-28 20:13:20365 NOTREACHED() << "Unknown renderer process type.";
366 break;
[email protected]2c1978a2011-11-29 17:02:39367 case ProcessMemoryInformation::RENDERER_NORMAL:
[email protected]fcf79352010-12-28 20:13:20368 default:
369 // TODO(erikkay): Should we bother splitting out the other subtypes?
370 UMA_HISTOGRAM_MEMORY_KB("Memory.Renderer", sample);
371 renderer_count++;
372 break;
373 }
[email protected]f164cea2009-11-05 23:37:40374 break;
[email protected]fcf79352010-12-28 20:13:20375 }
[email protected]bd5d6cf2011-12-01 00:39:12376 case content::PROCESS_TYPE_PLUGIN:
[email protected]f164cea2009-11-05 23:37:40377 UMA_HISTOGRAM_MEMORY_KB("Memory.Plugin", sample);
378 plugin_count++;
379 break;
[email protected]bd5d6cf2011-12-01 00:39:12380 case content::PROCESS_TYPE_WORKER:
[email protected]f164cea2009-11-05 23:37:40381 UMA_HISTOGRAM_MEMORY_KB("Memory.Worker", sample);
382 worker_count++;
383 break;
[email protected]bd5d6cf2011-12-01 00:39:12384 case content::PROCESS_TYPE_UTILITY:
[email protected]f164cea2009-11-05 23:37:40385 UMA_HISTOGRAM_MEMORY_KB("Memory.Utility", sample);
[email protected]fcf79352010-12-28 20:13:20386 other_count++;
[email protected]f164cea2009-11-05 23:37:40387 break;
[email protected]bd5d6cf2011-12-01 00:39:12388 case content::PROCESS_TYPE_ZYGOTE:
[email protected]f164cea2009-11-05 23:37:40389 UMA_HISTOGRAM_MEMORY_KB("Memory.Zygote", sample);
[email protected]fcf79352010-12-28 20:13:20390 other_count++;
[email protected]f164cea2009-11-05 23:37:40391 break;
[email protected]bd5d6cf2011-12-01 00:39:12392 case content::PROCESS_TYPE_SANDBOX_HELPER:
[email protected]f164cea2009-11-05 23:37:40393 UMA_HISTOGRAM_MEMORY_KB("Memory.SandboxHelper", sample);
[email protected]fcf79352010-12-28 20:13:20394 other_count++;
[email protected]f164cea2009-11-05 23:37:40395 break;
[email protected]bd5d6cf2011-12-01 00:39:12396 case content::PROCESS_TYPE_NACL_LOADER:
[email protected]f164cea2009-11-05 23:37:40397 UMA_HISTOGRAM_MEMORY_KB("Memory.NativeClient", sample);
[email protected]fcf79352010-12-28 20:13:20398 other_count++;
[email protected]f164cea2009-11-05 23:37:40399 break;
[email protected]bd5d6cf2011-12-01 00:39:12400 case content::PROCESS_TYPE_NACL_BROKER:
[email protected]aef8d5ae2010-03-17 22:40:52401 UMA_HISTOGRAM_MEMORY_KB("Memory.NativeClientBroker", sample);
[email protected]fcf79352010-12-28 20:13:20402 other_count++;
[email protected]aef8d5ae2010-03-17 22:40:52403 break;
[email protected]bd5d6cf2011-12-01 00:39:12404 case content::PROCESS_TYPE_GPU:
[email protected]96fcbf2d2010-08-03 16:10:27405 UMA_HISTOGRAM_MEMORY_KB("Memory.Gpu", sample);
[email protected]fcf79352010-12-28 20:13:20406 other_count++;
[email protected]96fcbf2d2010-08-03 16:10:27407 break;
[email protected]bd5d6cf2011-12-01 00:39:12408 case content::PROCESS_TYPE_PPAPI_PLUGIN:
[email protected]eef348fb2011-08-01 21:11:08409 UMA_HISTOGRAM_MEMORY_KB("Memory.PepperPlugin", sample);
410 pepper_plugin_count++;
411 break;
[email protected]f164cea2009-11-05 23:37:40412 default:
413 NOTREACHED();
[email protected]eef348fb2011-08-01 21:11:08414 break;
initial.commit09911bf2008-07-26 23:55:29415 }
416 }
[email protected]57c4b852009-08-17 21:59:29417 UMA_HISTOGRAM_MEMORY_KB("Memory.BackingStore",
418 BackingStoreManager::MemorySize() / 1024);
[email protected]a27a9382009-02-11 23:55:10419
[email protected]553dba62009-02-24 19:08:23420 UMA_HISTOGRAM_COUNTS_100("Memory.ProcessCount",
initial.commit09911bf2008-07-26 23:55:29421 static_cast<int>(browser.processes.size()));
[email protected]fcf79352010-12-28 20:13:20422 UMA_HISTOGRAM_COUNTS_100("Memory.ChromeProcessCount", chrome_count);
423 UMA_HISTOGRAM_COUNTS_100("Memory.ExtensionProcessCount", extension_count);
424 UMA_HISTOGRAM_COUNTS_100("Memory.OtherProcessCount", other_count);
[email protected]553dba62009-02-24 19:08:23425 UMA_HISTOGRAM_COUNTS_100("Memory.PluginProcessCount", plugin_count);
[email protected]eef348fb2011-08-01 21:11:08426 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount",
427 pepper_plugin_count);
[email protected]fcf79352010-12-28 20:13:20428 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count);
[email protected]553dba62009-02-24 19:08:23429 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count);
[email protected]f164cea2009-11-05 23:37:40430 // TODO(viettrungluu): Do we want separate counts for the other
431 // (platform-specific) process types?
[email protected]921cd0cc2008-10-21 22:30:55432
433 int total_sample = static_cast<int>(aggregate_memory / 1000);
[email protected]553dba62009-02-24 19:08:23434 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample);
initial.commit09911bf2008-07-26 23:55:29435}