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

Unified Diff: chrome/browser/performance_monitor/performance_monitor.cc

Issue 2694363007: Add memory and CPU histogram for OOPIF
Patch Set: Created 3 years, 10 months 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/performance_monitor/performance_monitor.cc
diff --git a/chrome/browser/performance_monitor/performance_monitor.cc b/chrome/browser/performance_monitor/performance_monitor.cc
index 6c26e4a99e8a14e457318a839972417ad7c7417d..e17f5dda107fbd731faee7883cd1eebc463bd2c0 100644
--- a/chrome/browser/performance_monitor/performance_monitor.cc
+++ b/chrome/browser/performance_monitor/performance_monitor.cc
@@ -16,6 +16,9 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/render_widget_host.h"
+#include "content/public/browser/render_widget_host_iterator.h"
+#include "content/public/browser/render_widget_host_view.h"
#include "content/public/common/content_constants.h"
#include "extensions/features/features.h"
@@ -37,9 +40,22 @@ const int kGatherIntervalInSeconds = 120;
base::LazyInstance<PerformanceMonitor> g_monitor = LAZY_INSTANCE_INITIALIZER;
-void GatherMetricsForRenderProcess(content::RenderProcessHost* host,
- ProcessMetricsMetadata* data) {
+void GatherMetricsForRenderProcess(
+ content::RenderProcessHost* host,
+ const std::vector<content::RenderWidgetHost*>& widgets,
+ ProcessMetricsMetadata* data) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ for (auto* widget : widgets) {
+ DCHECK_EQ(host, widget->GetProcess());
+
+ content::RenderWidgetHostView* rwhv = widget->GetView();
+ if (rwhv && rwhv->IsRenderWidgetHostViewChildFrame()) {
+ data->contains_oopif = true;
+ break;
+ }
+ }
+
#if BUILDFLAG(ENABLE_EXTENSIONS)
content::BrowserContext* browser_context = host->GetBrowserContext();
extensions::ProcessMap* extension_process_map =
@@ -95,6 +111,18 @@ void PerformanceMonitor::GatherMetricsMapOnUIThread() {
// it doesn't matter. We just check it for inequality.
current_update_sequence++;
+ // First pass, collate the widgets by process ID.
+ std::map<content::RenderProcessHost*, std::vector<content::RenderWidgetHost*>>
+ widgets_by_rph;
+ std::unique_ptr<content::RenderWidgetHostIterator> widget_it(
+ content::RenderWidgetHost::GetRenderWidgetHosts());
+ while (content::RenderWidgetHost* widget = widget_it->GetNextHost()) {
+ // Ignore processes that don't have a connection, such as crashed tabs.
+ if (!widget->GetProcess()->HasConnection())
+ continue;
+ widgets_by_rph[widget->GetProcess()].push_back(widget);
+ }
+
// Find all render child processes; has to be done on the UI thread.
for (content::RenderProcessHost::iterator rph_iter =
content::RenderProcessHost::AllHostsIterator();
@@ -104,7 +132,7 @@ void PerformanceMonitor::GatherMetricsMapOnUIThread() {
data.process_type = content::PROCESS_TYPE_RENDERER;
data.handle = host->GetHandle();
- GatherMetricsForRenderProcess(host, &data);
+ GatherMetricsForRenderProcess(host, widgets_by_rph[host], &data);
MarkProcessAsAlive(data, current_update_sequence);
}

Powered by Google App Engine
This is Rietveld 408576698