| 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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 void UninitializeStatisticsRecorder() { | 30 void UninitializeStatisticsRecorder() { |
| 31 delete statistics_recorder_; | 31 delete statistics_recorder_; |
| 32 statistics_recorder_ = NULL; | 32 statistics_recorder_ = NULL; |
| 33 } | 33 } |
| 34 | 34 |
| 35 Histogram* CreateHistogram(const std::string& name, | 35 Histogram* CreateHistogram(const std::string& name, |
| 36 HistogramBase::Sample min, | 36 HistogramBase::Sample min, |
| 37 HistogramBase::Sample max, | 37 HistogramBase::Sample max, |
| 38 size_t bucket_count) { | 38 size_t bucket_count) { |
| 39 return new Histogram(name, min, max, bucket_count, NULL); | 39 BucketRanges* ranges = new BucketRanges(bucket_count + 1); |
| 40 Histogram::InitializeBucketRanges(min, max, ranges); |
| 41 const BucketRanges* registered_ranges = |
| 42 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges); |
| 43 return new Histogram(name, min, max, registered_ranges); |
| 40 } | 44 } |
| 41 | 45 |
| 42 void DeleteHistogram(HistogramBase* histogram) { | 46 void DeleteHistogram(HistogramBase* histogram) { |
| 43 delete histogram; | 47 delete histogram; |
| 44 } | 48 } |
| 45 | 49 |
| 46 StatisticsRecorder* statistics_recorder_; | 50 StatisticsRecorder* statistics_recorder_; |
| 47 }; | 51 }; |
| 48 | 52 |
| 49 TEST_F(StatisticsRecorderTest, NotInitialized) { | 53 TEST_F(StatisticsRecorderTest, NotInitialized) { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 EXPECT_EQ(1u, ranges.size()); | 257 EXPECT_EQ(1u, ranges.size()); |
| 254 | 258 |
| 255 Histogram::FactoryGet("Histogram3", 1, 64, 16, HistogramBase::kNoFlags); | 259 Histogram::FactoryGet("Histogram3", 1, 64, 16, HistogramBase::kNoFlags); |
| 256 | 260 |
| 257 ranges.clear(); | 261 ranges.clear(); |
| 258 StatisticsRecorder::GetBucketRanges(&ranges); | 262 StatisticsRecorder::GetBucketRanges(&ranges); |
| 259 EXPECT_EQ(2u, ranges.size()); | 263 EXPECT_EQ(2u, ranges.size()); |
| 260 } | 264 } |
| 261 | 265 |
| 262 } // namespace base | 266 } // namespace base |
| OLD | NEW |