| 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 "base/metrics/statistics_recorder.h" | 5 #include "base/metrics/statistics_recorder.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 ~StatisticsRecorderTest() override { | 42 ~StatisticsRecorderTest() override { |
| 43 GlobalHistogramAllocator::ReleaseForTesting(); | 43 GlobalHistogramAllocator::ReleaseForTesting(); |
| 44 UninitializeStatisticsRecorder(); | 44 UninitializeStatisticsRecorder(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void InitializeStatisticsRecorder() { | 47 void InitializeStatisticsRecorder() { |
| 48 DCHECK(!statistics_recorder_); | 48 DCHECK(!statistics_recorder_); |
| 49 StatisticsRecorder::UninitializeForTesting(); | 49 StatisticsRecorder::UninitializeForTesting(); |
| 50 statistics_recorder_.reset(new StatisticsRecorder()); | 50 statistics_recorder_ = StatisticsRecorder::CreateTemporaryForTesting(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void UninitializeStatisticsRecorder() { | 53 void UninitializeStatisticsRecorder() { |
| 54 statistics_recorder_.reset(); | 54 statistics_recorder_.reset(); |
| 55 StatisticsRecorder::UninitializeForTesting(); | 55 StatisticsRecorder::UninitializeForTesting(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 Histogram* CreateHistogram(const std::string& name, | 58 Histogram* CreateHistogram(const std::string& name, |
| 59 HistogramBase::Sample min, | 59 HistogramBase::Sample min, |
| 60 HistogramBase::Sample max, | 60 HistogramBase::Sample max, |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 HistogramBase* histogram = Histogram::FactoryGet("TestHistogram", 1, 1000, 10, | 586 HistogramBase* histogram = Histogram::FactoryGet("TestHistogram", 1, 1000, 10, |
| 587 HistogramBase::kNoFlags); | 587 HistogramBase::kNoFlags); |
| 588 EXPECT_TRUE(histogram); | 588 EXPECT_TRUE(histogram); |
| 589 histogram->Add(1); | 589 histogram->Add(1); |
| 590 | 590 |
| 591 EXPECT_TRUE(callback_wrapper.called); | 591 EXPECT_TRUE(callback_wrapper.called); |
| 592 EXPECT_EQ(callback_wrapper.last_histogram_value, 1); | 592 EXPECT_EQ(callback_wrapper.last_histogram_value, 1); |
| 593 } | 593 } |
| 594 | 594 |
| 595 } // namespace base | 595 } // namespace base |
| OLD | NEW |