Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_metrics_module.h" | 5 #include "chrome/browser/extensions/extension_metrics_module.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
| 9 #include "content/public/browser/user_metrics.h" | 9 #include "content/public/browser/user_metrics.h" |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, sample)); | 26 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, sample)); |
| 27 return true; | 27 return true; |
| 28 } | 28 } |
| 29 | 29 |
| 30 bool MetricsHistogramHelperFunction::RecordValue(const std::string& name, | 30 bool MetricsHistogramHelperFunction::RecordValue(const std::string& name, |
| 31 Histogram::ClassType type, | 31 Histogram::ClassType type, |
| 32 int min, | 32 int min, |
| 33 int max, | 33 int max, |
| 34 size_t buckets, | 34 size_t buckets, |
| 35 int sample) { | 35 int sample) { |
| 36 // Make sure toxic values don't get to internal code | |
|
jar (doing other things)
2012/01/05 17:35:14
You should also watch out for INT_MAX since you're
rkc
2012/01/06 00:08:01
Done.
| |
| 37 min = min > 0 ? min : 1; | |
|
jar (doing other things)
2012/01/05 17:35:14
nit: (personal style): I find it much more readabl
rkc
2012/01/06 00:08:01
Done.
| |
| 38 max = max > min ? max : min + 1; | |
| 39 buckets = buckets > 2 ? buckets : 3; | |
| 40 // Trim buckets down to a maximum of the given range + over/underflow buckets | |
| 41 if ((int)buckets > (max - min + 2)) { | |
|
jar (doing other things)
2012/01/05 17:35:14
nit: Use C++ style casts: static_cast<int>(bucket
rkc
2012/01/06 00:08:01
Done.
| |
| 42 buckets = max - min + 2; | |
| 43 } | |
| 44 | |
| 36 Histogram* counter; | 45 Histogram* counter; |
| 37 if (type == Histogram::LINEAR_HISTOGRAM) { | 46 if (type == Histogram::LINEAR_HISTOGRAM) { |
| 38 counter = LinearHistogram::FactoryGet(name, | 47 counter = LinearHistogram::FactoryGet(name, |
| 39 min, | 48 min, |
| 40 max, | 49 max, |
| 41 buckets, | 50 buckets, |
| 42 Histogram::kUmaTargetedHistogramFlag); | 51 Histogram::kUmaTargetedHistogramFlag); |
| 43 } else { | 52 } else { |
| 44 counter = Histogram::FactoryGet(name, | 53 counter = Histogram::FactoryGet(name, |
| 45 min, | 54 min, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 return RecordValue(name, Histogram::HISTOGRAM, 1, kThreeMinMs, 50, sample); | 129 return RecordValue(name, Histogram::HISTOGRAM, 1, kThreeMinMs, 50, sample); |
| 121 } | 130 } |
| 122 | 131 |
| 123 bool MetricsRecordLongTimeFunction::RunImpl() { | 132 bool MetricsRecordLongTimeFunction::RunImpl() { |
| 124 std::string name; | 133 std::string name; |
| 125 int sample; | 134 int sample; |
| 126 EXTENSION_FUNCTION_VALIDATE(GetNameAndSample(&name, &sample)); | 135 EXTENSION_FUNCTION_VALIDATE(GetNameAndSample(&name, &sample)); |
| 127 static const int kOneHourMs = 60 * 60 * 1000; | 136 static const int kOneHourMs = 60 * 60 * 1000; |
| 128 return RecordValue(name, Histogram::HISTOGRAM, 1, kOneHourMs, 50, sample); | 137 return RecordValue(name, Histogram::HISTOGRAM, 1, kOneHourMs, 50, sample); |
| 129 } | 138 } |
| OLD | NEW |