Commit a408469a authored by Patrick Monette's avatar Patrick Monette Committed by Chromium LUCI CQ

Add a ChromeBrowserMainExtraPartsPerformanceMonitor

At first, this class will own the performance_monitor::SystemMonitor.

In the future, it will also own the ProcessMonitor when it no longer
is a leaky singleton.

Bug: 1166820
Change-Id: Ie47865c3b6e9afcae91be14c22342f3b27685426
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2630228Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Reviewed-by: default avatarSébastien Marchand <sebmarchand@chromium.org>
Commit-Queue: Patrick Monette <pmonette@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844571}
parent 9068fbc7
......@@ -1121,6 +1121,8 @@ static_library("browser") {
"performance_manager/policies/policy_features.h",
"performance_manager/policies/working_set_trimmer_policy.cc",
"performance_manager/policies/working_set_trimmer_policy.h",
"performance_monitor/chrome_browser_main_extra_parts_performance_monitor.cc",
"performance_monitor/chrome_browser_main_extra_parts_performance_monitor.h",
"performance_monitor/process_metrics_history.cc",
"performance_monitor/process_metrics_history.h",
"performance_monitor/process_monitor.cc",
......
......@@ -74,7 +74,6 @@
#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/performance_monitor/process_monitor.h"
#include "chrome/browser/performance_monitor/system_monitor.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/prefs/chrome_command_line_pref_store.h"
#include "chrome/browser/prefs/chrome_pref_service_factory.h"
......@@ -731,8 +730,6 @@ void ChromeBrowserMainParts::PostMainMessageLoopStart() {
ThreadProfiler::SetMainThreadTaskRunner(base::ThreadTaskRunnerHandle::Get());
system_monitor_ = performance_monitor::SystemMonitor::Create();
// TODO(sebmarchand): Allow this to be created earlier if startup tracing is
// enabled.
trace_event_system_stats_monitor_ =
......
......@@ -41,10 +41,6 @@ namespace tracing {
class TraceEventSystemStatsMonitor;
}
namespace performance_monitor {
class SystemMonitor;
}
class ChromeBrowserMainParts : public content::BrowserMainParts {
public:
~ChromeBrowserMainParts() override;
......@@ -156,10 +152,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts {
// Parts are deleted in the inverse order they are added.
std::vector<std::unique_ptr<ChromeBrowserMainExtraParts>> chrome_extra_parts_;
// The system monitor instance, used by some subsystems to collect the system
// metrics they need.
std::unique_ptr<performance_monitor::SystemMonitor> system_monitor_;
// The system stats monitor used by chrome://tracing. This doesn't do anything
// until tracing of the |system_stats| category is enabled.
std::unique_ptr<tracing::TraceEventSystemStatsMonitor>
......
......@@ -92,6 +92,7 @@
#include "chrome/browser/payments/payment_request_display_manager_factory.h"
#include "chrome/browser/performance_manager/chrome_browser_main_extra_parts_performance_manager.h"
#include "chrome/browser/performance_manager/chrome_content_browser_client_performance_manager_part.h"
#include "chrome/browser/performance_monitor/chrome_browser_main_extra_parts_performance_monitor.h"
#include "chrome/browser/permissions/attestation_permission_request.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/plugins/pdf_iframe_navigation_throttle.h"
......@@ -1456,6 +1457,9 @@ ChromeContentBrowserClient::CreateBrowserMainParts(
main_parts->AddParts(std::make_unique<ChromeBrowserMainExtraPartsOzone>());
#endif
main_parts->AddParts(
std::make_unique<ChromeBrowserMainExtraPartsPerformanceMonitor>());
main_parts->AddParts(
std::make_unique<ChromeBrowserMainExtraPartsPerformanceManager>());
......
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/performance_monitor/chrome_browser_main_extra_parts_performance_monitor.h"
#include "chrome/browser/performance_monitor/system_monitor.h"
ChromeBrowserMainExtraPartsPerformanceMonitor::
ChromeBrowserMainExtraPartsPerformanceMonitor() = default;
ChromeBrowserMainExtraPartsPerformanceMonitor::
~ChromeBrowserMainExtraPartsPerformanceMonitor() = default;
void ChromeBrowserMainExtraPartsPerformanceMonitor::PostMainMessageLoopStart() {
system_monitor_ = performance_monitor::SystemMonitor::Create();
}
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_PERFORMANCE_MONITOR_CHROME_BROWSER_MAIN_EXTRA_PARTS_PERFORMANCE_MONITOR_H_
#define CHROME_BROWSER_PERFORMANCE_MONITOR_CHROME_BROWSER_MAIN_EXTRA_PARTS_PERFORMANCE_MONITOR_H_
#include <memory>
#include "chrome/browser/chrome_browser_main_extra_parts.h"
namespace performance_monitor {
class SystemMonitor;
} // namespace performance_monitor
class ChromeBrowserMainExtraPartsPerformanceMonitor
: public ChromeBrowserMainExtraParts {
public:
ChromeBrowserMainExtraPartsPerformanceMonitor();
~ChromeBrowserMainExtraPartsPerformanceMonitor() override;
ChromeBrowserMainExtraPartsPerformanceMonitor(
const ChromeBrowserMainExtraPartsPerformanceMonitor&) = delete;
ChromeBrowserMainExtraPartsPerformanceMonitor& operator=(
const ChromeBrowserMainExtraPartsPerformanceMonitor&) = delete;
// ChromeBrowserMainExtraParts:
void PostMainMessageLoopStart() override;
private:
// The system monitor instance, used by some subsystems to collect the system
// metrics they need.
std::unique_ptr<performance_monitor::SystemMonitor> system_monitor_;
};
#endif // CHROME_BROWSER_PERFORMANCE_MONITOR_CHROME_BROWSER_MAIN_EXTRA_PARTS_PERFORMANCE_MONITOR_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment