OLD | NEW |
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // to released memory after the following line. | 209 // to released memory after the following line. |
210 const void* tentative_histogram_ptr = tentative_histogram.get(); | 210 const void* tentative_histogram_ptr = tentative_histogram.get(); |
211 histogram = StatisticsRecorder::RegisterOrDeleteDuplicate( | 211 histogram = StatisticsRecorder::RegisterOrDeleteDuplicate( |
212 tentative_histogram.release()); | 212 tentative_histogram.release()); |
213 | 213 |
214 // Persistent histograms need some follow-up processing. | 214 // Persistent histograms need some follow-up processing. |
215 if (histogram_ref) { | 215 if (histogram_ref) { |
216 allocator->FinalizeHistogram(histogram_ref, | 216 allocator->FinalizeHistogram(histogram_ref, |
217 histogram == tentative_histogram_ptr); | 217 histogram == tentative_histogram_ptr); |
218 } | 218 } |
| 219 |
| 220 // Update report on created histograms. |
| 221 ReportHistogramActivity(*histogram, HISTOGRAM_CREATED); |
| 222 } else { |
| 223 // Update report on lookup histograms. |
| 224 ReportHistogramActivity(*histogram, HISTOGRAM_LOOKUP); |
219 } | 225 } |
220 | 226 |
221 DCHECK_EQ(histogram_type_, histogram->GetHistogramType()); | 227 DCHECK_EQ(histogram_type_, histogram->GetHistogramType()) << name_; |
222 if (bucket_count_ != 0 && | 228 if (bucket_count_ != 0 && |
223 !histogram->HasConstructionArguments(minimum_, maximum_, bucket_count_)) { | 229 !histogram->HasConstructionArguments(minimum_, maximum_, bucket_count_)) { |
224 // The construction arguments do not match the existing histogram. This can | 230 // The construction arguments do not match the existing histogram. This can |
225 // come about if an extension updates in the middle of a chrome run and has | 231 // come about if an extension updates in the middle of a chrome run and has |
226 // changed one of them, or simply by bad code within Chrome itself. We | 232 // changed one of them, or simply by bad code within Chrome itself. We |
227 // return NULL here with the expectation that bad code in Chrome will crash | 233 // return NULL here with the expectation that bad code in Chrome will crash |
228 // on dereference, but extension/Pepper APIs will guard against NULL and not | 234 // on dereference, but extension/Pepper APIs will guard against NULL and not |
229 // crash. | 235 // crash. |
230 DLOG(ERROR) << "Histogram " << name_ << " has bad construction arguments"; | 236 DLOG(ERROR) << "Histogram " << name_ << " has bad construction arguments"; |
231 return nullptr; | 237 return nullptr; |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 Sample sample = custom_ranges[i]; | 1169 Sample sample = custom_ranges[i]; |
1164 if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1) | 1170 if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1) |
1165 return false; | 1171 return false; |
1166 if (sample != 0) | 1172 if (sample != 0) |
1167 has_valid_range = true; | 1173 has_valid_range = true; |
1168 } | 1174 } |
1169 return has_valid_range; | 1175 return has_valid_range; |
1170 } | 1176 } |
1171 | 1177 |
1172 } // namespace base | 1178 } // namespace base |
OLD | NEW |