| 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/histogram.h" | 5 #include "base/metrics/histogram.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 EXPECT_NE(0U, allocator_->GetNextIterable(&iter, &type)); // CustomHistogram | 182 EXPECT_NE(0U, allocator_->GetNextIterable(&iter, &type)); // CustomHistogram |
| 183 EXPECT_EQ(0U, allocator_->GetNextIterable(&iter, &type)); | 183 EXPECT_EQ(0U, allocator_->GetNextIterable(&iter, &type)); |
| 184 | 184 |
| 185 // Create a second allocator and have it access the memory of the first. | 185 // Create a second allocator and have it access the memory of the first. |
| 186 scoped_ptr<HistogramBase> recovered; | 186 scoped_ptr<HistogramBase> recovered; |
| 187 PersistentMemoryAllocator recovery( | 187 PersistentMemoryAllocator recovery( |
| 188 allocator_memory_.get(), kAllocatorMemorySize, 0, | 188 allocator_memory_.get(), kAllocatorMemorySize, 0, |
| 189 0, std::string(), false); | 189 0, std::string(), false); |
| 190 recovery.CreateIterator(&iter); | 190 recovery.CreateIterator(&iter); |
| 191 | 191 |
| 192 recovered.reset(GetNextPersistentHistogram(&recovery, &iter)); | 192 recovered = GetNextPersistentHistogram(&recovery, &iter); |
| 193 ASSERT_TRUE(recovered); | 193 ASSERT_TRUE(recovered); |
| 194 recovered->CheckName("TestHistogram"); | 194 recovered->CheckName("TestHistogram"); |
| 195 | 195 |
| 196 recovered.reset(GetNextPersistentHistogram(&recovery, &iter)); | 196 recovered = GetNextPersistentHistogram(&recovery, &iter); |
| 197 ASSERT_TRUE(recovered); | 197 ASSERT_TRUE(recovered); |
| 198 recovered->CheckName("TestLinearHistogram"); | 198 recovered->CheckName("TestLinearHistogram"); |
| 199 | 199 |
| 200 recovered.reset(GetNextPersistentHistogram(&recovery, &iter)); | 200 recovered = GetNextPersistentHistogram(&recovery, &iter); |
| 201 ASSERT_TRUE(recovered); | 201 ASSERT_TRUE(recovered); |
| 202 recovered->CheckName("TestBooleanHistogram"); | 202 recovered->CheckName("TestBooleanHistogram"); |
| 203 | 203 |
| 204 recovered.reset(GetNextPersistentHistogram(&recovery, &iter)); | 204 recovered = GetNextPersistentHistogram(&recovery, &iter); |
| 205 ASSERT_TRUE(recovered); | 205 ASSERT_TRUE(recovered); |
| 206 recovered->CheckName("TestCustomHistogram"); | 206 recovered->CheckName("TestCustomHistogram"); |
| 207 | 207 |
| 208 recovered.reset(GetNextPersistentHistogram(&recovery, &iter)); | 208 recovered = GetNextPersistentHistogram(&recovery, &iter); |
| 209 EXPECT_FALSE(recovered); | 209 EXPECT_FALSE(recovered); |
| 210 | 210 |
| 211 // Use standard macros (but with fixed samples) | 211 // Use standard macros (but with fixed samples) |
| 212 LOCAL_HISTOGRAM_TIMES("Test2Histogram", TimeDelta::FromDays(1)); | 212 LOCAL_HISTOGRAM_TIMES("Test2Histogram", TimeDelta::FromDays(1)); |
| 213 LOCAL_HISTOGRAM_COUNTS("Test3Histogram", 30); | 213 LOCAL_HISTOGRAM_COUNTS("Test3Histogram", 30); |
| 214 LOCAL_HISTOGRAM_ENUMERATION("Test6Histogram", 129, 130); | 214 LOCAL_HISTOGRAM_ENUMERATION("Test6Histogram", 129, 130); |
| 215 } | 215 } |
| 216 | 216 |
| 217 // Check that the macro correctly matches histograms by name and records their | 217 // Check that the macro correctly matches histograms by name and records their |
| 218 // data together. | 218 // data together. |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 // CustomHistogram needs at least 1 valid range. | 797 // CustomHistogram needs at least 1 valid range. |
| 798 custom_ranges.clear(); | 798 custom_ranges.clear(); |
| 799 custom_ranges.push_back(0); | 799 custom_ranges.push_back(0); |
| 800 EXPECT_DEATH(CustomHistogram::FactoryGet("BadRangesCustom3", custom_ranges, | 800 EXPECT_DEATH(CustomHistogram::FactoryGet("BadRangesCustom3", custom_ranges, |
| 801 HistogramBase::kNoFlags), | 801 HistogramBase::kNoFlags), |
| 802 ""); | 802 ""); |
| 803 } | 803 } |
| 804 #endif | 804 #endif |
| 805 | 805 |
| 806 } // namespace base | 806 } // namespace base |
| OLD | NEW |