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..e86d4bc107a5 --- /dev/null +++ b/chromium_src/chrome/browser/metrics/chrome_metrics_service_client.cc @@ -0,0 +1,24 @@ +/* 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. +} + +ChromeMetricsServiceClient::ChromeMetricsServiceClient( + metrics::MetricsStateManager* state_manager, + variations::SyntheticTrialRegistry* synthetic_trial_registry) + : ChromeMetricsServiceClient_ChromiumImpl(state_manager, + synthetic_trial_registry) {} 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..6e705f967057 --- /dev/null +++ b/chromium_src/chrome/browser/metrics/chrome_metrics_service_client.h @@ -0,0 +1,32 @@ +/* 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 { + public: + void RegisterMetricsServiceProviders() override; + void RegisterUKMProviders() override; + + ChromeMetricsServiceClient( + metrics::MetricsStateManager* state_manager, + variations::SyntheticTrialRegistry* synthetic_trial_registry); + + private: + // TODO: remove? + friend class ChromeMetricsServiceClientTest; + friend class ChromeMetricsServiceClientTestIgnoredForAppMetrics; + friend class ChromeMetricsServiceClientTestWithoutUKMProviders; + FRIEND_TEST_ALL_PREFIXES(ChromeMetricsServiceClientTest, IsWebstoreExtension); +}; + +#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() {