Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: base/metrics/persistent_histogram_allocator.cc

Issue 1825143002: Revert of Collect information about failing histogram factory calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/metrics/metrics_hashes.cc ('k') | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 RecordCreateHistogramResult(CREATE_HISTOGRAM_SUCCESS); 288 RecordCreateHistogramResult(CREATE_HISTOGRAM_SUCCESS);
289 return histogram; 289 return histogram;
290 } 290 }
291 291
292 // Copy the histogram_data to local storage because anything in persistent 292 // Copy the histogram_data to local storage because anything in persistent
293 // memory cannot be trusted as it could be changed at any moment by a 293 // memory cannot be trusted as it could be changed at any moment by a
294 // malicious actor that shares access. The contents of histogram_data are 294 // malicious actor that shares access. The contents of histogram_data are
295 // validated below; the local copy is to ensure that the contents cannot 295 // validated below; the local copy is to ensure that the contents cannot
296 // be externally changed between validation and use. 296 // be externally changed between validation and use.
297 PersistentHistogramData histogram_data = *histogram_data_ptr; 297 PersistentHistogramData histogram_data = *histogram_data_ptr;
298 CHECK_EQ(histogram_data.histogram_type, histogram_data_ptr->histogram_type);
299 CHECK_EQ(histogram_data.flags, histogram_data_ptr->flags);
300 CHECK_EQ(histogram_data.minimum, histogram_data_ptr->minimum);
301 CHECK_EQ(histogram_data.maximum, histogram_data_ptr->maximum);
302 CHECK_EQ(histogram_data.bucket_count, histogram_data_ptr->bucket_count);
303 CHECK_EQ(histogram_data.ranges_checksum, histogram_data_ptr->ranges_checksum);
304 298
305 HistogramBase::Sample* ranges_data = 299 HistogramBase::Sample* ranges_data =
306 memory_allocator_->GetAsObject<HistogramBase::Sample>( 300 memory_allocator_->GetAsObject<HistogramBase::Sample>(
307 histogram_data.ranges_ref, kTypeIdRangesArray); 301 histogram_data.ranges_ref, kTypeIdRangesArray);
308 302
309 const uint32_t max_buckets = 303 const uint32_t max_buckets =
310 std::numeric_limits<uint32_t>::max() / sizeof(HistogramBase::Sample); 304 std::numeric_limits<uint32_t>::max() / sizeof(HistogramBase::Sample);
311 size_t required_bytes = 305 size_t required_bytes =
312 (histogram_data.bucket_count + 1) * sizeof(HistogramBase::Sample); 306 (histogram_data.bucket_count + 1) * sizeof(HistogramBase::Sample);
313 size_t allocated_bytes = 307 size_t allocated_bytes =
(...skipping 30 matching lines...) Expand all
344 NOTREACHED(); 338 NOTREACHED();
345 return nullptr; 339 return nullptr;
346 } 340 }
347 341
348 // After the main "counts" array is a second array using for storing what 342 // After the main "counts" array is a second array using for storing what
349 // was previously logged. This is used to calculate the "delta" during 343 // was previously logged. This is used to calculate the "delta" during
350 // snapshot operations. 344 // snapshot operations.
351 HistogramBase::AtomicCount* logged_data = 345 HistogramBase::AtomicCount* logged_data =
352 counts_data + histogram_data.bucket_count; 346 counts_data + histogram_data.bucket_count;
353 347
354 CHECK_LT(0, histogram_data.minimum);
355 CHECK_LT(0, histogram_data.maximum);
356 std::string name(histogram_data_ptr->name); 348 std::string name(histogram_data_ptr->name);
357 scoped_ptr<HistogramBase> histogram; 349 scoped_ptr<HistogramBase> histogram;
358 switch (histogram_data.histogram_type) { 350 switch (histogram_data.histogram_type) {
359 case HISTOGRAM: 351 case HISTOGRAM:
360 histogram = Histogram::PersistentCreate( 352 histogram = Histogram::PersistentCreate(
361 name, histogram_data.minimum, histogram_data.maximum, ranges, 353 name, histogram_data.minimum, histogram_data.maximum, ranges,
362 counts_data, logged_data, histogram_data.bucket_count, 354 counts_data, logged_data, histogram_data.bucket_count,
363 &histogram_data_ptr->samples_metadata, 355 &histogram_data_ptr->samples_metadata,
364 &histogram_data_ptr->logged_metadata); 356 &histogram_data_ptr->logged_metadata);
365 DCHECK(histogram); 357 DCHECK(histogram);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 scoped_ptr<HistogramBase> histogram = 578 scoped_ptr<HistogramBase> histogram =
587 g_allocator->GetNextHistogramWithIgnore(&iter, last_created); 579 g_allocator->GetNextHistogramWithIgnore(&iter, last_created);
588 if (!histogram) 580 if (!histogram)
589 break; 581 break;
590 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram.release()); 582 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram.release());
591 } 583 }
592 } 584 }
593 } 585 }
594 586
595 } // namespace base 587 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/metrics_hashes.cc ('k') | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698