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

Unified Diff: chrome/browser/extensions/api/metrics/metrics.cc

Issue 10696145: Moving metrics to api/ . (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/metrics/metrics.cc
diff --git a/chrome/browser/extensions/extension_metrics_module.cc b/chrome/browser/extensions/api/metrics/metrics.cc
similarity index 67%
rename from chrome/browser/extensions/extension_metrics_module.cc
rename to chrome/browser/extensions/api/metrics/metrics.cc
index 0c63a7aee1ab21c182ef9a2a8e31b8e5692539df..3ff42de8971d82e143a7e629f83d68c2c5fe5221 100644
--- a/chrome/browser/extensions/extension_metrics_module.cc
+++ b/chrome/browser/extensions/api/metrics/metrics.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/extensions/extension_metrics_module.h"
+#include "chrome/browser/extensions/api/metrics/metrics.h"
#include <algorithm>
@@ -10,13 +10,14 @@
#include "chrome/common/extensions/extension.h"
#include "content/public/browser/user_metrics.h"
-using base::Histogram;
-using base::LinearHistogram;
-using content::UserMetricsAction;
Matt Perry 2012/07/10 19:18:17 Why'd you remove the using directives? They are al
vabr (Chromium) 2012/07/11 08:22:29 Thanks for pointing that out, I overlooked the dis
+namespace extensions {
+
+namespace {
const size_t kMaxBuckets = 10000; // We don't ever want more than these many
// buckets; there is no real need for them
// and would cause crazy memory usage
+} // namespace
bool MetricsRecordUserActionFunction::RunImpl() {
std::string name;
@@ -33,12 +34,11 @@ bool MetricsHistogramHelperFunction::GetNameAndSample(std::string* name,
return true;
}
-bool MetricsHistogramHelperFunction::RecordValue(const std::string& name,
- Histogram::ClassType type,
- int min,
- int max,
- size_t buckets,
- int sample) {
+bool MetricsHistogramHelperFunction::RecordValue(
+ const std::string& name,
+ base::Histogram::ClassType type,
+ int min, int max, size_t buckets,
+ int sample) {
// Make sure toxic values don't get to internal code.
// Fix for maximums
min = std::min(min, INT_MAX - 3);
@@ -52,19 +52,17 @@ bool MetricsHistogramHelperFunction::RecordValue(const std::string& name,
if (buckets > static_cast<size_t>(max - min + 2))
buckets = max - min + 2;
- Histogram* counter;
- if (type == Histogram::LINEAR_HISTOGRAM) {
- counter = LinearHistogram::FactoryGet(name,
- min,
- max,
- buckets,
- Histogram::kUmaTargetedHistogramFlag);
+ base::Histogram* counter;
+ if (type == base::Histogram::LINEAR_HISTOGRAM) {
+ counter = base::LinearHistogram::FactoryGet(
+ name,
+ min, max, buckets,
+ base::Histogram::kUmaTargetedHistogramFlag);
} else {
- counter = Histogram::FactoryGet(name,
- min,
- max,
- buckets,
- Histogram::kUmaTargetedHistogramFlag);
+ counter = base::Histogram::FactoryGet(
+ name,
+ min, max, buckets,
+ base::Histogram::kUmaTargetedHistogramFlag);
}
counter->Add(sample);
@@ -90,8 +88,8 @@ bool MetricsRecordValueFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(metric_type->GetInteger("max", &max));
EXTENSION_FUNCTION_VALIDATE(metric_type->GetInteger("buckets", &buckets));
- Histogram::ClassType histogram_type(type == "histogram-linear" ?
- Histogram::LINEAR_HISTOGRAM : Histogram::HISTOGRAM);
+ base::Histogram::ClassType histogram_type(type == "histogram-linear" ?
+ base::Histogram::LINEAR_HISTOGRAM : base::Histogram::HISTOGRAM);
return RecordValue(name, histogram_type, min, max, buckets, sample);
}
@@ -99,28 +97,32 @@ bool MetricsRecordPercentageFunction::RunImpl() {
std::string name;
int sample;
EXTENSION_FUNCTION_VALIDATE(GetNameAndSample(&name, &sample));
- return RecordValue(name, Histogram::LINEAR_HISTOGRAM, 1, 101, 102, sample);
+ return RecordValue(
+ name,
+ base::Histogram::LINEAR_HISTOGRAM,
+ 1, 101, 102,
+ sample);
}
bool MetricsRecordCountFunction::RunImpl() {
std::string name;
int sample;
EXTENSION_FUNCTION_VALIDATE(GetNameAndSample(&name, &sample));
- return RecordValue(name, Histogram::HISTOGRAM, 1, 1000000, 50, sample);
+ return RecordValue(name, base::Histogram::HISTOGRAM, 1, 1000000, 50, sample);
}
bool MetricsRecordSmallCountFunction::RunImpl() {
std::string name;
int sample;
EXTENSION_FUNCTION_VALIDATE(GetNameAndSample(&name, &sample));
- return RecordValue(name, Histogram::HISTOGRAM, 1, 100, 50, sample);
+ return RecordValue(name, base::Histogram::HISTOGRAM, 1, 100, 50, sample);
}
bool MetricsRecordMediumCountFunction::RunImpl() {
std::string name;
int sample;
EXTENSION_FUNCTION_VALIDATE(GetNameAndSample(&name, &sample));
- return RecordValue(name, Histogram::HISTOGRAM, 1, 10000, 50, sample);
+ return RecordValue(name, base::Histogram::HISTOGRAM, 1, 10000, 50, sample);
}
bool MetricsRecordTimeFunction::RunImpl() {
@@ -128,7 +130,10 @@ bool MetricsRecordTimeFunction::RunImpl() {
int sample;
EXTENSION_FUNCTION_VALIDATE(GetNameAndSample(&name, &sample));
static const int kTenSecMs = 10 * 1000;
- return RecordValue(name, Histogram::HISTOGRAM, 1, kTenSecMs, 50, sample);
+ return RecordValue(name,
+ base::Histogram::HISTOGRAM,
+ 1, kTenSecMs, 50,
+ sample);
}
bool MetricsRecordMediumTimeFunction::RunImpl() {
@@ -136,7 +141,10 @@ bool MetricsRecordMediumTimeFunction::RunImpl() {
int sample;
EXTENSION_FUNCTION_VALIDATE(GetNameAndSample(&name, &sample));
static const int kThreeMinMs = 3 * 60 * 1000;
- return RecordValue(name, Histogram::HISTOGRAM, 1, kThreeMinMs, 50, sample);
+ return RecordValue(name,
+ base::Histogram::HISTOGRAM,
+ 1, kThreeMinMs, 50,
+ sample);
}
bool MetricsRecordLongTimeFunction::RunImpl() {
@@ -144,5 +152,10 @@ bool MetricsRecordLongTimeFunction::RunImpl() {
int sample;
EXTENSION_FUNCTION_VALIDATE(GetNameAndSample(&name, &sample));
static const int kOneHourMs = 60 * 60 * 1000;
- return RecordValue(name, Histogram::HISTOGRAM, 1, kOneHourMs, 50, sample);
+ return RecordValue(name,
+ base::Histogram::HISTOGRAM,
+ 1, kOneHourMs, 50,
+ sample);
}
+
+} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/metrics/metrics.h ('k') | chrome/browser/extensions/api/metrics/metrics_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698