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 #include "chrome/browser/extensions/api/metrics_private/metrics_private_api.h" | 5 #include "chrome/browser/extensions/api/metrics_private/metrics_private_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 if (type == base::LINEAR_HISTOGRAM) { | 132 if (type == base::LINEAR_HISTOGRAM) { |
133 counter = base::LinearHistogram::FactoryGet( | 133 counter = base::LinearHistogram::FactoryGet( |
134 name, min, max, buckets, | 134 name, min, max, buckets, |
135 base::HistogramBase::kUmaTargetedHistogramFlag); | 135 base::HistogramBase::kUmaTargetedHistogramFlag); |
136 } else { | 136 } else { |
137 counter = base::Histogram::FactoryGet( | 137 counter = base::Histogram::FactoryGet( |
138 name, min, max, buckets, | 138 name, min, max, buckets, |
139 base::HistogramBase::kUmaTargetedHistogramFlag); | 139 base::HistogramBase::kUmaTargetedHistogramFlag); |
140 } | 140 } |
141 | 141 |
142 counter->Add(sample); | 142 if (counter) |
Alexei Svitkine (slow)
2014/01/24 20:39:40
Add a comment.
elijahtaylor1
2014/01/24 23:10:37
Done.
| |
143 counter->Add(sample); | |
143 return true; | 144 return true; |
144 } | 145 } |
145 | 146 |
146 bool MetricsPrivateRecordValueFunction::RunImpl() { | 147 bool MetricsPrivateRecordValueFunction::RunImpl() { |
147 scoped_ptr<RecordValue::Params> params(RecordValue::Params::Create(*args_)); | 148 scoped_ptr<RecordValue::Params> params(RecordValue::Params::Create(*args_)); |
148 EXTENSION_FUNCTION_VALIDATE(params.get()); | 149 EXTENSION_FUNCTION_VALIDATE(params.get()); |
149 | 150 |
150 // Get the histogram parameters from the metric type object. | 151 // Get the histogram parameters from the metric type object. |
151 std::string type = api::metrics_private::MetricType::ToString( | 152 std::string type = api::metrics_private::MetricType::ToString( |
152 params->metric.type); | 153 params->metric.type); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 bool MetricsPrivateRecordLongTimeFunction::RunImpl() { | 210 bool MetricsPrivateRecordLongTimeFunction::RunImpl() { |
210 scoped_ptr<RecordLongTime::Params> params( | 211 scoped_ptr<RecordLongTime::Params> params( |
211 RecordLongTime::Params::Create(*args_)); | 212 RecordLongTime::Params::Create(*args_)); |
212 EXTENSION_FUNCTION_VALIDATE(params.get()); | 213 EXTENSION_FUNCTION_VALIDATE(params.get()); |
213 static const int kOneHourMs = 60 * 60 * 1000; | 214 static const int kOneHourMs = 60 * 60 * 1000; |
214 return RecordValue(params->metric_name, base::HISTOGRAM, | 215 return RecordValue(params->metric_name, base::HISTOGRAM, |
215 1, kOneHourMs, 50, params->value); | 216 1, kOneHourMs, 50, params->value); |
216 } | 217 } |
217 | 218 |
218 } // namespace extensions | 219 } // namespace extensions |
OLD | NEW |