Skip to content

Commit

Permalink
Removed StatisticsRecorder::Initialize and StatisticsRecorder::IsActive.
Browse files Browse the repository at this point in the history
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 <fdegros@chromium.org>
Reviewed-by: Julia Tuttle <juliatuttle@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Bartosz Fabianowski <bartfab@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: Luke Halliwell <halliwell@chromium.org>
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#527562}
  • Loading branch information
fdegros authored and Commit Bot committed Jan 8, 2018
1 parent faeba39 commit 13e8d06
Show file tree
Hide file tree
Showing 49 changed files with 6 additions and 203 deletions.
3 changes: 0 additions & 3 deletions ash/test/ash_test_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class RecordHistogramTest {
@Before
public void setUp() throws Exception {
LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized();
RecordHistogram.initialize();
}

/**
Expand Down
4 changes: 0 additions & 4 deletions base/android/record_histogram.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,6 @@ jlong JNI_RecordHistogram_RecordCustomTimesHistogramMilliseconds(
return reinterpret_cast<jlong>(histogram);
}

void JNI_RecordHistogram_Initialize(JNIEnv* env, const JavaParamRef<jclass>&) {
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
Expand Down
3 changes: 0 additions & 3 deletions base/metrics/persistent_histogram_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1090,9 +1090,6 @@ GlobalHistogramAllocator::GlobalHistogramAllocator(
std::unique_ptr<PersistentMemoryAllocator> 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() {
Expand Down
7 changes: 0 additions & 7 deletions base/metrics/statistics_recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions base/test/histogram_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions base/test/histogram_tester.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class HistogramTester {
public:
using CountsMap = std::map<std::string, HistogramBase::Count>;

// 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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
5 changes: 0 additions & 5 deletions chrome/app/chrome_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class NetworkPortalDetectorImplTest
base::WrapUnique(user_manager));

DBusThreadManager::Initialize();
base::StatisticsRecorder::Initialize();
SetupNetworkHandler();

ASSERT_TRUE(test_profile_manager_.SetUp());
Expand Down
4 changes: 0 additions & 4 deletions chrome/browser/mac/exception_processor_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,6 @@ CloudPolicyInvalidatorUserTypedTest::~CloudPolicyInvalidatorUserTypedTest() {
}

void CloudPolicyInvalidatorUserTypedTest::SetUp() {
base::StatisticsRecorder::Initialize();
refresh_samples_ = GetHistogramSamples(
GetPolicyType() == em::DeviceRegisterRequest::DEVICE ?
kMetricDevicePolicyRefresh : kMetricUserPolicyRefresh);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
27 changes: 0 additions & 27 deletions chrome/browser/ui/search/ntp_user_data_logger_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <vector>

#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"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -107,8 +104,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordNumberOfTiles) {
}

TEST(NTPUserDataLoggerTest, ShouldNotRecordImpressionsBeforeAllTilesLoaded) {
base::StatisticsRecorder::Initialize();

TestNTPUserDataLogger logger(GURL("chrome://newtab/"));

base::HistogramTester histogram_tester;
Expand Down Expand Up @@ -145,8 +140,6 @@ TEST(NTPUserDataLoggerTest, ShouldNotRecordImpressionsBeforeAllTilesLoaded) {
}

TEST(NTPUserDataLoggerTest, ShouldRecordImpressions) {
base::StatisticsRecorder::Initialize();

TestNTPUserDataLogger logger(GURL("chrome://newtab/"));

base::HistogramTester histogram_tester;
Expand Down Expand Up @@ -231,8 +224,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordImpressions) {
}

TEST(NTPUserDataLoggerTest, ShouldNotRecordRepeatedImpressions) {
base::StatisticsRecorder::Initialize();

TestNTPUserDataLogger logger(GURL("chrome://newtab/"));

base::HistogramTester histogram_tester;
Expand Down Expand Up @@ -296,8 +287,6 @@ TEST(NTPUserDataLoggerTest, ShouldNotRecordRepeatedImpressions) {
}

TEST(NTPUserDataLoggerTest, ShouldNotRecordImpressionsForBinsBeyondEight) {
base::StatisticsRecorder::Initialize();

TestNTPUserDataLogger logger(GURL("chrome://newtab/"));

base::HistogramTester histogram_tester;
Expand Down Expand Up @@ -346,8 +335,6 @@ TEST(NTPUserDataLoggerTest, ShouldNotRecordImpressionsForBinsBeyondEight) {
}

TEST(NTPUserDataLoggerTest, ShouldRecordImpressionsAgainAfterNavigating) {
base::StatisticsRecorder::Initialize();

TestNTPUserDataLogger logger(GURL("chrome://newtab/"));

// Record some previous tile impressions.
Expand Down Expand Up @@ -426,8 +413,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordImpressionsAgainAfterNavigating) {
}

TEST(NTPUserDataLoggerTest, ShouldRecordNavigations) {
base::StatisticsRecorder::Initialize();

TestNTPUserDataLogger logger(GURL("chrome://newtab/"));

{
Expand Down Expand Up @@ -603,8 +588,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordNavigations) {
}

TEST(NTPUserDataLoggerTest, ShouldRecordLoadTime) {
base::StatisticsRecorder::Initialize();

base::HistogramTester histogram_tester;

TestNTPUserDataLogger logger(GURL("chrome://newtab/"));
Expand Down Expand Up @@ -697,8 +680,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordLoadTime) {
}

TEST(NTPUserDataLoggerTest, ShouldRecordLoadTimeLocalNTPGoogle) {
base::StatisticsRecorder::Initialize();

base::HistogramTester histogram_tester;

TestNTPUserDataLogger logger((GURL(chrome::kChromeSearchLocalNtpUrl)));
Expand Down Expand Up @@ -734,8 +715,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordLoadTimeLocalNTPGoogle) {
}

TEST(NTPUserDataLoggerTest, ShouldRecordLoadTimeLocalNTPOther) {
base::StatisticsRecorder::Initialize();

base::HistogramTester histogram_tester;

TestNTPUserDataLogger logger((GURL(chrome::kChromeSearchLocalNtpUrl)));
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -841,8 +816,6 @@ TEST(NTPUserDataLoggerTest, ShouldRecordLoadTimeRemoteNTPOther) {
}

TEST(NTPUserDataLoggerTest, ShouldRecordImpressionsAge) {
base::StatisticsRecorder::Initialize();

base::HistogramTester histogram_tester;

// Ensure non-zero statistics.
Expand Down
3 changes: 0 additions & 3 deletions chrome/renderer/net/net_error_helper_core_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions chrome/service/service_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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<ServiceProcessState> state(new ServiceProcessState);
if (!state->Initialize())
Expand Down
2 changes: 0 additions & 2 deletions chromecast/base/metrics/grouped_histogram.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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,
Expand Down
Loading

0 comments on commit 13e8d06

Please sign in to comment.