OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/memory_details.h" | 5 #include "chrome/browser/memory_details.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 for (; !iter.IsAtEnd(); iter.Advance()) { | 243 for (; !iter.IsAtEnd(); iter.Advance()) { |
244 const RenderWidgetHost* widget = iter.GetCurrentValue(); | 244 const RenderWidgetHost* widget = iter.GetCurrentValue(); |
245 DCHECK(widget); | 245 DCHECK(widget); |
246 if (!widget || !widget->IsRenderView()) | 246 if (!widget || !widget->IsRenderView()) |
247 continue; | 247 continue; |
248 | 248 |
249 RenderViewHost* host = | 249 RenderViewHost* host = |
250 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); | 250 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); |
251 WebContents* contents = WebContents::FromRenderViewHost(host); | 251 WebContents* contents = WebContents::FromRenderViewHost(host); |
252 GURL url; | 252 GURL url; |
253 if (contents) | 253 if (contents) { |
254 url = contents->GetURL(); | 254 url = contents->GetURL(); |
| 255 SiteData* site_data = |
| 256 &chrome_browser->site_data[contents->GetBrowserContext()]; |
| 257 SiteDetails::CollectSiteInfo(contents, site_data); |
| 258 } |
255 extensions::ViewType type = extensions::GetViewType(contents); | 259 extensions::ViewType type = extensions::GetViewType(contents); |
256 if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) { | 260 if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) { |
257 process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME; | 261 process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME; |
258 } else if (extension_process_map && | 262 } else if (extension_process_map && |
259 extension_process_map->Contains(host->GetProcess()->GetID())) { | 263 extension_process_map->Contains(host->GetProcess()->GetID())) { |
260 // For our purposes, don't count processes containing only hosted apps | 264 // For our purposes, don't count processes containing only hosted apps |
261 // as extension processes. See also: crbug.com/102533. | 265 // as extension processes. See also: crbug.com/102533. |
262 std::set<std::string> extension_ids = | 266 std::set<std::string> extension_ids = |
263 extension_process_map->GetExtensionsInProcess( | 267 extension_process_map->GetExtensionsInProcess( |
264 host->GetProcess()->GetID()); | 268 host->GetProcess()->GetID()); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 const ProcessData& browser = *ChromeBrowser(); | 378 const ProcessData& browser = *ChromeBrowser(); |
375 size_t aggregate_memory = 0; | 379 size_t aggregate_memory = 0; |
376 int chrome_count = 0; | 380 int chrome_count = 0; |
377 int extension_count = 0; | 381 int extension_count = 0; |
378 int plugin_count = 0; | 382 int plugin_count = 0; |
379 int pepper_plugin_count = 0; | 383 int pepper_plugin_count = 0; |
380 int pepper_plugin_broker_count = 0; | 384 int pepper_plugin_broker_count = 0; |
381 int renderer_count = 0; | 385 int renderer_count = 0; |
382 int other_count = 0; | 386 int other_count = 0; |
383 int worker_count = 0; | 387 int worker_count = 0; |
| 388 int process_limit = content::RenderProcessHost::GetMaxRendererProcessCount(); |
384 for (size_t index = 0; index < browser.processes.size(); index++) { | 389 for (size_t index = 0; index < browser.processes.size(); index++) { |
385 int sample = static_cast<int>(browser.processes[index].working_set.priv); | 390 int sample = static_cast<int>(browser.processes[index].working_set.priv); |
386 aggregate_memory += sample; | 391 aggregate_memory += sample; |
387 switch (browser.processes[index].process_type) { | 392 switch (browser.processes[index].process_type) { |
388 case content::PROCESS_TYPE_BROWSER: | 393 case content::PROCESS_TYPE_BROWSER: |
389 UMA_HISTOGRAM_MEMORY_KB("Memory.Browser", sample); | 394 UMA_HISTOGRAM_MEMORY_KB("Memory.Browser", sample); |
390 break; | 395 break; |
391 case content::PROCESS_TYPE_RENDERER: { | 396 case content::PROCESS_TYPE_RENDERER: { |
392 ProcessMemoryInformation::RendererProcessType renderer_type = | 397 ProcessMemoryInformation::RendererProcessType renderer_type = |
393 browser.processes[index].renderer_type; | 398 browser.processes[index].renderer_type; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 UMA_HISTOGRAM_MEMORY_KB("Memory.BackingStore", | 465 UMA_HISTOGRAM_MEMORY_KB("Memory.BackingStore", |
461 RenderWidgetHost::BackingStoreMemorySize() / 1024); | 466 RenderWidgetHost::BackingStoreMemorySize() / 1024); |
462 #if defined(OS_CHROMEOS) | 467 #if defined(OS_CHROMEOS) |
463 // Chrome OS exposes system-wide graphics driver memory which has historically | 468 // Chrome OS exposes system-wide graphics driver memory which has historically |
464 // been a source of leak/bloat. | 469 // been a source of leak/bloat. |
465 base::SystemMemoryInfoKB meminfo; | 470 base::SystemMemoryInfoKB meminfo; |
466 if (base::GetSystemMemoryInfo(&meminfo) && meminfo.gem_size != -1) | 471 if (base::GetSystemMemoryInfo(&meminfo) && meminfo.gem_size != -1) |
467 UMA_HISTOGRAM_MEMORY_MB("Memory.Graphics", meminfo.gem_size / 1024 / 1024); | 472 UMA_HISTOGRAM_MEMORY_MB("Memory.Graphics", meminfo.gem_size / 1024 / 1024); |
468 #endif | 473 #endif |
469 | 474 |
| 475 UMA_HISTOGRAM_COUNTS_100("Memory.ProcessLimit", process_limit); |
470 UMA_HISTOGRAM_COUNTS_100("Memory.ProcessCount", | 476 UMA_HISTOGRAM_COUNTS_100("Memory.ProcessCount", |
471 static_cast<int>(browser.processes.size())); | 477 static_cast<int>(browser.processes.size())); |
472 UMA_HISTOGRAM_COUNTS_100("Memory.ChromeProcessCount", chrome_count); | 478 UMA_HISTOGRAM_COUNTS_100("Memory.ChromeProcessCount", chrome_count); |
473 UMA_HISTOGRAM_COUNTS_100("Memory.ExtensionProcessCount", extension_count); | 479 UMA_HISTOGRAM_COUNTS_100("Memory.ExtensionProcessCount", extension_count); |
474 UMA_HISTOGRAM_COUNTS_100("Memory.OtherProcessCount", other_count); | 480 UMA_HISTOGRAM_COUNTS_100("Memory.OtherProcessCount", other_count); |
475 UMA_HISTOGRAM_COUNTS_100("Memory.PluginProcessCount", plugin_count); | 481 UMA_HISTOGRAM_COUNTS_100("Memory.PluginProcessCount", plugin_count); |
476 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount", | 482 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount", |
477 pepper_plugin_count); | 483 pepper_plugin_count); |
478 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginBrokerProcessCount", | 484 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginBrokerProcessCount", |
479 pepper_plugin_broker_count); | 485 pepper_plugin_broker_count); |
480 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); | 486 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); |
481 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); | 487 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); |
482 // TODO(viettrungluu): Do we want separate counts for the other | 488 // TODO(viettrungluu): Do we want separate counts for the other |
483 // (platform-specific) process types? | 489 // (platform-specific) process types? |
484 | 490 |
485 int total_sample = static_cast<int>(aggregate_memory / 1000); | 491 int total_sample = static_cast<int>(aggregate_memory / 1000); |
486 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); | 492 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); |
| 493 |
| 494 // Predict the number of processes needed when isolating all sites and when |
| 495 // isolating only HTTPS sites. |
| 496 int all_renderer_count = renderer_count + chrome_count + extension_count; |
| 497 int non_renderer_count = browser.processes.size() - all_renderer_count; |
| 498 SiteDetails::UpdateHistograms(browser.site_data, all_renderer_count, |
| 499 non_renderer_count); |
487 } | 500 } |
OLD | NEW |