From 13e8d06f68da2a08fdfb42079789f8a59e0ac7b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Degros?= Date: Mon, 8 Jan 2018 13:53:34 +1100 Subject: [PATCH] Removed StatisticsRecorder::Initialize and StatisticsRecorder::IsActive. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a simple code cleanup. These methods were already deprecated and empty. TBR=bartfab@chromium.org,rockot@chromium.org,avi@chromium.org,dpranke@chromium.org,groby@chromium.org,pwnall@chromium.org,oshima@chromium.org,agrieve@chromium.org,stevenjb@chromium.org,halliwell@chromium.org,juliatuttle@chromium.org,treib@chromium.org,yfriedman@chromium.org,asvitkine@chromium.org,sdefresne@chromium.org,wolenetz@chromium.org,pauljensen@chromium.org,gene@chromium.org,csharrison@chromium.org,pfeldman@chromium.org,blundell@chromium.org,borisv@chromium.org Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs Change-Id: I658a4a8370fc423f1afd60ca5e943a4c8b511417 Bug: Reviewed-on: https://chromium-review.googlesource.com/846651 Commit-Queue: François Degros Reviewed-by: Julia Tuttle Reviewed-by: Victor Costan Reviewed-by: Charlie Harrison Reviewed-by: Yaron Friedman Reviewed-by: agrieve Reviewed-by: Avi Drissman Reviewed-by: Bartosz Fabianowski Reviewed-by: Sylvain Defresne Reviewed-by: Alexei Svitkine Reviewed-by: Luke Halliwell Reviewed-by: Mitsuru Oshima Cr-Commit-Position: refs/heads/master@{#527562} --- ash/test/ash_test_suite.cc | 3 --- .../base/library_loader/LibraryLoader.java | 3 --- .../base/metrics/RecordHistogram.java | 9 ------- .../base/metrics/RecordHistogramTest.java | 1 - base/android/record_histogram.cc | 4 --- .../metrics/persistent_histogram_allocator.cc | 3 --- base/metrics/statistics_recorder.h | 7 ----- base/test/histogram_tester.cc | 2 -- base/test/histogram_tester.h | 3 +-- .../chrome/browser/RestoreHistogramTest.java | 3 --- .../browser/customtabs/ClientManagerTest.java | 2 -- chrome/app/chrome_main_delegate.cc | 5 ---- .../network_portal_detector_impl_unittest.cc | 1 - .../mac/exception_processor_unittest.mm | 4 --- .../mod_pagespeed_metrics_unittest.cc | 1 - .../cloud_policy_invalidator_unittest.cc | 1 - .../spellcheck_custom_dictionary_unittest.cc | 6 ----- .../search/ntp_user_data_logger_unittest.cc | 27 ------------------- .../net/net_error_helper_core_unittest.cc | 3 --- chrome/service/service_main.cc | 3 --- chromecast/base/metrics/grouped_histogram.cc | 2 -- .../cronet/android/cronet_library_loader.cc | 4 --- .../cronet_url_request_context_adapter.cc | 2 -- .../cronet/histogram_manager_unittest.cc | 2 -- components/cronet/ios/cronet_environment.mm | 2 -- .../spellcheck_host_metrics_unittest.cc | 9 ------- .../sync/base/data_type_histogram_unittest.cc | 6 +---- components/test/components_test_suite.cc | 6 ----- .../translate_browser_metrics_unittest.cc | 2 -- .../core/common/translate_metrics_unittest.cc | 2 -- content/app/content_main_runner.cc | 3 --- content/browser/browser_main_runner.cc | 4 +-- content/child/child_process.cc | 3 --- content/gpu/gpu_main.cc | 4 --- .../public/test/content_test_suite_base.cc | 6 ----- content/renderer/renderer_main.cc | 4 --- dbus/signal_sender_verification_unittest.cc | 3 --- ios/chrome/test/app/histogram_test_util.h | 3 +-- ios/chrome/test/app/histogram_test_util.mm | 2 -- .../public/global_state/ios_global_state.mm | 3 --- ios/web/test/web_test_suite.mm | 6 ----- media/test/pipeline_integration_fuzzertest.cc | 6 ----- media/test/run_all_unittests.cc | 4 --- net/base/fuzzer_test_support.cc | 5 ---- net/test/run_all_unittests.cc | 6 ++--- .../tracked/pref_hash_filter_unittest.cc | 1 - sql/test/sql_test_suite.cc | 7 ----- .../fuzzers/language_detection_fuzzer.cc | 9 ------- .../testing/TestingPlatformSupport.cpp | 2 -- 49 files changed, 6 insertions(+), 203 deletions(-) diff --git a/ash/test/ash_test_suite.cc b/ash/test/ash_test_suite.cc index 40d7d7f22cfda0..31bb9599dd9846 100644 --- a/ash/test/ash_test_suite.cc +++ b/ash/test/ash_test_suite.cc @@ -10,7 +10,6 @@ #include "base/command_line.h" #include "base/files/file_path.h" #include "base/i18n/rtl.h" -#include "base/metrics/statistics_recorder.h" #include "base/path_service.h" #include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" @@ -30,8 +29,6 @@ AshTestSuite::~AshTestSuite() = default; void AshTestSuite::Initialize() { base::TestSuite::Initialize(); - // Ensure histograms hit during tests are registered properly. - base::StatisticsRecorder::Initialize(); gl::GLSurfaceTestSupport::InitializeOneOff(); gfx::RegisterPathProvider(); diff --git a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java index 0d25b81c9ebdcb..91857764cd61cf 100644 --- a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java +++ b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java @@ -318,9 +318,6 @@ protected Void doInBackground(Void... params) { Log.w(TAG, "Forking a process to prefetch the native library failed."); } } - // As this runs in a background thread, it can be called before histograms are - // initialized. In this instance, histograms are dropped. - RecordHistogram.initialize(); if (prefetch) { RecordHistogram.recordBooleanHistogram("LibraryLoader.PrefetchStatus", success); } diff --git a/base/android/java/src/org/chromium/base/metrics/RecordHistogram.java b/base/android/java/src/org/chromium/base/metrics/RecordHistogram.java index 07512648cad44b..ed3959e3f01325 100644 --- a/base/android/java/src/org/chromium/base/metrics/RecordHistogram.java +++ b/base/android/java/src/org/chromium/base/metrics/RecordHistogram.java @@ -292,14 +292,6 @@ public static int getHistogramTotalCountForTesting(String name) { return nativeGetHistogramTotalCountForTesting(name); } - /** - * Initializes the metrics system. - */ - public static void initialize() { - if (sDisabledBy != null) return; - nativeInitialize(); - } - private static native long nativeRecordCustomTimesHistogramMilliseconds( String name, long key, int duration, int min, int max, int numBuckets); @@ -314,5 +306,4 @@ private static native long nativeRecordLinearCountHistogram( private static native int nativeGetHistogramValueCountForTesting(String name, int sample); private static native int nativeGetHistogramTotalCountForTesting(String name); - private static native void nativeInitialize(); } diff --git a/base/android/javatests/src/org/chromium/base/metrics/RecordHistogramTest.java b/base/android/javatests/src/org/chromium/base/metrics/RecordHistogramTest.java index daf639bc93efca..89796115c352d7 100644 --- a/base/android/javatests/src/org/chromium/base/metrics/RecordHistogramTest.java +++ b/base/android/javatests/src/org/chromium/base/metrics/RecordHistogramTest.java @@ -26,7 +26,6 @@ public class RecordHistogramTest { @Before public void setUp() throws Exception { LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized(); - RecordHistogram.initialize(); } /** diff --git a/base/android/record_histogram.cc b/base/android/record_histogram.cc index 02f44934169684..0bc8423c854060 100644 --- a/base/android/record_histogram.cc +++ b/base/android/record_histogram.cc @@ -304,10 +304,6 @@ jlong JNI_RecordHistogram_RecordCustomTimesHistogramMilliseconds( return reinterpret_cast(histogram); } -void JNI_RecordHistogram_Initialize(JNIEnv* env, const JavaParamRef&) { - StatisticsRecorder::Initialize(); -} - // This backs a Java test util for testing histograms - // MetricsUtils.HistogramDelta. It should live in a test-specific file, but we // currently can't have test-specific native code packaged in test-specific Java diff --git a/base/metrics/persistent_histogram_allocator.cc b/base/metrics/persistent_histogram_allocator.cc index 79a903eb183017..6178b21a48d296 100644 --- a/base/metrics/persistent_histogram_allocator.cc +++ b/base/metrics/persistent_histogram_allocator.cc @@ -1090,9 +1090,6 @@ GlobalHistogramAllocator::GlobalHistogramAllocator( std::unique_ptr memory) : PersistentHistogramAllocator(std::move(memory)), import_iterator_(this) { - // Make sure the StatisticsRecorder is initialized to prevent duplicate - // histograms from being created. It's safe to call this multiple times. - StatisticsRecorder::Initialize(); } void GlobalHistogramAllocator::ImportHistogramsToStatisticsRecorder() { diff --git a/base/metrics/statistics_recorder.h b/base/metrics/statistics_recorder.h index f37f17b3176340..75352d1bf4674d 100644 --- a/base/metrics/statistics_recorder.h +++ b/base/metrics/statistics_recorder.h @@ -68,13 +68,6 @@ class BASE_EXPORT StatisticsRecorder { // Precondition: The recorder being deleted is the current global recorder. ~StatisticsRecorder(); - // DEPRECATED. - // - // StatisticsRecorder is always active and ready. There is no need to - // explicitly initialize it. - static void Initialize() {} - static bool IsActive() { return true; } - // Registers a provider of histograms that can be called to merge those into // the global recorder. Calls to ImportProvidedHistograms() will fetch from // registered providers. diff --git a/base/test/histogram_tester.cc b/base/test/histogram_tester.cc index 64b4ca2e00f741..8949133b71cc02 100644 --- a/base/test/histogram_tester.cc +++ b/base/test/histogram_tester.cc @@ -17,8 +17,6 @@ namespace base { HistogramTester::HistogramTester() { - StatisticsRecorder::Initialize(); // Safe to call multiple times. - // Record any histogram data that exists when the object is created so it can // be subtracted later. StatisticsRecorder::Histograms histograms; diff --git a/base/test/histogram_tester.h b/base/test/histogram_tester.h index 1bd024c69f9f32..b31c63153f8c51 100644 --- a/base/test/histogram_tester.h +++ b/base/test/histogram_tester.h @@ -29,8 +29,7 @@ class HistogramTester { public: using CountsMap = std::map; - // The constructor will call StatisticsRecorder::Initialize() for you. Also, - // this takes a snapshot of all current histograms counts. + // Takes a snapshot of all current histograms counts. HistogramTester(); ~HistogramTester(); diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/RestoreHistogramTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/RestoreHistogramTest.java index 2b5af69802585f..edf6354ab2cb76 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/RestoreHistogramTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/RestoreHistogramTest.java @@ -17,7 +17,6 @@ import org.chromium.base.library_loader.LibraryLoader; import org.chromium.base.library_loader.LibraryProcessType; import org.chromium.base.library_loader.ProcessInitException; -import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.MetricsUtils; import org.chromium.chrome.test.ChromeJUnit4ClassRunner; @@ -59,7 +58,6 @@ private void clearPrefs() { @SmallTest public void testHistogramWriter() throws ProcessInitException { LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized(); - RecordHistogram.initialize(); MetricsUtils.HistogramDelta noRestoreDelta = new MetricsUtils.HistogramDelta( ChromeBackupAgent.HISTOGRAM_ANDROID_RESTORE_RESULT, ChromeBackupAgent.NO_RESTORE); MetricsUtils.HistogramDelta restoreCompletedDelta = @@ -101,7 +99,6 @@ public void testHistogramWriter() throws ProcessInitException { @SmallTest public void testWritingHistogramAtStartup() throws InterruptedException, ProcessInitException { LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized(); - RecordHistogram.initialize(); MetricsUtils.HistogramDelta noRestoreDelta = new MetricsUtils.HistogramDelta( ChromeBackupAgent.HISTOGRAM_ANDROID_RESTORE_RESULT, ChromeBackupAgent.NO_RESTORE); diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/ClientManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/ClientManagerTest.java index caddec148a382d..6d4b5e7ddb0624 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/ClientManagerTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/ClientManagerTest.java @@ -20,7 +20,6 @@ import org.chromium.base.ContextUtils; import org.chromium.base.ThreadUtils; -import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.test.BaseJUnit4ClassRunner; import org.chromium.base.test.util.MetricsUtils; import org.chromium.base.test.util.RetryOnFailure; @@ -53,7 +52,6 @@ public void setUp() throws Exception { mActivityTestRule.loadNativeLibraryNoBrowserProcess(); RequestThrottler.purgeAllEntriesForTesting(context); mClientManager = new ClientManager(context); - RecordHistogram.initialize(); ThreadUtils.runOnUiThreadBlocking(new Runnable() { @Override public void run() { diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc index fa63a4f08f96d4..ba4775120b3a82 100644 --- a/chrome/app/chrome_main_delegate.cc +++ b/chrome/app/chrome_main_delegate.cc @@ -15,7 +15,6 @@ #include "base/lazy_instance.h" #include "base/macros.h" #include "base/message_loop/message_loop.h" -#include "base/metrics/statistics_recorder.h" #include "base/path_service.h" #include "base/process/memory.h" #include "base/process/process_handle.h" @@ -638,10 +637,6 @@ bool ChromeMainDelegate::BasicStartupComplete(int* exit_code) { if ((base::SysInfo::IsRunningOnChromeOS() && command_line.HasSwitch(chromeos::switches::kLoginUser)) || command_line.HasSwitch(switches::kDiagnosticsRecovery)) { - // The statistics subsystem needs get initialized soon enough for the - // statistics to be collected. It's safe to call this more than once. - base::StatisticsRecorder::Initialize(); - base::CommandLine interim_command_line(command_line.GetProgram()); const char* const kSwitchNames[] = {switches::kUserDataDir, }; interim_command_line.CopySwitchesFrom( diff --git a/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc b/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc index a788d09f6b9dda..f48d9ac26531d5 100644 --- a/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc +++ b/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc @@ -89,7 +89,6 @@ class NetworkPortalDetectorImplTest base::WrapUnique(user_manager)); DBusThreadManager::Initialize(); - base::StatisticsRecorder::Initialize(); SetupNetworkHandler(); ASSERT_TRUE(test_profile_manager_.SetUp()); diff --git a/chrome/browser/mac/exception_processor_unittest.mm b/chrome/browser/mac/exception_processor_unittest.mm index 78f570b54ff779..a0aa908d2ec7bc 100644 --- a/chrome/browser/mac/exception_processor_unittest.mm +++ b/chrome/browser/mac/exception_processor_unittest.mm @@ -47,10 +47,6 @@ size_t BinForExceptionNamed(NSString* name) { } TEST(ExceptionProcessorTest, RecordException) { - // Start up a histogram recorder. - // TODO(rtenneti): Leaks StatisticsRecorder and will update suppressions. - base::StatisticsRecorder::Initialize(); - StatisticsRecorder::Histograms histograms; StatisticsRecorder::GetSnapshot("OSX.NSException", &histograms); EXPECT_EQ(0U, histograms.size()); diff --git a/chrome/browser/mod_pagespeed/mod_pagespeed_metrics_unittest.cc b/chrome/browser/mod_pagespeed/mod_pagespeed_metrics_unittest.cc index b373b22b9eab32..e01f919c4618b9 100644 --- a/chrome/browser/mod_pagespeed/mod_pagespeed_metrics_unittest.cc +++ b/chrome/browser/mod_pagespeed/mod_pagespeed_metrics_unittest.cc @@ -21,7 +21,6 @@ namespace mod_pagespeed { // Ensure that we count PageSpeed headers correctly. TEST(ModPagespeedMetricsTest, CountPageSpeedHeadersTest) { - base::StatisticsRecorder::Initialize(); GURL url("http://google.com"); std::string temp("HTTP/1.1 200 OK\n\n"); std::replace(temp.begin(), temp.end(), '\n', '\0'); diff --git a/chrome/browser/policy/cloud/cloud_policy_invalidator_unittest.cc b/chrome/browser/policy/cloud/cloud_policy_invalidator_unittest.cc index e771f5537ef117..2f374b44d573d2 100644 --- a/chrome/browser/policy/cloud/cloud_policy_invalidator_unittest.cc +++ b/chrome/browser/policy/cloud/cloud_policy_invalidator_unittest.cc @@ -884,7 +884,6 @@ CloudPolicyInvalidatorUserTypedTest::~CloudPolicyInvalidatorUserTypedTest() { } void CloudPolicyInvalidatorUserTypedTest::SetUp() { - base::StatisticsRecorder::Initialize(); refresh_samples_ = GetHistogramSamples( GetPolicyType() == em::DeviceRegisterRequest::DEVICE ? kMetricDevicePolicyRefresh : kMetricUserPolicyRefresh); diff --git a/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc b/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc index 5a640b85ce23c8..c488d189d6d717 100644 --- a/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc +++ b/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc @@ -67,8 +67,6 @@ class SpellcheckCustomDictionaryTest : public testing::Test { // Use SetTestingFactoryAndUse to force creation and initialization. SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( &profile_, &BuildSpellcheckService); - - StatisticsRecorder::Initialize(); } // A wrapper around SpellcheckCustomDictionary::LoadDictionaryFile private @@ -1143,10 +1141,6 @@ TEST_F(SpellcheckCustomDictionaryTest, MAYBE_RecordSizeStatsCorrectly) { // Record a baseline. SpellCheckHostMetrics::RecordCustomWordCountStats(123); - // Determine if test failures are due the statistics recorder not being - // available or because the histogram just isn't there: crbug.com/230534. - EXPECT_TRUE(StatisticsRecorder::IsActive()); - HistogramBase* histogram = StatisticsRecorder::FindHistogram("SpellCheck.CustomWords"); ASSERT_TRUE(histogram != NULL); diff --git a/chrome/browser/ui/search/ntp_user_data_logger_unittest.cc b/chrome/browser/ui/search/ntp_user_data_logger_unittest.cc index 83df3d05f48076..b80809a22f56f7 100644 --- a/chrome/browser/ui/search/ntp_user_data_logger_unittest.cc +++ b/chrome/browser/ui/search/ntp_user_data_logger_unittest.cc @@ -9,7 +9,6 @@ #include #include "base/metrics/histogram.h" -#include "base/metrics/statistics_recorder.h" #include "base/test/histogram_tester.h" #include "base/time/time.h" #include "chrome/common/search/ntp_logging_events.h" @@ -73,8 +72,6 @@ MATCHER_P3(IsBucketBetween, lower_bound, upper_bound, count, "") { } // namespace TEST(NTPUserDataLoggerTest, ShouldRecordNumberOfTiles) { - base::StatisticsRecorder::Initialize(); - base::HistogramTester histogram_tester; // Ensure non-zero statistics. @@ -107,8 +104,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordNumberOfTiles) { } TEST(NTPUserDataLoggerTest, ShouldNotRecordImpressionsBeforeAllTilesLoaded) { - base::StatisticsRecorder::Initialize(); - TestNTPUserDataLogger logger(GURL("chrome://newtab/")); base::HistogramTester histogram_tester; @@ -145,8 +140,6 @@ TEST(NTPUserDataLoggerTest, ShouldNotRecordImpressionsBeforeAllTilesLoaded) { } TEST(NTPUserDataLoggerTest, ShouldRecordImpressions) { - base::StatisticsRecorder::Initialize(); - TestNTPUserDataLogger logger(GURL("chrome://newtab/")); base::HistogramTester histogram_tester; @@ -231,8 +224,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordImpressions) { } TEST(NTPUserDataLoggerTest, ShouldNotRecordRepeatedImpressions) { - base::StatisticsRecorder::Initialize(); - TestNTPUserDataLogger logger(GURL("chrome://newtab/")); base::HistogramTester histogram_tester; @@ -296,8 +287,6 @@ TEST(NTPUserDataLoggerTest, ShouldNotRecordRepeatedImpressions) { } TEST(NTPUserDataLoggerTest, ShouldNotRecordImpressionsForBinsBeyondEight) { - base::StatisticsRecorder::Initialize(); - TestNTPUserDataLogger logger(GURL("chrome://newtab/")); base::HistogramTester histogram_tester; @@ -346,8 +335,6 @@ TEST(NTPUserDataLoggerTest, ShouldNotRecordImpressionsForBinsBeyondEight) { } TEST(NTPUserDataLoggerTest, ShouldRecordImpressionsAgainAfterNavigating) { - base::StatisticsRecorder::Initialize(); - TestNTPUserDataLogger logger(GURL("chrome://newtab/")); // Record some previous tile impressions. @@ -426,8 +413,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordImpressionsAgainAfterNavigating) { } TEST(NTPUserDataLoggerTest, ShouldRecordNavigations) { - base::StatisticsRecorder::Initialize(); - TestNTPUserDataLogger logger(GURL("chrome://newtab/")); { @@ -603,8 +588,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordNavigations) { } TEST(NTPUserDataLoggerTest, ShouldRecordLoadTime) { - base::StatisticsRecorder::Initialize(); - base::HistogramTester histogram_tester; TestNTPUserDataLogger logger(GURL("chrome://newtab/")); @@ -697,8 +680,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordLoadTime) { } TEST(NTPUserDataLoggerTest, ShouldRecordLoadTimeLocalNTPGoogle) { - base::StatisticsRecorder::Initialize(); - base::HistogramTester histogram_tester; TestNTPUserDataLogger logger((GURL(chrome::kChromeSearchLocalNtpUrl))); @@ -734,8 +715,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordLoadTimeLocalNTPGoogle) { } TEST(NTPUserDataLoggerTest, ShouldRecordLoadTimeLocalNTPOther) { - base::StatisticsRecorder::Initialize(); - base::HistogramTester histogram_tester; TestNTPUserDataLogger logger((GURL(chrome::kChromeSearchLocalNtpUrl))); @@ -771,8 +750,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordLoadTimeLocalNTPOther) { } TEST(NTPUserDataLoggerTest, ShouldRecordLoadTimeRemoteNTPGoogle) { - base::StatisticsRecorder::Initialize(); - base::HistogramTester histogram_tester; TestNTPUserDataLogger logger(GURL("https://www.google.com/_/chrome/newtab")); @@ -806,8 +783,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordLoadTimeRemoteNTPGoogle) { } TEST(NTPUserDataLoggerTest, ShouldRecordLoadTimeRemoteNTPOther) { - base::StatisticsRecorder::Initialize(); - base::HistogramTester histogram_tester; TestNTPUserDataLogger logger(GURL("https://www.notgoogle.com/newtab")); @@ -841,8 +816,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordLoadTimeRemoteNTPOther) { } TEST(NTPUserDataLoggerTest, ShouldRecordImpressionsAge) { - base::StatisticsRecorder::Initialize(); - base::HistogramTester histogram_tester; // Ensure non-zero statistics. diff --git a/chrome/renderer/net/net_error_helper_core_unittest.cc b/chrome/renderer/net/net_error_helper_core_unittest.cc index c36dffb82bd4e4..3f7c74d86f03ea 100644 --- a/chrome/renderer/net/net_error_helper_core_unittest.cc +++ b/chrome/renderer/net/net_error_helper_core_unittest.cc @@ -18,7 +18,6 @@ #include "base/logging.h" #include "base/macros.h" #include "base/memory/ptr_util.h" -#include "base/metrics/statistics_recorder.h" #include "base/strings/stringprintf.h" #include "base/test/histogram_tester.h" #include "base/timer/mock_timer.h" @@ -173,8 +172,6 @@ class NetErrorHelperCoreTest : public testing::Test, EXPECT_FALSE(is_url_being_fetched()); } - void SetUp() override { base::StatisticsRecorder::Initialize(); } - void SetUpCore(bool auto_reload_enabled, bool auto_reload_visible_only, bool visible) { diff --git a/chrome/service/service_main.cc b/chrome/service/service_main.cc index 248270603cfe95..1af4ea7d3908f1 100644 --- a/chrome/service/service_main.cc +++ b/chrome/service/service_main.cc @@ -5,7 +5,6 @@ #include "base/base_switches.h" #include "base/debug/debugger.h" #include "base/message_loop/message_loop.h" -#include "base/metrics/statistics_recorder.h" #include "base/run_loop.h" #include "chrome/common/service_process_util.h" #include "chrome/service/service_process.h" @@ -28,8 +27,6 @@ int CloudPrintServiceProcessMain( VLOG(1) << "Service process launched: " << parameters.command_line.GetCommandLineString(); - base::StatisticsRecorder::Initialize(); - // If there is already a service process running, quit now. std::unique_ptr state(new ServiceProcessState); if (!state->Initialize()) diff --git a/chromecast/base/metrics/grouped_histogram.cc b/chromecast/base/metrics/grouped_histogram.cc index dd8d0977485dbf..b45dbefb838592 100644 --- a/chromecast/base/metrics/grouped_histogram.cc +++ b/chromecast/base/metrics/grouped_histogram.cc @@ -140,7 +140,6 @@ void PreregisterHistogram(const char* name, int32_t flags) { base::StringPiece name_piece(name); - DCHECK(base::StatisticsRecorder::IsActive()); DCHECK(base::Histogram::InspectConstructionArguments( name_piece, &minimum, &maximum, &bucket_count)); DCHECK(!base::StatisticsRecorder::FindHistogram(name_piece)) @@ -167,7 +166,6 @@ void PreregisterHistogram(const char* name, } // namespace void PreregisterAllGroupedHistograms() { - base::StatisticsRecorder::Initialize(); for (size_t i = 0; i < arraysize(kHistogramsToGroup); ++i) { PreregisterHistogram( kHistogramsToGroup[i].name, diff --git a/components/cronet/android/cronet_library_loader.cc b/components/cronet/android/cronet_library_loader.cc index b46507e610b26f..5aa1acc3d79454 100644 --- a/components/cronet/android/cronet_library_loader.cc +++ b/components/cronet/android/cronet_library_loader.cc @@ -17,7 +17,6 @@ #include "base/logging.h" #include "base/macros.h" #include "base/message_loop/message_loop.h" -#include "base/metrics/statistics_recorder.h" #include "base/task_scheduler/task_scheduler.h" #include "components/cronet/android/cronet_jni_registration.h" #include "components/cronet/version.h" @@ -46,9 +45,6 @@ net::NetworkChangeNotifier* g_network_change_notifier = nullptr; bool NativeInit() { if (!base::android::OnJNIOnLoadInit()) return false; - // Initializes the statistics recorder system. This needs to be done before - // emitting histograms to prevent memory leaks (crbug.com/707836). - base::StatisticsRecorder::Initialize(); if (!base::TaskScheduler::GetInstance()) base::TaskScheduler::CreateAndStartWithDefaultParams("Cronet"); diff --git a/components/cronet/android/cronet_url_request_context_adapter.cc b/components/cronet/android/cronet_url_request_context_adapter.cc index 658f2349f129e4..145f24ddd2af2f 100644 --- a/components/cronet/android/cronet_url_request_context_adapter.cc +++ b/components/cronet/android/cronet_url_request_context_adapter.cc @@ -28,7 +28,6 @@ #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/metrics/histogram_macros.h" -#include "base/metrics/statistics_recorder.h" #include "base/single_thread_task_runner.h" #include "base/threading/thread_restrictions.h" #include "base/threading/thread_task_runner_handle.h" @@ -894,7 +893,6 @@ static ScopedJavaLocalRef JNI_CronetUrlRequestContext_GetHistogramDeltas( JNIEnv* env, const JavaParamRef& jcaller) { - DCHECK(base::StatisticsRecorder::IsActive()); std::vector data; if (!HistogramManager::GetInstance()->GetDeltas(&data)) return ScopedJavaLocalRef(); diff --git a/components/cronet/histogram_manager_unittest.cc b/components/cronet/histogram_manager_unittest.cc index af599e704a0df6..91bed5fcd92da6 100644 --- a/components/cronet/histogram_manager_unittest.cc +++ b/components/cronet/histogram_manager_unittest.cc @@ -9,7 +9,6 @@ #include #include "base/metrics/histogram_macros.h" -#include "base/metrics/statistics_recorder.h" #include "testing/gtest/include/gtest/gtest.h" namespace cronet { @@ -18,7 +17,6 @@ using metrics::ChromeUserMetricsExtension; using metrics::HistogramEventProto; TEST(HistogramManager, HistogramBucketFields) { - base::StatisticsRecorder::Initialize(); // Capture histograms at the start of the test to avoid later GetDeltas() // calls picking them up. std::vector data_init; diff --git a/components/cronet/ios/cronet_environment.mm b/components/cronet/ios/cronet_environment.mm index b6a07c0cd1856c..62070e2eee6e4f 100644 --- a/components/cronet/ios/cronet_environment.mm +++ b/components/cronet/ios/cronet_environment.mm @@ -17,7 +17,6 @@ #include "base/mac/foundation_util.h" #include "base/macros.h" #include "base/message_loop/message_loop.h" -#include "base/metrics/statistics_recorder.h" #include "base/path_service.h" #include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" @@ -437,7 +436,6 @@ bool IsNetLogPathValid(const base::FilePath& path) { } std::vector CronetEnvironment::GetHistogramDeltas() { - DCHECK(base::StatisticsRecorder::IsActive()); std::vector data; if (!HistogramManager::GetInstance()->GetDeltas(&data)) return std::vector(); diff --git a/components/spellcheck/browser/spellcheck_host_metrics_unittest.cc b/components/spellcheck/browser/spellcheck_host_metrics_unittest.cc index adace851ed7898..64338f6a94839a 100644 --- a/components/spellcheck/browser/spellcheck_host_metrics_unittest.cc +++ b/components/spellcheck/browser/spellcheck_host_metrics_unittest.cc @@ -11,7 +11,6 @@ #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/metrics/histogram_samples.h" -#include "base/metrics/statistics_recorder.h" #include "base/strings/utf_string_conversions.h" #include "base/test/histogram_tester.h" #include "build/build_config.h" @@ -22,10 +21,6 @@ class SpellcheckHostMetricsTest : public testing::Test { SpellcheckHostMetricsTest() { } - static void SetUpTestCase() { - base::StatisticsRecorder::Initialize(); - } - void SetUp() override { metrics_.reset(new SpellCheckHostMetrics); } SpellCheckHostMetrics* metrics() { return metrics_.get(); } @@ -63,10 +58,6 @@ TEST_F(SpellcheckHostMetricsTest, RecordEnabledStats) { TEST_F(SpellcheckHostMetricsTest, MAYBE_CustomWordStats) { SpellCheckHostMetrics::RecordCustomWordCountStats(123); - // Determine if test failures are due the statistics recorder not being - // available or because the histogram just isn't there: crbug.com/230534. - EXPECT_TRUE(base::StatisticsRecorder::IsActive()); - base::HistogramTester histogram_tester; SpellCheckHostMetrics::RecordCustomWordCountStats(23); diff --git a/components/sync/base/data_type_histogram_unittest.cc b/components/sync/base/data_type_histogram_unittest.cc index a7fb661ddf7ede..fc0d4ba9aef8b7 100644 --- a/components/sync/base/data_type_histogram_unittest.cc +++ b/components/sync/base/data_type_histogram_unittest.cc @@ -4,16 +4,12 @@ #include "components/sync/base/data_type_histogram.h" -#include "base/metrics/statistics_recorder.h" #include "testing/gtest/include/gtest/gtest.h" namespace syncer { namespace { -class DataTypeHistogramTest : public testing::Test { - public: - void SetUp() override { base::StatisticsRecorder::Initialize(); } -}; +class DataTypeHistogramTest : public testing::Test {}; // Create a histogram of type LOCAL_HISTOGRAM_COUNTS for each model type. // Nothing should break. diff --git a/components/test/components_test_suite.cc b/components/test/components_test_suite.cc index e76118ee1a8524..78f7e37d6e9629 100644 --- a/components/test/components_test_suite.cc +++ b/components/test/components_test_suite.cc @@ -11,7 +11,6 @@ #include "base/files/file_path.h" #include "base/macros.h" #include "base/memory/ptr_util.h" -#include "base/metrics/statistics_recorder.h" #include "base/path_service.h" #include "base/test/launcher/unit_test_launcher.h" #include "base/test/test_suite.h" @@ -48,11 +47,6 @@ class ComponentsTestSuite : public base::TestSuite { mojo::edk::Init(); - // Initialize the histograms subsystem, so that any histograms hit in tests - // are correctly registered with the statistics recorder and can be queried - // by tests. - base::StatisticsRecorder::Initialize(); - #if !defined(OS_IOS) gl::GLSurfaceTestSupport::InitializeOneOff(); diff --git a/components/translate/core/browser/translate_browser_metrics_unittest.cc b/components/translate/core/browser/translate_browser_metrics_unittest.cc index ce5ce186170baa..5f12436b6bb3c0 100644 --- a/components/translate/core/browser/translate_browser_metrics_unittest.cc +++ b/components/translate/core/browser/translate_browser_metrics_unittest.cc @@ -22,8 +22,6 @@ namespace { class MetricsRecorder { public: explicit MetricsRecorder(const char* key) : key_(key) { - StatisticsRecorder::Initialize(); - HistogramBase* histogram = StatisticsRecorder::FindHistogram(key_); if (histogram) base_samples_ = histogram->SnapshotSamples(); diff --git a/components/translate/core/common/translate_metrics_unittest.cc b/components/translate/core/common/translate_metrics_unittest.cc index 011903026a2cc8..dc33c69773f582 100644 --- a/components/translate/core/common/translate_metrics_unittest.cc +++ b/components/translate/core/common/translate_metrics_unittest.cc @@ -30,8 +30,6 @@ const int kFalse = 0; class MetricsRecorder { public: explicit MetricsRecorder(const char* key) : key_(key) { - StatisticsRecorder::Initialize(); - HistogramBase* histogram = StatisticsRecorder::FindHistogram(key_); if (histogram) base_samples_ = histogram->SnapshotSamples(); diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc index c11f96af06ab03..090857ed16c9bd 100644 --- a/content/app/content_main_runner.cc +++ b/content/app/content_main_runner.cc @@ -29,7 +29,6 @@ #include "base/macros.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram_base.h" -#include "base/metrics/statistics_recorder.h" #include "base/path_service.h" #include "base/process/launch.h" #include "base/process/memory.h" @@ -640,8 +639,6 @@ class ContentMainRunnerImpl : public ContentMainRunner { return TerminateForFatalInitializationError(); #endif // OS_ANDROID && (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE) - base::StatisticsRecorder::Initialize(); - InitializeV8IfNeeded(command_line, process_type); #if !defined(OFFICIAL_BUILD) diff --git a/content/browser/browser_main_runner.cc b/content/browser/browser_main_runner.cc index 8d4aca9e55419d..f959968f579de3 100644 --- a/content/browser/browser_main_runner.cc +++ b/content/browser/browser_main_runner.cc @@ -8,11 +8,11 @@ #include "base/command_line.h" #include "base/debug/debugger.h" #include "base/debug/leak_annotations.h" +#include "base/lazy_instance.h" #include "base/logging.h" #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/metrics/histogram_macros.h" -#include "base/metrics/statistics_recorder.h" #include "base/run_loop.h" #include "base/time/time.h" #include "base/trace_event/heap_profiler_allocation_context_tracker.h" @@ -80,8 +80,6 @@ class BrowserMainRunnerImpl : public BrowserMainRunner { if (parameters.command_line.HasSwitch(switches::kBrowserStartupDialog)) WaitForDebugger("Browser"); - base::StatisticsRecorder::Initialize(); - notification_service_.reset(new NotificationServiceImpl); #if defined(OS_WIN) diff --git a/content/child/child_process.cc b/content/child/child_process.cc index 9ab78bd0cfab97..835a59e685a043 100644 --- a/content/child/child_process.cc +++ b/content/child/child_process.cc @@ -9,7 +9,6 @@ #include "base/bind.h" #include "base/lazy_instance.h" #include "base/message_loop/message_loop.h" -#include "base/metrics/statistics_recorder.h" #include "base/process/process_handle.h" #include "base/single_thread_task_runner.h" #include "base/task_scheduler/task_scheduler.h" @@ -36,8 +35,6 @@ ChildProcess::ChildProcess( DCHECK(!g_lazy_tls.Pointer()->Get()); g_lazy_tls.Pointer()->Set(this); - base::StatisticsRecorder::Initialize(); - // Initialize TaskScheduler if not already done. A TaskScheduler may already // exist when ChildProcess is instantiated in the browser process or in a // test process. diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc index fbb53787866aa0..919e7fc665348a 100644 --- a/content/gpu/gpu_main.cc +++ b/content/gpu/gpu_main.cc @@ -11,7 +11,6 @@ #include "base/lazy_instance.h" #include "base/message_loop/message_loop.h" #include "base/metrics/histogram_macros.h" -#include "base/metrics/statistics_recorder.h" #include "base/rand_util.h" #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" @@ -274,9 +273,6 @@ int GpuMain(const MainFunctionParams& parameters) { base::PlatformThread::SetName("CrGpuMain"); - // Initializes StatisticsRecorder which tracks UMA histograms. - base::StatisticsRecorder::Initialize(); - #if defined(OS_ANDROID) || defined(OS_CHROMEOS) // Set thread priority before sandbox initialization. base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::DISPLAY); diff --git a/content/public/test/content_test_suite_base.cc b/content/public/test/content_test_suite_base.cc index deb889256689ec..a1f0f0abad7559 100644 --- a/content/public/test/content_test_suite_base.cc +++ b/content/public/test/content_test_suite_base.cc @@ -7,7 +7,6 @@ #include #include "base/compiler_specific.h" -#include "base/metrics/statistics_recorder.h" #include "base/test/test_suite.h" #include "base/threading/sequenced_worker_pool.h" #include "build/build_config.h" @@ -40,11 +39,6 @@ ContentTestSuiteBase::ContentTestSuiteBase(int argc, char** argv) void ContentTestSuiteBase::Initialize() { base::TestSuite::Initialize(); - // Initialize the histograms subsystem, so that any histograms hit in tests - // are correctly registered with the statistics recorder and can be queried - // by tests. - base::StatisticsRecorder::Initialize(); - #if defined(V8_USE_EXTERNAL_STARTUP_DATA) gin::V8Initializer::LoadV8Snapshot(); gin::V8Initializer::LoadV8Natives(); diff --git a/content/renderer/renderer_main.cc b/content/renderer/renderer_main.cc index 89161707d5faf5..b3d66e52386978 100644 --- a/content/renderer/renderer_main.cc +++ b/content/renderer/renderer_main.cc @@ -12,7 +12,6 @@ #include "base/i18n/rtl.h" #include "base/message_loop/message_loop.h" #include "base/metrics/histogram_macros.h" -#include "base/metrics/statistics_recorder.h" #include "base/pending_task.h" #include "base/run_loop.h" #include "base/strings/string_util.h" @@ -168,9 +167,6 @@ int RendererMain(const MainFunctionParams& parameters) { bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); - // Initialize histogram statistics gathering system. - base::StatisticsRecorder::Initialize(); - #if defined(OS_ANDROID) // If we have any pending LibraryLoader histograms, record them. base::android::RecordLibraryLoaderRendererHistograms(); diff --git a/dbus/signal_sender_verification_unittest.cc b/dbus/signal_sender_verification_unittest.cc index 3a5f299ab8ed47..00a1138d257b48 100644 --- a/dbus/signal_sender_verification_unittest.cc +++ b/dbus/signal_sender_verification_unittest.cc @@ -8,7 +8,6 @@ #include "base/message_loop/message_loop.h" #include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_samples.h" -#include "base/metrics/statistics_recorder.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/test/test_timeouts.h" @@ -31,8 +30,6 @@ class SignalSenderVerificationTest : public testing::Test { } void SetUp() override { - base::StatisticsRecorder::Initialize(); - // Make the main thread not to allow IO. base::ThreadRestrictions::SetIOAllowed(false); diff --git a/ios/chrome/test/app/histogram_test_util.h b/ios/chrome/test/app/histogram_test_util.h index 42a1ced7a8e8f8..6f00337ac5aeb4 100644 --- a/ios/chrome/test/app/histogram_test_util.h +++ b/ios/chrome/test/app/histogram_test_util.h @@ -33,8 +33,7 @@ class HistogramTester { public: using CountsMap = std::map; - // The constructor will call StatisticsRecorder::Initialize() for you. Also, - // this takes a snapshot of all current histograms counts. + // Takes a snapshot of all current histograms counts. HistogramTester(); ~HistogramTester(); diff --git a/ios/chrome/test/app/histogram_test_util.mm b/ios/chrome/test/app/histogram_test_util.mm index ac5e62e7fbac3b..0eb0738cd980b2 100644 --- a/ios/chrome/test/app/histogram_test_util.mm +++ b/ios/chrome/test/app/histogram_test_util.mm @@ -34,8 +34,6 @@ namespace chrome_test_util { HistogramTester::HistogramTester() { - base::StatisticsRecorder::Initialize(); // Safe to call multiple times. - // Record any histogram data that exists when the object is created so it can // be subtracted later. base::StatisticsRecorder::Histograms histograms; diff --git a/ios/web/public/global_state/ios_global_state.mm b/ios/web/public/global_state/ios_global_state.mm index 150f78dbfbf3b5..41b35e8d12cd14 100644 --- a/ios/web/public/global_state/ios_global_state.mm +++ b/ios/web/public/global_state/ios_global_state.mm @@ -8,7 +8,6 @@ #include "base/command_line.h" #include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" -#include "base/metrics/statistics_recorder.h" #include "base/task_scheduler/initialization_util.h" #include "net/base/network_change_notifier.h" @@ -54,8 +53,6 @@ void Create(const CreateParams& create_params) { base::TaskScheduler::Create(""); base::CommandLine::Init(create_params.argc, create_params.argv); - - base::StatisticsRecorder::Initialize(); }); } diff --git a/ios/web/test/web_test_suite.mm b/ios/web/test/web_test_suite.mm index a201277919b971..f27819ed7d2a00 100644 --- a/ios/web/test/web_test_suite.mm +++ b/ios/web/test/web_test_suite.mm @@ -5,7 +5,6 @@ #include "ios/web/public/test/web_test_suite.h" #include "base/memory/ptr_util.h" -#include "base/metrics/statistics_recorder.h" #include "base/path_service.h" #import "ios/web/public/test/fakes/test_web_client.h" #include "ios/web/public/url_schemes.h" @@ -27,11 +26,6 @@ void WebTestSuite::Initialize() { base::TestSuite::Initialize(); - // Initialize the histograms subsystem, so that any histograms hit in tests - // are correctly registered with the statistics recorder and can be queried - // by tests. - base::StatisticsRecorder::Initialize(); - RegisterWebSchemes(false); // Force unittests to run using en-US so if testing string output will work diff --git a/media/test/pipeline_integration_fuzzertest.cc b/media/test/pipeline_integration_fuzzertest.cc index d2f01da9b9a9dd..348cf82495cd78 100644 --- a/media/test/pipeline_integration_fuzzertest.cc +++ b/media/test/pipeline_integration_fuzzertest.cc @@ -12,7 +12,6 @@ #include "base/command_line.h" #include "base/location.h" #include "base/logging.h" -#include "base/metrics/statistics_recorder.h" #include "base/threading/thread_task_runner_handle.h" #include "media/base/bind_to_current_loop.h" #include "media/base/eme_constants.h" @@ -221,11 +220,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { // Media pipeline starts new threads, which needs AtExitManager. base::AtExitManager at_exit; - // Required to avoid leaking histogram memory over long fuzzing runs. Must be - // installed before any histograms are acquired. This is safe to call multiple - // times. - base::StatisticsRecorder::Initialize(); - // Media pipeline checks command line arguments internally. base::CommandLine::Init(0, nullptr); diff --git a/media/test/run_all_unittests.cc b/media/test/run_all_unittests.cc index ac2abc6c6fc695..bfd3ed4ded8148 100644 --- a/media/test/run_all_unittests.cc +++ b/media/test/run_all_unittests.cc @@ -4,7 +4,6 @@ #include "base/bind.h" #include "base/command_line.h" -#include "base/metrics/statistics_recorder.h" #include "base/test/launcher/unit_test_launcher.h" #include "base/test/test_discardable_memory_allocator.h" #include "base/test/test_suite.h" @@ -34,9 +33,6 @@ void TestSuiteNoAtExit::Initialize() { // Run TestSuite::Initialize first so that logging is initialized. base::TestSuite::Initialize(); - // Ensure histograms hit during tests are registered properly. - base::StatisticsRecorder::Initialize(); - base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); command_line->AppendSwitch(switches::kEnableInbandTextTracks); diff --git a/net/base/fuzzer_test_support.cc b/net/base/fuzzer_test_support.cc index 8e10957bfc5fd2..f2a54d51686f0b 100644 --- a/net/base/fuzzer_test_support.cc +++ b/net/base/fuzzer_test_support.cc @@ -6,7 +6,6 @@ #include "base/command_line.h" #include "base/i18n/icu_util.h" #include "base/logging.h" -#include "base/metrics/statistics_recorder.h" #include "base/test/scoped_task_environment.h" namespace { @@ -26,10 +25,6 @@ struct InitGlobals { // asserting when handling non-ASCII urls. CHECK(base::i18n::InitializeICU()); - // Prevent every call to get a Histogram* from leaking memory. Instead, only - // the fist call to get each Histogram* leaks memory. - base::StatisticsRecorder::Initialize(); - // Disable noisy logging as per "libFuzzer in Chrome" documentation: // testing/libfuzzer/getting_started.md#Disable-noisy-error-message-logging. logging::SetMinLogLevel(logging::LOG_FATAL); diff --git a/net/test/run_all_unittests.cc b/net/test/run_all_unittests.cc index 7ba6b98ad76811..635c4099e9b51e 100644 --- a/net/test/run_all_unittests.cc +++ b/net/test/run_all_unittests.cc @@ -2,8 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include + #include "base/build_time.h" -#include "base/metrics/statistics_recorder.h" #include "base/test/launcher/unit_test_launcher.h" #include "build/build_config.h" #include "crypto/nss_util.h" @@ -50,9 +51,6 @@ bool VerifyBuildIsTimely() { } // namespace int main(int argc, char** argv) { - // Record histograms, so we can get histograms data in tests. - base::StatisticsRecorder::Initialize(); - if (!VerifyBuildIsTimely()) return 1; diff --git a/services/preferences/tracked/pref_hash_filter_unittest.cc b/services/preferences/tracked/pref_hash_filter_unittest.cc index 1f85f718c0e6a4..f3912dd869ee24 100644 --- a/services/preferences/tracked/pref_hash_filter_unittest.cc +++ b/services/preferences/tracked/pref_hash_filter_unittest.cc @@ -549,7 +549,6 @@ class PrefHashFilterTest : public testing::TestWithParam, reset_recorded_(false) {} void SetUp() override { - base::StatisticsRecorder::Initialize(); Reset(); } diff --git a/sql/test/sql_test_suite.cc b/sql/test/sql_test_suite.cc index e7743280bfdd8f..2b6d750a002f1a 100644 --- a/sql/test/sql_test_suite.cc +++ b/sql/test/sql_test_suite.cc @@ -4,7 +4,6 @@ #include "sql/test/sql_test_suite.h" -#include "base/metrics/statistics_recorder.h" #include "sql/test/paths.h" namespace sql { @@ -16,12 +15,6 @@ SQLTestSuite::~SQLTestSuite() = default; void SQLTestSuite::Initialize() { base::TestSuite::Initialize(); - - // Initialize the histograms subsystem, so that any histograms hit in tests - // are correctly registered with the statistics recorder and can be queried - // by tests. - base::StatisticsRecorder::Initialize(); - sql::test::RegisterPathProvider(); } diff --git a/testing/libfuzzer/fuzzers/language_detection_fuzzer.cc b/testing/libfuzzer/fuzzers/language_detection_fuzzer.cc index c87e07efcccfc5..1545f76aff923a 100644 --- a/testing/libfuzzer/fuzzers/language_detection_fuzzer.cc +++ b/testing/libfuzzer/fuzzers/language_detection_fuzzer.cc @@ -7,7 +7,6 @@ #include -#include "base/metrics/statistics_recorder.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "components/translate/core/language_detection/language_detection_util.h" @@ -36,11 +35,3 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { &is_cld_reliable); return 0; } - -struct Environment { - Environment() { - base::StatisticsRecorder::Initialize(); - } -}; - -Environment* env = new Environment(); diff --git a/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp b/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp index 37065ebe49d755..a4c3db14a66bd5 100644 --- a/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp +++ b/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp @@ -33,7 +33,6 @@ #include #include "base/command_line.h" #include "base/memory/discardable_memory_allocator.h" -#include "base/metrics/statistics_recorder.h" #include "base/run_loop.h" #include "base/test/icu_test_util.h" #include "base/test/test_discardable_memory_allocator.h" @@ -228,7 +227,6 @@ ScopedUnittestsEnvironmentSetup::ScopedUnittestsEnvironmentSetup(int argc, WTF::WrapUnique(new base::TestDiscardableMemoryAllocator); base::DiscardableMemoryAllocator::SetInstance( discardable_memory_allocator_.get()); - base::StatisticsRecorder::Initialize(); dummy_platform_ = WTF::WrapUnique(new DummyPlatform); Platform::SetCurrentPlatformForTesting(dummy_platform_.get());