| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/persistent_histogram_allocator.h" | 5 #include "base/metrics/persistent_histogram_allocator.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 // static | 653 // static |
| 654 void GlobalHistogramAllocator::Set( | 654 void GlobalHistogramAllocator::Set( |
| 655 std::unique_ptr<GlobalHistogramAllocator> allocator) { | 655 std::unique_ptr<GlobalHistogramAllocator> allocator) { |
| 656 // Releasing or changing an allocator is extremely dangerous because it | 656 // Releasing or changing an allocator is extremely dangerous because it |
| 657 // likely has histograms stored within it. If the backing memory is also | 657 // likely has histograms stored within it. If the backing memory is also |
| 658 // also released, future accesses to those histograms will seg-fault. | 658 // also released, future accesses to those histograms will seg-fault. |
| 659 CHECK(!g_allocator); | 659 CHECK(!g_allocator); |
| 660 g_allocator = allocator.release(); | 660 g_allocator = allocator.release(); |
| 661 size_t existing = StatisticsRecorder::GetHistogramCount(); | 661 size_t existing = StatisticsRecorder::GetHistogramCount(); |
| 662 | 662 |
| 663 DLOG_IF(WARNING, existing) | 663 DVLOG_IF(1, existing) |
| 664 << existing << " histograms were created before persistence was enabled."; | 664 << existing << " histograms were created before persistence was enabled."; |
| 665 } | 665 } |
| 666 | 666 |
| 667 // static | 667 // static |
| 668 GlobalHistogramAllocator* GlobalHistogramAllocator::Get() { | 668 GlobalHistogramAllocator* GlobalHistogramAllocator::Get() { |
| 669 return g_allocator; | 669 return g_allocator; |
| 670 } | 670 } |
| 671 | 671 |
| 672 // static | 672 // static |
| 673 std::unique_ptr<GlobalHistogramAllocator> | 673 std::unique_ptr<GlobalHistogramAllocator> |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 while (true) { | 724 while (true) { |
| 725 std::unique_ptr<HistogramBase> histogram = | 725 std::unique_ptr<HistogramBase> histogram = |
| 726 import_iterator_.GetNextWithIgnore(record_to_ignore); | 726 import_iterator_.GetNextWithIgnore(record_to_ignore); |
| 727 if (!histogram) | 727 if (!histogram) |
| 728 break; | 728 break; |
| 729 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram.release()); | 729 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram.release()); |
| 730 } | 730 } |
| 731 } | 731 } |
| 732 | 732 |
| 733 } // namespace base | 733 } // namespace base |
| OLD | NEW |