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

Side by Side Diff: chrome/browser/extensions/api/metrics_private/metrics_private_api.cc

Issue 141393002: Return a NULL histogram pointer on construction error (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add construction param to restore old CHECK for non-API calls Created 6 years, 11 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
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 #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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 max = std::max(max, min + 1); 125 max = std::max(max, min + 1);
126 buckets = std::max(buckets, static_cast<size_t>(3)); 126 buckets = std::max(buckets, static_cast<size_t>(3));
127 // Trim buckets down to a maximum of the given range + over/underflow buckets 127 // Trim buckets down to a maximum of the given range + over/underflow buckets
128 if (buckets > static_cast<size_t>(max - min + 2)) 128 if (buckets > static_cast<size_t>(max - min + 2))
129 buckets = max - min + 2; 129 buckets = max - min + 2;
130 130
131 base::HistogramBase* counter; 131 base::HistogramBase* counter;
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 base::HistogramBase::kAllowBadConstruction);
136 } else { 137 } else {
137 counter = base::Histogram::FactoryGet( 138 counter = base::Histogram::FactoryGet(
138 name, min, max, buckets, 139 name, min, max, buckets,
139 base::HistogramBase::kUmaTargetedHistogramFlag); 140 base::HistogramBase::kUmaTargetedHistogramFlag,
141 base::HistogramBase::kAllowBadConstruction);
140 } 142 }
141 143
142 counter->Add(sample); 144 counter->Add(sample);
143 return true; 145 return true;
144 } 146 }
145 147
146 bool MetricsPrivateRecordValueFunction::RunImpl() { 148 bool MetricsPrivateRecordValueFunction::RunImpl() {
147 scoped_ptr<RecordValue::Params> params(RecordValue::Params::Create(*args_)); 149 scoped_ptr<RecordValue::Params> params(RecordValue::Params::Create(*args_));
148 EXTENSION_FUNCTION_VALIDATE(params.get()); 150 EXTENSION_FUNCTION_VALIDATE(params.get());
149 151
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 bool MetricsPrivateRecordLongTimeFunction::RunImpl() { 211 bool MetricsPrivateRecordLongTimeFunction::RunImpl() {
210 scoped_ptr<RecordLongTime::Params> params( 212 scoped_ptr<RecordLongTime::Params> params(
211 RecordLongTime::Params::Create(*args_)); 213 RecordLongTime::Params::Create(*args_));
212 EXTENSION_FUNCTION_VALIDATE(params.get()); 214 EXTENSION_FUNCTION_VALIDATE(params.get());
213 static const int kOneHourMs = 60 * 60 * 1000; 215 static const int kOneHourMs = 60 * 60 * 1000;
214 return RecordValue(params->metric_name, base::HISTOGRAM, 216 return RecordValue(params->metric_name, base::HISTOGRAM,
215 1, kOneHourMs, 50, params->value); 217 1, kOneHourMs, 50, params->value);
216 } 218 }
217 219
218 } // namespace extensions 220 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698