| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/metrics/histogram_base.h" | 8 #include "base/metrics/histogram_base.h" |
| 9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
| 10 #include "base/metrics/statistics_recorder.h" | 10 #include "base/metrics/statistics_recorder.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 | 23 |
| 24 ~HistogramBaseTest() override { | 24 ~HistogramBaseTest() override { |
| 25 HistogramBase::report_histogram_ = nullptr; | 25 HistogramBase::report_histogram_ = nullptr; |
| 26 } | 26 } |
| 27 | 27 |
| 28 void ResetStatisticsRecorder() { | 28 void ResetStatisticsRecorder() { |
| 29 // It is necessary to fully destruct any existing StatisticsRecorder | 29 // It is necessary to fully destruct any existing StatisticsRecorder |
| 30 // before creating a new one. | 30 // before creating a new one. |
| 31 statistics_recorder_.reset(); | 31 statistics_recorder_.reset(); |
| 32 statistics_recorder_.reset(new StatisticsRecorder()); | 32 statistics_recorder_ = StatisticsRecorder::CreateTemporaryForTesting(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 HistogramBase* GetCreationReportHistogram(const std::string& name) { | 35 HistogramBase* GetCreationReportHistogram(const std::string& name) { |
| 36 HistogramBase::EnableActivityReportHistogram(name); | 36 HistogramBase::EnableActivityReportHistogram(name); |
| 37 return HistogramBase::report_histogram_; | 37 return HistogramBase::report_histogram_; |
| 38 } | 38 } |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 std::unique_ptr<StatisticsRecorder> statistics_recorder_; | 41 std::unique_ptr<StatisticsRecorder> statistics_recorder_; |
| 42 | 42 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 BooleanHistogram::FactoryGet("CRH-Boolean", 0); | 213 BooleanHistogram::FactoryGet("CRH-Boolean", 0); |
| 214 CustomHistogram::FactoryGet("CRH-Custom", ranges, 0); | 214 CustomHistogram::FactoryGet("CRH-Custom", ranges, 0); |
| 215 SparseHistogram::FactoryGet("CRH-Sparse", 0); | 215 SparseHistogram::FactoryGet("CRH-Sparse", 0); |
| 216 samples = report->SnapshotSamples(); | 216 samples = report->SnapshotSamples(); |
| 217 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_CREATED)); | 217 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_CREATED)); |
| 218 EXPECT_EQ(9, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_CREATED)); | 218 EXPECT_EQ(9, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_CREATED)); |
| 219 EXPECT_EQ(5, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_LOOKUP)); | 219 EXPECT_EQ(5, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_LOOKUP)); |
| 220 } | 220 } |
| 221 | 221 |
| 222 } // namespace base | 222 } // namespace base |
| OLD | NEW |