OLD | NEW |
---|---|
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_persistence.h" | 5 #include "base/metrics/histogram_persistence.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 result_histogram->Add(result); | 180 result_histogram->Add(result); |
181 } | 181 } |
182 | 182 |
183 void SetPersistentHistogramMemoryAllocator( | 183 void SetPersistentHistogramMemoryAllocator( |
184 PersistentMemoryAllocator* allocator) { | 184 PersistentMemoryAllocator* allocator) { |
185 // Releasing or changing an allocator is extremely dangerous because it | 185 // Releasing or changing an allocator is extremely dangerous because it |
186 // likely has histograms stored within it. If the backing memory is also | 186 // likely has histograms stored within it. If the backing memory is also |
187 // also released, future accesses to those histograms will seg-fault. | 187 // also released, future accesses to those histograms will seg-fault. |
188 CHECK(!g_allocator); | 188 CHECK(!g_allocator); |
189 g_allocator = allocator; | 189 g_allocator = allocator; |
190 | |
191 size_t existing = StatisticsRecorder::GetHistogramCount(); | |
192 if (existing != 0) { | |
193 DLOG(WARNING) << existing | |
grt (UTC plus 2)
2016/03/09 04:04:43
DLOG_IF(WARNING, existing) << ...
bcwhite
2016/03/09 14:01:57
Didn't know about that one. Will do.
bcwhite
2016/03/09 16:04:26
Done.
| |
194 << " histograms were created before persistence was enabled."; | |
195 } | |
190 } | 196 } |
191 | 197 |
192 PersistentMemoryAllocator* GetPersistentHistogramMemoryAllocator() { | 198 PersistentMemoryAllocator* GetPersistentHistogramMemoryAllocator() { |
193 return g_allocator; | 199 return g_allocator; |
194 } | 200 } |
195 | 201 |
196 PersistentMemoryAllocator* | 202 PersistentMemoryAllocator* |
197 ReleasePersistentHistogramMemoryAllocatorForTesting() { | 203 ReleasePersistentHistogramMemoryAllocatorForTesting() { |
198 PersistentMemoryAllocator* allocator = g_allocator; | 204 PersistentMemoryAllocator* allocator = g_allocator; |
199 if (!allocator) | 205 if (!allocator) |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 while (true) { | 513 while (true) { |
508 HistogramBase* histogram = GetNextPersistentHistogram(g_allocator, &iter); | 514 HistogramBase* histogram = GetNextPersistentHistogram(g_allocator, &iter); |
509 if (!histogram) | 515 if (!histogram) |
510 break; | 516 break; |
511 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram); | 517 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram); |
512 } | 518 } |
513 } | 519 } |
514 } | 520 } |
515 | 521 |
516 } // namespace base | 522 } // namespace base |
OLD | NEW |