Chromium Code Reviews| Index: base/metrics/histogram_persistence.cc |
| diff --git a/base/metrics/histogram_persistence.cc b/base/metrics/histogram_persistence.cc |
| index 7c60079ef9ced823ea06d16470e5ff14780ed7a4..9166be027be17bb8ad1babd75fe2a604914b88a9 100644 |
| --- a/base/metrics/histogram_persistence.cc |
| +++ b/base/metrics/histogram_persistence.cc |
| @@ -222,11 +222,14 @@ HistogramBase* CreatePersistentHistogram( |
| histogram_data.counts_ref, kTypeIdCountsArray); |
| if (!counts_data || |
| allocator->GetAllocSize(histogram_data.counts_ref) < |
| - histogram_data.bucket_count * sizeof(HistogramBase::AtomicCount)) { |
| + 2 * histogram_data.bucket_count * |
| + sizeof(HistogramBase::AtomicCount)) { |
|
Alexei Svitkine (slow)
2016/02/09 19:46:51
Nit: Can you make a variable to store the size and
bcwhite
2016/02/11 16:42:38
Done.
|
| RecordCreateHistogramResult(CREATE_HISTOGRAM_INVALID_COUNTS_ARRAY); |
| NOTREACHED(); |
| return nullptr; |
| } |
| + HistogramBase::AtomicCount* logged_data = |
|
Alexei Svitkine (slow)
2016/02/09 19:46:51
Add a comment mentioning the second half of the co
bcwhite
2016/02/11 16:42:38
Done.
|
| + counts_data + histogram_data.bucket_count; |
| std::string name(histogram_data_ptr->name); |
| HistogramBase* histogram = nullptr; |
| @@ -238,6 +241,7 @@ HistogramBase* CreatePersistentHistogram( |
| histogram_data.maximum, |
| ranges, |
| counts_data, |
| + logged_data, |
| histogram_data.bucket_count, |
| &histogram_data_ptr->samples_metadata); |
| DCHECK(histogram); |
| @@ -249,6 +253,7 @@ HistogramBase* CreatePersistentHistogram( |
| histogram_data.maximum, |
| ranges, |
| counts_data, |
| + logged_data, |
| histogram_data.bucket_count, |
| &histogram_data_ptr->samples_metadata); |
| DCHECK(histogram); |
| @@ -258,6 +263,7 @@ HistogramBase* CreatePersistentHistogram( |
| name, |
| ranges, |
| counts_data, |
| + logged_data, |
| &histogram_data_ptr->samples_metadata); |
| DCHECK(histogram); |
| break; |
| @@ -266,6 +272,7 @@ HistogramBase* CreatePersistentHistogram( |
| name, |
| ranges, |
| counts_data, |
| + logged_data, |
| histogram_data.bucket_count, |
| &histogram_data_ptr->samples_metadata); |
| DCHECK(histogram); |
| @@ -351,7 +358,10 @@ HistogramBase* AllocatePersistentHistogram( |
| NOTREACHED(); |
| return nullptr; |
| } |
| - size_t counts_bytes = bucket_count * sizeof(HistogramBase::AtomicCount); |
| + |
| + // Allocate persistent memory for 2x bucket counts (one for "live" and one |
| + // for "logged") and memory for bucket ranges. |
| + size_t counts_bytes = 2 * bucket_count * sizeof(HistogramBase::AtomicCount); |
| size_t ranges_bytes = (bucket_count + 1) * sizeof(HistogramBase::Sample); |
| PersistentMemoryAllocator::Reference ranges_ref = |
| allocator->Allocate(ranges_bytes, kTypeIdRangesArray); |