[email protected] | b0b67cf | 2012-01-18 21:59:57 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
| 5 | #include "chrome/browser/memory_details.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 6 | |
[email protected] | 24d6969 | 2011-10-21 18:26:51 | [diff] [blame] | 7 | #include "base/bind.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 8 | #include "base/file_version_info.h" |
[email protected] | 835d7c8 | 2010-10-14 04:38:38 | [diff] [blame] | 9 | #include "base/metrics/histogram.h" |
[email protected] | 76543b9 | 2009-08-31 17:27:45 | [diff] [blame] | 10 | #include "base/process_util.h" |
[email protected] | f9b29436 | 2013-06-10 20:22:31 | [diff] [blame] | 11 | #include "base/strings/string_util.h" |
| 12 | #include "base/strings/stringprintf.h" |
[email protected] | 112158af | 2013-06-07 23:46:18 | [diff] [blame] | 13 | #include "base/strings/utf_string_conversions.h" |
[email protected] | 8add541 | 2011-10-01 21:02:14 | [diff] [blame] | 14 | #include "chrome/browser/extensions/extension_process_manager.h" |
[email protected] | 79dc42cd | 2011-01-08 21:43:35 | [diff] [blame] | 15 | #include "chrome/browser/extensions/extension_service.h" |
| 16 | #include "chrome/browser/profiles/profile.h" |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 17 | #include "chrome/common/extensions/extension.h" |
[email protected] | cd3d789 | 2009-03-04 23:55:06 | [diff] [blame] | 18 | #include "chrome/common/url_constants.h" |
[email protected] | d5d38325 | 2013-07-04 14:44:32 | [diff] [blame] | 19 | #include "components/nacl/common/nacl_process_type.h" |
[email protected] | 4967f79 | 2012-01-20 22:14:40 | [diff] [blame] | 20 | #include "content/public/browser/browser_child_process_host_iterator.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 21 | #include "content/public/browser/browser_thread.h" |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame] | 22 | #include "content/public/browser/child_process_data.h" |
[email protected] | a53209b | 2012-01-20 16:48:16 | [diff] [blame] | 23 | #include "content/public/browser/navigation_controller.h" |
[email protected] | 022af74 | 2011-12-28 18:37:25 | [diff] [blame] | 24 | #include "content/public/browser/navigation_entry.h" |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 25 | #include "content/public/browser/render_process_host.h" |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame] | 26 | #include "content/public/browser/render_view_host.h" |
[email protected] | 83ff91c | 2012-01-05 20:54:13 | [diff] [blame] | 27 | #include "content/public/browser/web_contents.h" |
[email protected] | e091df8 | 2011-10-11 18:13:21 | [diff] [blame] | 28 | #include "content/public/common/bindings_policy.h" |
[email protected] | cb2edf2 | 2013-04-01 20:25:23 | [diff] [blame] | 29 | #include "extensions/browser/view_type_utils.h" |
[email protected] | ae5ca89 | 2009-07-30 18:00:47 | [diff] [blame] | 30 | #include "grit/chromium_strings.h" |
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 31 | #include "grit/generated_resources.h" |
[email protected] | c051a1b | 2011-01-21 23:30:17 | [diff] [blame] | 32 | #include "ui/base/l10n/l10n_util.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 33 | |
[email protected] | a423c9e | 2012-03-06 18:02:31 | [diff] [blame] | 34 | #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
[email protected] | c2c68b1f | 2012-02-25 00:29:15 | [diff] [blame] | 35 | #include "content/public/browser/zygote_host_linux.h" |
[email protected] | 54fd1d3 | 2009-09-01 00:12:58 | [diff] [blame] | 36 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 37 | |
[email protected] | 4306df7 | 2012-04-20 18:58:57 | [diff] [blame] | 38 | using base::StringPrintf; |
[email protected] | 4967f79 | 2012-01-20 22:14:40 | [diff] [blame] | 39 | using content::BrowserChildProcessHostIterator; |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 40 | using content::BrowserThread; |
[email protected] | 10f417c5 | 2011-12-28 21:04:23 | [diff] [blame] | 41 | using content::NavigationEntry; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 42 | using content::RenderViewHost; |
| 43 | using content::RenderWidgetHost; |
[email protected] | 83ff91c | 2012-01-05 20:54:13 | [diff] [blame] | 44 | using content::WebContents; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 45 | using extensions::Extension; |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 46 | |
[email protected] | 2c1978a | 2011-11-29 17:02:39 | [diff] [blame] | 47 | // static |
| 48 | std::string ProcessMemoryInformation::GetRendererTypeNameInEnglish( |
| 49 | RendererProcessType type) { |
| 50 | switch (type) { |
| 51 | case RENDERER_NORMAL: |
| 52 | return "Tab"; |
| 53 | case RENDERER_CHROME: |
| 54 | return "Tab (Chrome)"; |
| 55 | case RENDERER_EXTENSION: |
| 56 | return "Extension"; |
| 57 | case RENDERER_DEVTOOLS: |
| 58 | return "Devtools"; |
| 59 | case RENDERER_INTERSTITIAL: |
| 60 | return "Interstitial"; |
| 61 | case RENDERER_NOTIFICATION: |
| 62 | return "Notification"; |
| 63 | case RENDERER_BACKGROUND_APP: |
| 64 | return "Background App"; |
| 65 | case RENDERER_UNKNOWN: |
| 66 | default: |
| 67 | NOTREACHED() << "Unknown renderer process type!"; |
| 68 | return "Unknown"; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | // static |
| 73 | std::string ProcessMemoryInformation::GetFullTypeNameInEnglish( |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 74 | int process_type, |
[email protected] | 2c1978a | 2011-11-29 17:02:39 | [diff] [blame] | 75 | RendererProcessType rtype) { |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 76 | if (process_type == content::PROCESS_TYPE_RENDERER) |
[email protected] | 2c1978a | 2011-11-29 17:02:39 | [diff] [blame] | 77 | return GetRendererTypeNameInEnglish(rtype); |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 78 | return content::GetProcessTypeNameInEnglish(process_type); |
[email protected] | 2c1978a | 2011-11-29 17:02:39 | [diff] [blame] | 79 | } |
| 80 | |
[email protected] | 8e38341 | 2010-10-19 16:57:03 | [diff] [blame] | 81 | ProcessMemoryInformation::ProcessMemoryInformation() |
| 82 | : pid(0), |
| 83 | num_processes(0), |
| 84 | is_diagnostics(false), |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 85 | process_type(content::PROCESS_TYPE_UNKNOWN), |
[email protected] | 2c1978a | 2011-11-29 17:02:39 | [diff] [blame] | 86 | renderer_type(RENDERER_UNKNOWN) { |
[email protected] | 8e38341 | 2010-10-19 16:57:03 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | ProcessMemoryInformation::~ProcessMemoryInformation() {} |
| 90 | |
[email protected] | 8e23c88 | 2012-05-05 01:14:11 | [diff] [blame] | 91 | bool ProcessMemoryInformation::operator<( |
| 92 | const ProcessMemoryInformation& rhs) const { |
| 93 | return working_set.priv < rhs.working_set.priv; |
| 94 | } |
| 95 | |
[email protected] | 93aa89c7 | 2010-10-20 21:32:04 | [diff] [blame] | 96 | ProcessData::ProcessData() {} |
| 97 | |
| 98 | ProcessData::ProcessData(const ProcessData& rhs) |
| 99 | : name(rhs.name), |
| 100 | process_name(rhs.process_name), |
| 101 | processes(rhs.processes) { |
| 102 | } |
| 103 | |
| 104 | ProcessData::~ProcessData() {} |
| 105 | |
| 106 | ProcessData& ProcessData::operator=(const ProcessData& rhs) { |
| 107 | name = rhs.name; |
| 108 | process_name = rhs.process_name; |
| 109 | processes = rhs.processes; |
| 110 | return *this; |
| 111 | } |
| 112 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 113 | // About threading: |
| 114 | // |
| 115 | // This operation will hit no fewer than 3 threads. |
| 116 | // |
[email protected] | 8be4584 | 2012-04-13 19:49:29 | [diff] [blame] | 117 | // The BrowserChildProcessHostIterator can only be accessed from the IO thread. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 118 | // |
| 119 | // The RenderProcessHostIterator can only be accessed from the UI thread. |
| 120 | // |
| 121 | // This operation can take 30-100ms to complete. We never want to have |
| 122 | // one task run for that long on the UI or IO threads. So, we run the |
| 123 | // expensive parts of this operation over on the file thread. |
| 124 | // |
[email protected] | 4306df7 | 2012-04-20 18:58:57 | [diff] [blame] | 125 | void MemoryDetails::StartFetch(UserMetricsMode user_metrics_mode) { |
[email protected] | 9bb480ee | 2011-08-03 21:41:16 | [diff] [blame] | 126 | // This might get called from the UI or FILE threads, but should not be |
| 127 | // getting called from the IO thread. |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 128 | DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | 4306df7 | 2012-04-20 18:58:57 | [diff] [blame] | 129 | user_metrics_mode_ = user_metrics_mode; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 130 | |
| 131 | // In order to process this request, we need to use the plugin information. |
| 132 | // However, plugin process information is only available from the IO thread. |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 133 | BrowserThread::PostTask( |
| 134 | BrowserThread::IO, FROM_HERE, |
[email protected] | 24d6969 | 2011-10-21 18:26:51 | [diff] [blame] | 135 | base::Bind(&MemoryDetails::CollectChildInfoOnIOThread, this)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 136 | } |
| 137 | |
[email protected] | 8e38341 | 2010-10-19 16:57:03 | [diff] [blame] | 138 | MemoryDetails::~MemoryDetails() {} |
| 139 | |
[email protected] | 4306df7 | 2012-04-20 18:58:57 | [diff] [blame] | 140 | std::string MemoryDetails::ToLogString() { |
| 141 | std::string log; |
| 142 | log.reserve(4096); |
[email protected] | 8e23c88 | 2012-05-05 01:14:11 | [diff] [blame] | 143 | ProcessMemoryInformationList processes = ChromeBrowser()->processes; |
| 144 | // Sort by memory consumption, low to high. |
| 145 | std::sort(processes.begin(), processes.end()); |
| 146 | // Print from high to low. |
| 147 | for (ProcessMemoryInformationList::reverse_iterator iter1 = |
| 148 | processes.rbegin(); |
| 149 | iter1 != processes.rend(); |
| 150 | ++iter1) { |
[email protected] | 4306df7 | 2012-04-20 18:58:57 | [diff] [blame] | 151 | log += ProcessMemoryInformation::GetFullTypeNameInEnglish( |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 152 | iter1->process_type, iter1->renderer_type); |
[email protected] | 4306df7 | 2012-04-20 18:58:57 | [diff] [blame] | 153 | if (!iter1->titles.empty()) { |
| 154 | log += " ["; |
| 155 | for (std::vector<string16>::const_iterator iter2 = |
| 156 | iter1->titles.begin(); |
| 157 | iter2 != iter1->titles.end(); ++iter2) { |
| 158 | if (iter2 != iter1->titles.begin()) |
| 159 | log += "|"; |
| 160 | log += UTF16ToUTF8(*iter2); |
| 161 | } |
| 162 | log += "]"; |
| 163 | } |
| 164 | log += StringPrintf(" %d MB private, %d MB shared\n", |
| 165 | static_cast<int>(iter1->working_set.priv) / 1024, |
| 166 | static_cast<int>(iter1->working_set.shared) / 1024); |
| 167 | } |
| 168 | return log; |
| 169 | } |
| 170 | |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 171 | void MemoryDetails::CollectChildInfoOnIOThread() { |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 172 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 173 | |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 174 | std::vector<ProcessMemoryInformation> child_info; |
| 175 | |
[email protected] | 82a14c1 | 2012-11-13 18:40:55 | [diff] [blame] | 176 | // Collect the list of child processes. A 0 |handle| means that |
| 177 | // the process is being launched, so we skip it. |
[email protected] | 4967f79 | 2012-01-20 22:14:40 | [diff] [blame] | 178 | for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 179 | ProcessMemoryInformation info; |
[email protected] | 82a14c1 | 2012-11-13 18:40:55 | [diff] [blame] | 180 | if (!iter.GetData().handle) |
| 181 | continue; |
[email protected] | 4967f79 | 2012-01-20 22:14:40 | [diff] [blame] | 182 | info.pid = base::GetProcId(iter.GetData().handle); |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 183 | if (!info.pid) |
| 184 | continue; |
| 185 | |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 186 | info.process_type = iter.GetData().process_type; |
[email protected] | 2c1978a | 2011-11-29 17:02:39 | [diff] [blame] | 187 | info.renderer_type = ProcessMemoryInformation::RENDERER_UNKNOWN; |
[email protected] | 4967f79 | 2012-01-20 22:14:40 | [diff] [blame] | 188 | info.titles.push_back(iter.GetData().name); |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 189 | child_info.push_back(info); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | // Now go do expensive memory lookups from the file thread. |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 193 | BrowserThread::PostTask( |
| 194 | BrowserThread::FILE, FROM_HERE, |
[email protected] | 24d6969 | 2011-10-21 18:26:51 | [diff] [blame] | 195 | base::Bind(&MemoryDetails::CollectProcessData, this, child_info)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 196 | } |
| 197 | |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 198 | void MemoryDetails::CollectChildInfoOnUIThread() { |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 199 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 200 | |
[email protected] | a423c9e | 2012-03-06 18:02:31 | [diff] [blame] | 201 | #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
[email protected] | c2c68b1f | 2012-02-25 00:29:15 | [diff] [blame] | 202 | const pid_t zygote_pid = content::ZygoteHost::GetInstance()->GetPid(); |
[email protected] | 52356d2 | 2012-02-29 18:34:20 | [diff] [blame] | 203 | const pid_t sandbox_helper_pid = |
| 204 | content::ZygoteHost::GetInstance()->GetSandboxHelperPid(); |
[email protected] | 54fd1d3 | 2009-09-01 00:12:58 | [diff] [blame] | 205 | #endif |
| 206 | |
| 207 | ProcessData* const chrome_browser = ChromeBrowser(); |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 208 | // Get more information about the process. |
[email protected] | 54fd1d3 | 2009-09-01 00:12:58 | [diff] [blame] | 209 | for (size_t index = 0; index < chrome_browser->processes.size(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 210 | index++) { |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 211 | // Check if it's a renderer, if so get the list of page titles in it and |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 212 | // check if it's a diagnostics-related process. We skip about:memory pages. |
| 213 | // Iterate the RenderProcessHosts to find the tab contents. |
[email protected] | 54fd1d3 | 2009-09-01 00:12:58 | [diff] [blame] | 214 | ProcessMemoryInformation& process = |
| 215 | chrome_browser->processes[index]; |
| 216 | |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 217 | RenderWidgetHost::List widgets = RenderWidgetHost::GetRenderWidgetHosts(); |
| 218 | for (size_t i = 0; i < widgets.size(); ++i) { |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 219 | content::RenderProcessHost* render_process_host = |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 220 | widgets[i]->GetProcess(); |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 221 | DCHECK(render_process_host); |
[email protected] | 8a34e660 | 2010-10-02 17:29:43 | [diff] [blame] | 222 | // Ignore processes that don't have a connection, such as crashed tabs. |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 223 | if (!render_process_host->HasConnection() || |
| 224 | process.pid != base::GetProcId(render_process_host->GetHandle())) { |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 225 | continue; |
[email protected] | 201b273 | 2009-11-13 18:57:46 | [diff] [blame] | 226 | } |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 227 | process.process_type = content::PROCESS_TYPE_RENDERER; |
[email protected] | 9b62ecf | 2011-07-27 20:23:08 | [diff] [blame] | 228 | Profile* profile = |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 229 | Profile::FromBrowserContext( |
| 230 | render_process_host->GetBrowserContext()); |
[email protected] | 79dc42cd | 2011-01-08 21:43:35 | [diff] [blame] | 231 | ExtensionService* extension_service = profile->GetExtensionService(); |
[email protected] | 267b493 | 2012-10-11 18:04:26 | [diff] [blame] | 232 | extensions::ProcessMap* extension_process_map = NULL; |
| 233 | // No extensions on Android. So extension_service can be NULL. |
| 234 | if (extension_service) |
| 235 | extension_process_map = extension_service->process_map(); |
[email protected] | 79dc42cd | 2011-01-08 21:43:35 | [diff] [blame] | 236 | |
[email protected] | 0932b30c | 2012-04-17 13:25:10 | [diff] [blame] | 237 | // The RenderProcessHost may host multiple WebContentses. Any |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 238 | // of them which contain diagnostics information make the whole |
| 239 | // process be considered a diagnostics process. |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 240 | if (!widgets[i]->IsRenderView()) |
| 241 | continue; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 242 | |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 243 | RenderViewHost* host = RenderViewHost::From(widgets[i]); |
| 244 | WebContents* contents = WebContents::FromRenderViewHost(host); |
| 245 | GURL url; |
| 246 | if (contents) { |
| 247 | url = contents->GetURL(); |
| 248 | SiteData* site_data = |
| 249 | &chrome_browser->site_data[contents->GetBrowserContext()]; |
| 250 | SiteDetails::CollectSiteInfo(contents, site_data); |
| 251 | } |
| 252 | extensions::ViewType type = extensions::GetViewType(contents); |
| 253 | if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) { |
| 254 | process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME; |
| 255 | } else if (extension_process_map && |
| 256 | extension_process_map->Contains(host->GetProcess()->GetID())) { |
| 257 | // For our purposes, don't count processes containing only hosted apps |
| 258 | // as extension processes. See also: crbug.com/102533. |
| 259 | std::set<std::string> extension_ids = |
| 260 | extension_process_map->GetExtensionsInProcess( |
| 261 | host->GetProcess()->GetID()); |
| 262 | for (std::set<std::string>::iterator iter = extension_ids.begin(); |
| 263 | iter != extension_ids.end(); ++iter) { |
[email protected] | 299d7f1 | 2012-05-23 05:31:15 | [diff] [blame] | 264 | const Extension* extension = |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 265 | extension_service->GetExtensionById(*iter, false); |
| 266 | if (extension && !extension->is_hosted_app()) { |
[email protected] | 04d9cc40 | 2012-08-17 22:30:12 | [diff] [blame] | 267 | process.renderer_type = |
| 268 | ProcessMemoryInformation::RENDERER_EXTENSION; |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 269 | break; |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 270 | } |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 271 | } |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 272 | } |
| 273 | if (extension_process_map && |
| 274 | extension_process_map->Contains(host->GetProcess()->GetID())) { |
| 275 | const Extension* extension = |
| 276 | extension_service->extensions()->GetByID(url.host()); |
| 277 | if (extension) { |
| 278 | string16 title = UTF8ToUTF16(extension->name()); |
| 279 | process.titles.push_back(title); |
[email protected] | 299d7f1 | 2012-05-23 05:31:15 | [diff] [blame] | 280 | process.renderer_type = |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 281 | ProcessMemoryInformation::RENDERER_EXTENSION; |
[email protected] | 299d7f1 | 2012-05-23 05:31:15 | [diff] [blame] | 282 | continue; |
| 283 | } |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 284 | } |
[email protected] | 299d7f1 | 2012-05-23 05:31:15 | [diff] [blame] | 285 | |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 286 | if (!contents) { |
| 287 | process.renderer_type = |
| 288 | ProcessMemoryInformation::RENDERER_INTERSTITIAL; |
| 289 | continue; |
| 290 | } |
[email protected] | 299d7f1 | 2012-05-23 05:31:15 | [diff] [blame] | 291 | |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 292 | if (type == extensions::VIEW_TYPE_BACKGROUND_CONTENTS) { |
| 293 | process.titles.push_back(UTF8ToUTF16(url.spec())); |
| 294 | process.renderer_type = |
| 295 | ProcessMemoryInformation::RENDERER_BACKGROUND_APP; |
| 296 | continue; |
| 297 | } |
[email protected] | 299d7f1 | 2012-05-23 05:31:15 | [diff] [blame] | 298 | |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 299 | if (type == extensions::VIEW_TYPE_NOTIFICATION) { |
| 300 | process.titles.push_back(UTF8ToUTF16(url.spec())); |
| 301 | process.renderer_type = |
| 302 | ProcessMemoryInformation::RENDERER_NOTIFICATION; |
| 303 | continue; |
| 304 | } |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 305 | |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 306 | // Since we have a WebContents and and the renderer type hasn't been |
| 307 | // set yet, it must be a normal tabbed renderer. |
| 308 | if (process.renderer_type == ProcessMemoryInformation::RENDERER_UNKNOWN) |
| 309 | process.renderer_type = ProcessMemoryInformation::RENDERER_NORMAL; |
[email protected] | cd3d789 | 2009-03-04 23:55:06 | [diff] [blame] | 310 | |
[email protected] | 039b84a4 | 2013-06-21 20:23:37 | [diff] [blame] | 311 | string16 title = contents->GetTitle(); |
| 312 | if (!title.length()) |
| 313 | title = l10n_util::GetStringUTF16(IDS_DEFAULT_TAB_TITLE); |
| 314 | process.titles.push_back(title); |
| 315 | |
| 316 | // We need to check the pending entry as well as the virtual_url to |
| 317 | // see if it's a chrome://memory URL (we don't want to count these in |
| 318 | // the total memory usage of the browser). |
| 319 | // |
| 320 | // When we reach here, chrome://memory will be the pending entry since |
| 321 | // we haven't responded with any data such that it would be committed. |
| 322 | // If you have another chrome://memory tab open (which would be |
| 323 | // committed), we don't want to count it either, so we also check the |
| 324 | // last committed entry. |
| 325 | // |
| 326 | // Either the pending or last committed entries can be NULL. |
| 327 | const NavigationEntry* pending_entry = |
| 328 | contents->GetController().GetPendingEntry(); |
| 329 | const NavigationEntry* last_committed_entry = |
| 330 | contents->GetController().GetLastCommittedEntry(); |
| 331 | if ((last_committed_entry && |
| 332 | LowerCaseEqualsASCII(last_committed_entry->GetVirtualURL().spec(), |
| 333 | chrome::kChromeUIMemoryURL)) || |
| 334 | (pending_entry && |
| 335 | LowerCaseEqualsASCII(pending_entry->GetVirtualURL().spec(), |
| 336 | chrome::kChromeUIMemoryURL))) { |
| 337 | process.is_diagnostics = true; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 338 | } |
| 339 | } |
[email protected] | 54fd1d3 | 2009-09-01 00:12:58 | [diff] [blame] | 340 | |
[email protected] | a423c9e | 2012-03-06 18:02:31 | [diff] [blame] | 341 | #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
[email protected] | 54fd1d3 | 2009-09-01 00:12:58 | [diff] [blame] | 342 | if (process.pid == zygote_pid) { |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 343 | process.process_type = content::PROCESS_TYPE_ZYGOTE; |
[email protected] | 54fd1d3 | 2009-09-01 00:12:58 | [diff] [blame] | 344 | } else if (process.pid == sandbox_helper_pid) { |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 345 | process.process_type = content::PROCESS_TYPE_SANDBOX_HELPER; |
[email protected] | 54fd1d3 | 2009-09-01 00:12:58 | [diff] [blame] | 346 | } |
| 347 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 348 | } |
| 349 | |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 350 | // Get rid of other Chrome processes that are from a different profile. |
[email protected] | 54fd1d3 | 2009-09-01 00:12:58 | [diff] [blame] | 351 | for (size_t index = 0; index < chrome_browser->processes.size(); |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 352 | index++) { |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 353 | if (chrome_browser->processes[index].process_type == |
[email protected] | bd5d6cf | 2011-12-01 00:39:12 | [diff] [blame] | 354 | content::PROCESS_TYPE_UNKNOWN) { |
[email protected] | 54fd1d3 | 2009-09-01 00:12:58 | [diff] [blame] | 355 | chrome_browser->processes.erase( |
| 356 | chrome_browser->processes.begin() + index); |
[email protected] | a436d92 | 2009-02-13 23:16:42 | [diff] [blame] | 357 | index--; |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 358 | } |
| 359 | } |
| 360 | |
[email protected] | 4306df7 | 2012-04-20 18:58:57 | [diff] [blame] | 361 | if (user_metrics_mode_ == UPDATE_USER_METRICS) |
| 362 | UpdateHistograms(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 363 | |
| 364 | OnDetailsAvailable(); |
| 365 | } |
| 366 | |
| 367 | void MemoryDetails::UpdateHistograms() { |
| 368 | // Reports a set of memory metrics to UMA. |
[email protected] | 57c4b85 | 2009-08-17 21:59:29 | [diff] [blame] | 369 | // Memory is measured in KB. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 370 | |
[email protected] | 54fd1d3 | 2009-09-01 00:12:58 | [diff] [blame] | 371 | const ProcessData& browser = *ChromeBrowser(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 372 | size_t aggregate_memory = 0; |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 373 | int chrome_count = 0; |
| 374 | int extension_count = 0; |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 375 | int plugin_count = 0; |
[email protected] | eef348fb | 2011-08-01 21:11:08 | [diff] [blame] | 376 | int pepper_plugin_count = 0; |
[email protected] | 3f5f516 | 2012-10-17 09:19:40 | [diff] [blame] | 377 | int pepper_plugin_broker_count = 0; |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 378 | int renderer_count = 0; |
| 379 | int other_count = 0; |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 380 | int worker_count = 0; |
[email protected] | 1ae93fb1 | 2013-06-14 03:38:56 | [diff] [blame] | 381 | int process_limit = content::RenderProcessHost::GetMaxRendererProcessCount(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 382 | for (size_t index = 0; index < browser.processes.size(); index++) { |
[email protected] | 921cd0cc | 2008-10-21 22:30:55 | [diff] [blame] | 383 | int sample = static_cast<int>(browser.processes[index].working_set.priv); |
| 384 | aggregate_memory += sample; |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 385 | switch (browser.processes[index].process_type) { |
[email protected] | bd5d6cf | 2011-12-01 00:39:12 | [diff] [blame] | 386 | case content::PROCESS_TYPE_BROWSER: |
[email protected] | f164cea | 2009-11-05 23:37:40 | [diff] [blame] | 387 | UMA_HISTOGRAM_MEMORY_KB("Memory.Browser", sample); |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 388 | continue; |
[email protected] | bd5d6cf | 2011-12-01 00:39:12 | [diff] [blame] | 389 | case content::PROCESS_TYPE_RENDERER: { |
[email protected] | 2c1978a | 2011-11-29 17:02:39 | [diff] [blame] | 390 | ProcessMemoryInformation::RendererProcessType renderer_type = |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 391 | browser.processes[index].renderer_type; |
| 392 | switch (renderer_type) { |
[email protected] | 2c1978a | 2011-11-29 17:02:39 | [diff] [blame] | 393 | case ProcessMemoryInformation::RENDERER_EXTENSION: |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 394 | UMA_HISTOGRAM_MEMORY_KB("Memory.Extension", sample); |
| 395 | extension_count++; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 396 | continue; |
[email protected] | 2c1978a | 2011-11-29 17:02:39 | [diff] [blame] | 397 | case ProcessMemoryInformation::RENDERER_CHROME: |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 398 | UMA_HISTOGRAM_MEMORY_KB("Memory.Chrome", sample); |
| 399 | chrome_count++; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 400 | continue; |
[email protected] | 2c1978a | 2011-11-29 17:02:39 | [diff] [blame] | 401 | case ProcessMemoryInformation::RENDERER_UNKNOWN: |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 402 | NOTREACHED() << "Unknown renderer process type."; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 403 | continue; |
[email protected] | 2c1978a | 2011-11-29 17:02:39 | [diff] [blame] | 404 | case ProcessMemoryInformation::RENDERER_NORMAL: |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 405 | default: |
| 406 | // TODO(erikkay): Should we bother splitting out the other subtypes? |
| 407 | UMA_HISTOGRAM_MEMORY_KB("Memory.Renderer", sample); |
| 408 | renderer_count++; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 409 | continue; |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 410 | } |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 411 | } |
[email protected] | bd5d6cf | 2011-12-01 00:39:12 | [diff] [blame] | 412 | case content::PROCESS_TYPE_PLUGIN: |
[email protected] | f164cea | 2009-11-05 23:37:40 | [diff] [blame] | 413 | UMA_HISTOGRAM_MEMORY_KB("Memory.Plugin", sample); |
| 414 | plugin_count++; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 415 | continue; |
[email protected] | bd5d6cf | 2011-12-01 00:39:12 | [diff] [blame] | 416 | case content::PROCESS_TYPE_WORKER: |
[email protected] | f164cea | 2009-11-05 23:37:40 | [diff] [blame] | 417 | UMA_HISTOGRAM_MEMORY_KB("Memory.Worker", sample); |
| 418 | worker_count++; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 419 | continue; |
[email protected] | bd5d6cf | 2011-12-01 00:39:12 | [diff] [blame] | 420 | case content::PROCESS_TYPE_UTILITY: |
[email protected] | f164cea | 2009-11-05 23:37:40 | [diff] [blame] | 421 | UMA_HISTOGRAM_MEMORY_KB("Memory.Utility", sample); |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 422 | other_count++; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 423 | continue; |
[email protected] | bd5d6cf | 2011-12-01 00:39:12 | [diff] [blame] | 424 | case content::PROCESS_TYPE_ZYGOTE: |
[email protected] | f164cea | 2009-11-05 23:37:40 | [diff] [blame] | 425 | UMA_HISTOGRAM_MEMORY_KB("Memory.Zygote", sample); |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 426 | other_count++; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 427 | continue; |
[email protected] | bd5d6cf | 2011-12-01 00:39:12 | [diff] [blame] | 428 | case content::PROCESS_TYPE_SANDBOX_HELPER: |
[email protected] | f164cea | 2009-11-05 23:37:40 | [diff] [blame] | 429 | UMA_HISTOGRAM_MEMORY_KB("Memory.SandboxHelper", sample); |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 430 | other_count++; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 431 | continue; |
[email protected] | bd5d6cf | 2011-12-01 00:39:12 | [diff] [blame] | 432 | case content::PROCESS_TYPE_GPU: |
[email protected] | 96fcbf2d | 2010-08-03 16:10:27 | [diff] [blame] | 433 | UMA_HISTOGRAM_MEMORY_KB("Memory.Gpu", sample); |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 434 | other_count++; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 435 | continue; |
[email protected] | bd5d6cf | 2011-12-01 00:39:12 | [diff] [blame] | 436 | case content::PROCESS_TYPE_PPAPI_PLUGIN: |
[email protected] | eef348fb | 2011-08-01 21:11:08 | [diff] [blame] | 437 | UMA_HISTOGRAM_MEMORY_KB("Memory.PepperPlugin", sample); |
| 438 | pepper_plugin_count++; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 439 | continue; |
[email protected] | 3f5f516 | 2012-10-17 09:19:40 | [diff] [blame] | 440 | case content::PROCESS_TYPE_PPAPI_BROKER: |
| 441 | UMA_HISTOGRAM_MEMORY_KB("Memory.PepperPluginBroker", sample); |
| 442 | pepper_plugin_broker_count++; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 443 | continue; |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 444 | case PROCESS_TYPE_NACL_LOADER: |
| 445 | UMA_HISTOGRAM_MEMORY_KB("Memory.NativeClient", sample); |
| 446 | other_count++; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 447 | continue; |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 448 | case PROCESS_TYPE_NACL_BROKER: |
| 449 | UMA_HISTOGRAM_MEMORY_KB("Memory.NativeClientBroker", sample); |
| 450 | other_count++; |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 451 | continue; |
[email protected] | f164cea | 2009-11-05 23:37:40 | [diff] [blame] | 452 | default: |
| 453 | NOTREACHED(); |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 454 | continue; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 455 | } |
| 456 | } |
[email protected] | 57c4b85 | 2009-08-17 21:59:29 | [diff] [blame] | 457 | UMA_HISTOGRAM_MEMORY_KB("Memory.BackingStore", |
[email protected] | 0b07be45 | 2012-02-29 01:14:42 | [diff] [blame] | 458 | RenderWidgetHost::BackingStoreMemorySize() / 1024); |
[email protected] | dc0b5bd | 2012-12-11 21:24:39 | [diff] [blame] | 459 | #if defined(OS_CHROMEOS) |
| 460 | // Chrome OS exposes system-wide graphics driver memory which has historically |
| 461 | // been a source of leak/bloat. |
| 462 | base::SystemMemoryInfoKB meminfo; |
| 463 | if (base::GetSystemMemoryInfo(&meminfo) && meminfo.gem_size != -1) |
| 464 | UMA_HISTOGRAM_MEMORY_MB("Memory.Graphics", meminfo.gem_size / 1024 / 1024); |
| 465 | #endif |
[email protected] | a27a938 | 2009-02-11 23:55:10 | [diff] [blame] | 466 | |
[email protected] | 1ae93fb1 | 2013-06-14 03:38:56 | [diff] [blame] | 467 | UMA_HISTOGRAM_COUNTS_100("Memory.ProcessLimit", process_limit); |
[email protected] | 553dba6 | 2009-02-24 19:08:23 | [diff] [blame] | 468 | UMA_HISTOGRAM_COUNTS_100("Memory.ProcessCount", |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 469 | static_cast<int>(browser.processes.size())); |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 470 | UMA_HISTOGRAM_COUNTS_100("Memory.ChromeProcessCount", chrome_count); |
| 471 | UMA_HISTOGRAM_COUNTS_100("Memory.ExtensionProcessCount", extension_count); |
| 472 | UMA_HISTOGRAM_COUNTS_100("Memory.OtherProcessCount", other_count); |
[email protected] | 553dba6 | 2009-02-24 19:08:23 | [diff] [blame] | 473 | UMA_HISTOGRAM_COUNTS_100("Memory.PluginProcessCount", plugin_count); |
[email protected] | eef348fb | 2011-08-01 21:11:08 | [diff] [blame] | 474 | UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount", |
| 475 | pepper_plugin_count); |
[email protected] | 3f5f516 | 2012-10-17 09:19:40 | [diff] [blame] | 476 | UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginBrokerProcessCount", |
| 477 | pepper_plugin_broker_count); |
[email protected] | fcf7935 | 2010-12-28 20:13:20 | [diff] [blame] | 478 | UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); |
[email protected] | 553dba6 | 2009-02-24 19:08:23 | [diff] [blame] | 479 | UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); |
[email protected] | f164cea | 2009-11-05 23:37:40 | [diff] [blame] | 480 | // TODO(viettrungluu): Do we want separate counts for the other |
| 481 | // (platform-specific) process types? |
[email protected] | 921cd0cc | 2008-10-21 22:30:55 | [diff] [blame] | 482 | |
| 483 | int total_sample = static_cast<int>(aggregate_memory / 1000); |
[email protected] | 553dba6 | 2009-02-24 19:08:23 | [diff] [blame] | 484 | UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); |
[email protected] | 1ae93fb1 | 2013-06-14 03:38:56 | [diff] [blame] | 485 | |
| 486 | // Predict the number of processes needed when isolating all sites and when |
| 487 | // isolating only HTTPS sites. |
| 488 | int all_renderer_count = renderer_count + chrome_count + extension_count; |
| 489 | int non_renderer_count = browser.processes.size() - all_renderer_count; |
| 490 | SiteDetails::UpdateHistograms(browser.site_data, all_renderer_count, |
| 491 | non_renderer_count); |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 492 | #if defined(OS_CHROMEOS) |
| 493 | UpdateSwapHistograms(); |
| 494 | #endif |
| 495 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 496 | } |
[email protected] | 23deabb7 | 2013-07-16 21:55:20 | [diff] [blame^] | 497 | |
| 498 | #if defined(OS_CHROMEOS) |
| 499 | void MemoryDetails::UpdateSwapHistograms() { |
| 500 | const ProcessData& browser = *ChromeBrowser(); |
| 501 | size_t aggregate_memory = 0; |
| 502 | for (size_t index = 0; index < browser.processes.size(); index++) { |
| 503 | int sample = static_cast<int>(browser.processes[index].working_set.swapped); |
| 504 | aggregate_memory += sample; |
| 505 | switch (browser.processes[index].process_type) { |
| 506 | case content::PROCESS_TYPE_BROWSER: |
| 507 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.Browser", sample); |
| 508 | continue; |
| 509 | case content::PROCESS_TYPE_RENDERER: { |
| 510 | ProcessMemoryInformation::RendererProcessType renderer_type = |
| 511 | browser.processes[index].renderer_type; |
| 512 | switch (renderer_type) { |
| 513 | case ProcessMemoryInformation::RENDERER_EXTENSION: |
| 514 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.Extension", sample); |
| 515 | continue; |
| 516 | case ProcessMemoryInformation::RENDERER_CHROME: |
| 517 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.Chrome", sample); |
| 518 | continue; |
| 519 | case ProcessMemoryInformation::RENDERER_UNKNOWN: |
| 520 | NOTREACHED() << "Unknown renderer process type."; |
| 521 | continue; |
| 522 | case ProcessMemoryInformation::RENDERER_NORMAL: |
| 523 | default: |
| 524 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.Renderer", sample); |
| 525 | continue; |
| 526 | } |
| 527 | } |
| 528 | case content::PROCESS_TYPE_PLUGIN: |
| 529 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.Plugin", sample); |
| 530 | continue; |
| 531 | case content::PROCESS_TYPE_WORKER: |
| 532 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.Worker", sample); |
| 533 | continue; |
| 534 | case content::PROCESS_TYPE_UTILITY: |
| 535 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.Utility", sample); |
| 536 | continue; |
| 537 | case content::PROCESS_TYPE_ZYGOTE: |
| 538 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.Zygote", sample); |
| 539 | continue; |
| 540 | case content::PROCESS_TYPE_SANDBOX_HELPER: |
| 541 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.SandboxHelper", sample); |
| 542 | continue; |
| 543 | case content::PROCESS_TYPE_GPU: |
| 544 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.Gpu", sample); |
| 545 | continue; |
| 546 | case content::PROCESS_TYPE_PPAPI_PLUGIN: |
| 547 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.PepperPlugin", sample); |
| 548 | continue; |
| 549 | case content::PROCESS_TYPE_PPAPI_BROKER: |
| 550 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.PepperPluginBroker", sample); |
| 551 | continue; |
| 552 | case PROCESS_TYPE_NACL_LOADER: |
| 553 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.NativeClient", sample); |
| 554 | continue; |
| 555 | case PROCESS_TYPE_NACL_BROKER: |
| 556 | UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.NativeClientBroker", sample); |
| 557 | continue; |
| 558 | default: |
| 559 | NOTREACHED(); |
| 560 | continue; |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | int total_sample = static_cast<int>(aggregate_memory / 1000); |
| 565 | UMA_HISTOGRAM_MEMORY_MB("Memory.Swap.Total", total_sample); |
| 566 | } |
| 567 | |
| 568 | #endif |