From 5e7d177ef264e7eab60b1eb6e3bf6678ddc76c8f Mon Sep 17 00:00:00 2001 From: Tommi Date: Mon, 30 Oct 2017 17:16:22 +0100 Subject: [PATCH] Remove references to and implementation of GetHistogramName(). The method prototype is being changed to returning a const char*, we don't rely on it in webrtc and the point of the DCHECK that previously referenced it, was to avoid usage of std::string for histogram names. Bug: webrtc:8472 Change-Id: I69b588d4a8f339911a051fd232d63ea5bb1f9a45 Reviewed-on: https://webrtc-review.googlesource.com/16940 Commit-Queue: Tommi Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#20484} --- system_wrappers/include/metrics.h | 6 ------ system_wrappers/source/metrics_default.cc | 5 ----- system_wrappers/source/metrics_unittest.cc | 12 ------------ 3 files changed, 23 deletions(-) diff --git a/system_wrappers/include/metrics.h b/system_wrappers/include/metrics.h index b8fbc7d168..6a6878ad9b 100644 --- a/system_wrappers/include/metrics.h +++ b/system_wrappers/include/metrics.h @@ -164,9 +164,6 @@ prev_pointer == histogram_pointer); \ } \ if (histogram_pointer) { \ - RTC_DCHECK_EQ(constant_name, \ - webrtc::metrics::GetHistogramName(histogram_pointer)) \ - << "The name should not vary."; \ webrtc::metrics::HistogramAdd(histogram_pointer, sample); \ } \ } while (0) @@ -262,9 +259,6 @@ Histogram* HistogramFactoryGetCountsLinear(const std::string& name, Histogram* HistogramFactoryGetEnumeration( const std::string& name, int boundary); -// Returns name of the histogram. -const std::string& GetHistogramName(Histogram* histogram_pointer); - // Function for adding a |sample| to a histogram. void HistogramAdd(Histogram* histogram_pointer, int sample); diff --git a/system_wrappers/source/metrics_default.cc b/system_wrappers/source/metrics_default.cc index 3263ec0ec8..fbb2956301 100644 --- a/system_wrappers/source/metrics_default.cc +++ b/system_wrappers/source/metrics_default.cc @@ -247,11 +247,6 @@ Histogram* HistogramFactoryGetEnumeration(const std::string& name, return map->GetEnumerationHistogram(name, boundary); } -const std::string& GetHistogramName(Histogram* histogram_pointer) { - RtcHistogram* ptr = reinterpret_cast(histogram_pointer); - return ptr->name(); -} - // Fast path. Adds |sample| to cached |histogram_pointer|. void HistogramAdd(Histogram* histogram_pointer, int sample) { RtcHistogram* ptr = reinterpret_cast(histogram_pointer); diff --git a/system_wrappers/source/metrics_unittest.cc b/system_wrappers/source/metrics_unittest.cc index 0eeda0da2a..fe909e821c 100644 --- a/system_wrappers/source/metrics_unittest.cc +++ b/system_wrappers/source/metrics_unittest.cc @@ -22,11 +22,6 @@ void AddSparseSample(const std::string& name, int sample) { void AddSampleWithVaryingName(int index, const std::string& name, int sample) { RTC_HISTOGRAMS_COUNTS_100(index, name, sample); } -#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) -void AddSample(const std::string& name, int sample) { - RTC_HISTOGRAM_COUNTS_100(name, sample); -} -#endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) } // namespace class MetricsTest : public ::testing::Test { @@ -117,11 +112,4 @@ TEST_F(MetricsTest, RtcHistogramSparse_NonConstantNameWorks) { EXPECT_EQ(1, metrics::NumSamples("Sparse2")); } -#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) -TEST_F(MetricsTest, RtcHistogram_FailsForNonConstantName) { - AddSample("ConstantName1", kSample); - EXPECT_DEATH(AddSample("NotConstantName1", kSample), ""); -} -#endif - } // namespace webrtc