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/histogram.cc

Issue 2970873002: Alias |ranges| so it appears in minidump. (Closed)
Patch Set: Created 3 years, 5 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Histogram is an object that aggregates statistics, and can summarize them in 5 // Histogram is an object that aggregates statistics, and can summarize them in
6 // various forms, including ASCII graphical, HTML, and numerically (as a 6 // various forms, including ASCII graphical, HTML, and numerically (as a
7 // vector of numbers corresponding to each of the aggregating buckets). 7 // vector of numbers corresponding to each of the aggregating buckets).
8 // See header file for details and examples. 8 // See header file for details and examples.
9 9
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 histogram_type_(histogram_type), 111 histogram_type_(histogram_type),
112 minimum_(minimum), 112 minimum_(minimum),
113 maximum_(maximum), 113 maximum_(maximum),
114 bucket_count_(bucket_count), 114 bucket_count_(bucket_count),
115 flags_(flags) {} 115 flags_(flags) {}
116 116
117 // Create a BucketRanges structure appropriate for this histogram. 117 // Create a BucketRanges structure appropriate for this histogram.
118 virtual BucketRanges* CreateRanges() { 118 virtual BucketRanges* CreateRanges() {
119 BucketRanges* ranges = new BucketRanges(bucket_count_ + 1); 119 BucketRanges* ranges = new BucketRanges(bucket_count_ + 1);
120 Histogram::InitializeBucketRanges(minimum_, maximum_, ranges); 120 Histogram::InitializeBucketRanges(minimum_, maximum_, ranges);
121 base::debug::Alias(&ranges); // TODO(bcwhite): Remove after crbug/586622.
brucedawson 2017/08/17 19:28:00 Be aware that this technique doesn't work very wel
bcwhite 2017/08/18 05:09:01 Yeah... I've noticed that. :-( It would be nice
121 return ranges; 122 return ranges;
122 } 123 }
123 124
124 // Allocate the correct Histogram object off the heap (in case persistent 125 // Allocate the correct Histogram object off the heap (in case persistent
125 // memory is not available). 126 // memory is not available).
126 virtual std::unique_ptr<HistogramBase> HeapAlloc(const BucketRanges* ranges) { 127 virtual std::unique_ptr<HistogramBase> HeapAlloc(const BucketRanges* ranges) {
127 return WrapUnique(new Histogram(name_, minimum_, maximum_, ranges)); 128 return WrapUnique(new Histogram(name_, minimum_, maximum_, ranges));
128 } 129 }
129 130
130 // Perform any required datafill on the just-created histogram. If 131 // Perform any required datafill on the just-created histogram. If
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 const DescriptionPair* descriptions) 774 const DescriptionPair* descriptions)
774 : Histogram::Factory(name, LINEAR_HISTOGRAM, minimum, maximum, 775 : Histogram::Factory(name, LINEAR_HISTOGRAM, minimum, maximum,
775 bucket_count, flags) { 776 bucket_count, flags) {
776 descriptions_ = descriptions; 777 descriptions_ = descriptions;
777 } 778 }
778 779
779 protected: 780 protected:
780 BucketRanges* CreateRanges() override { 781 BucketRanges* CreateRanges() override {
781 BucketRanges* ranges = new BucketRanges(bucket_count_ + 1); 782 BucketRanges* ranges = new BucketRanges(bucket_count_ + 1);
782 LinearHistogram::InitializeBucketRanges(minimum_, maximum_, ranges); 783 LinearHistogram::InitializeBucketRanges(minimum_, maximum_, ranges);
784 base::debug::Alias(&ranges); // TODO(bcwhite): Remove after crbug/586622.
783 return ranges; 785 return ranges;
784 } 786 }
785 787
786 std::unique_ptr<HistogramBase> HeapAlloc( 788 std::unique_ptr<HistogramBase> HeapAlloc(
787 const BucketRanges* ranges) override { 789 const BucketRanges* ranges) override {
788 return WrapUnique(new LinearHistogram(name_, minimum_, maximum_, ranges)); 790 return WrapUnique(new LinearHistogram(name_, minimum_, maximum_, ranges));
789 } 791 }
790 792
791 void FillHistogram(HistogramBase* base_histogram) override { 793 void FillHistogram(HistogramBase* base_histogram) override {
792 Histogram::Factory::FillHistogram(base_histogram); 794 Histogram::Factory::FillHistogram(base_histogram);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 970
969 class BooleanHistogram::Factory : public Histogram::Factory { 971 class BooleanHistogram::Factory : public Histogram::Factory {
970 public: 972 public:
971 Factory(const std::string& name, int32_t flags) 973 Factory(const std::string& name, int32_t flags)
972 : Histogram::Factory(name, BOOLEAN_HISTOGRAM, 1, 2, 3, flags) {} 974 : Histogram::Factory(name, BOOLEAN_HISTOGRAM, 1, 2, 3, flags) {}
973 975
974 protected: 976 protected:
975 BucketRanges* CreateRanges() override { 977 BucketRanges* CreateRanges() override {
976 BucketRanges* ranges = new BucketRanges(3 + 1); 978 BucketRanges* ranges = new BucketRanges(3 + 1);
977 LinearHistogram::InitializeBucketRanges(1, 2, ranges); 979 LinearHistogram::InitializeBucketRanges(1, 2, ranges);
980 base::debug::Alias(&ranges); // TODO(bcwhite): Remove after crbug/586622.
978 return ranges; 981 return ranges;
979 } 982 }
980 983
981 std::unique_ptr<HistogramBase> HeapAlloc( 984 std::unique_ptr<HistogramBase> HeapAlloc(
982 const BucketRanges* ranges) override { 985 const BucketRanges* ranges) override {
983 return WrapUnique(new BooleanHistogram(name_, ranges)); 986 return WrapUnique(new BooleanHistogram(name_, ranges));
984 } 987 }
985 988
986 private: 989 private:
987 DISALLOW_COPY_AND_ASSIGN(Factory); 990 DISALLOW_COPY_AND_ASSIGN(Factory);
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 Sample sample = custom_ranges[i]; 1224 Sample sample = custom_ranges[i];
1222 if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1) 1225 if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1)
1223 return false; 1226 return false;
1224 if (sample != 0) 1227 if (sample != 0)
1225 has_valid_range = true; 1228 has_valid_range = true;
1226 } 1229 }
1227 return has_valid_range; 1230 return has_valid_range;
1228 } 1231 }
1229 1232
1230 } // namespace base 1233 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698