From 5fc4228126f9a902e6b41035bdba02f88e35f278 Mon Sep 17 00:00:00 2001 From: Mikhail Atuchin Date: Tue, 29 Oct 2024 23:00:38 +0400 Subject: [PATCH] disable chromium metrics providers --- .../metrics/chrome_metrics_service_client.cc | 18 ++++++++++++++++ .../metrics/chrome_metrics_service_client.h | 21 +++++++++++++++++++ ...n_extra_parts_performance_manager.cc.patch | 18 ++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 chromium_src/chrome/browser/metrics/chrome_metrics_service_client.cc create mode 100644 chromium_src/chrome/browser/metrics/chrome_metrics_service_client.h create mode 100644 patches/chrome-browser-performance_manager-chrome_browser_main_extra_parts_performance_manager.cc.patch diff --git a/chromium_src/chrome/browser/metrics/chrome_metrics_service_client.cc b/chromium_src/chrome/browser/metrics/chrome_metrics_service_client.cc new file mode 100644 index 000000000000..50eb36598dab --- /dev/null +++ b/chromium_src/chrome/browser/metrics/chrome_metrics_service_client.cc @@ -0,0 +1,18 @@ +/* Copyright (c) 2024 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "chrome/browser/metrics/chrome_metrics_service_client.h" + +#define ChromeMetricsServiceClient ChromeMetricsServiceClient_ChromiumImpl +#include "src/chrome/browser/metrics/chrome_metrics_service_client.cc" +#undef ChromeMetricsServiceClient + +void ChromeMetricsServiceClient::RegisterMetricsServiceProviders() { + // Do nothing. +} + +void ChromeMetricsServiceClient::RegisterUKMProviders() { + // Do nothing. +} diff --git a/chromium_src/chrome/browser/metrics/chrome_metrics_service_client.h b/chromium_src/chrome/browser/metrics/chrome_metrics_service_client.h new file mode 100644 index 000000000000..38b0933b91a8 --- /dev/null +++ b/chromium_src/chrome/browser/metrics/chrome_metrics_service_client.h @@ -0,0 +1,21 @@ +/* Copyright (c) 2024 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ +#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ +#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ + +#define ChromeMetricsServiceClient ChromeMetricsServiceClient_ChromiumImpl +#define RegisterMetricsServiceProviders virtual RegisterMetricsServiceProviders +#include "src/chrome/browser/metrics/chrome_metrics_service_client.h" // IWYU pragma: export +#undef RegisterMetricsServiceProviders +#undef ChromeMetricsServiceClient + +class ChromeMetricsServiceClient + : public ChromeMetricsServiceClient_ChromiumImpl { + private: + void RegisterMetricsServiceProviders() override; + void RegisterUKMProviders() override; +}; + +#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ diff --git a/patches/chrome-browser-performance_manager-chrome_browser_main_extra_parts_performance_manager.cc.patch b/patches/chrome-browser-performance_manager-chrome_browser_main_extra_parts_performance_manager.cc.patch new file mode 100644 index 000000000000..9604b46738e0 --- /dev/null +++ b/patches/chrome-browser-performance_manager-chrome_browser_main_extra_parts_performance_manager.cc.patch @@ -0,0 +1,18 @@ +diff --git a/chrome/browser/performance_manager/chrome_browser_main_extra_parts_performance_manager.cc b/chrome/browser/performance_manager/chrome_browser_main_extra_parts_performance_manager.cc +index 11548a8313dc775cb9bea3bc041d896e42ce305a..bbdced4ba79bd5722b74b0639e1c2bcfa7b6f250 100644 +--- a/chrome/browser/performance_manager/chrome_browser_main_extra_parts_performance_manager.cc ++++ b/chrome/browser/performance_manager/chrome_browser_main_extra_parts_performance_manager.cc +@@ -310,11 +310,13 @@ void ChromeBrowserMainExtraPartsPerformanceManager::PreMainMessageLoopRun() { + performance_manager::user_tuning::UserPerformanceTuningManager::GetInstance() + ->Start(); + ++#if 0 // Disabled in Brave + // This object is created by the metrics service before threads, but it + // needs the UserPerformanceTuningManager to exist. At this point it's + // instantiated, but still needs to be initialized. + performance_manager::MetricsProviderDesktop::GetInstance()->Initialize(); + #endif ++#endif + } + + void ChromeBrowserMainExtraPartsPerformanceManager::PostMainMessageLoopRun() {