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

Side by Side Diff: chrome/browser/extensions/extension_metrics_module.cc

Issue 8510046: Removing extension name suffix from the metric name in chrome.experimental.metrics (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Removing obsolete comment Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/values.h" 8 #include "base/values.h"
9 #include "chrome/common/extensions/extension.h" 9 #include "chrome/common/extensions/extension.h"
10 #include "chrome/browser/ui/options/options_util.h" 10 #include "chrome/browser/ui/options/options_util.h"
11 #include "chrome/installer/util/google_update_settings.h" 11 #include "chrome/installer/util/google_update_settings.h"
12 #include "content/browser/user_metrics.h" 12 #include "content/browser/user_metrics.h"
13 13
14 using base::Histogram; 14 using base::Histogram;
15 using base::LinearHistogram; 15 using base::LinearHistogram;
16 16
17 namespace { 17 namespace {
18 18
19 // Build the full name of a metrics for the given extension. Each metric 19 // Build the full name of a metrics for the given extension.
20 // is made up of the unique name within the extension followed by the 20 // For a non-component extension the metric name is made up of the unique name
21 // extension's id. This keeps the metrics from one extension unique from 21 // within the extension followed by the extension's id. This keeps the metrics
22 // other extensions, as well as those metrics from chrome itself. 22 // from one extension unique from other extensions, as well as those metrics
23 // from chrome itself.
24 // For a component extension the metric name is used as is. There are not so
25 // many of them and it is easy enough to prevent name clashes.
23 std::string BuildMetricName(const std::string& name, 26 std::string BuildMetricName(const std::string& name,
24 const Extension* extension) { 27 const Extension* extension) {
25 std::string full_name(name); 28 std::string full_name(name);
26 full_name += extension->id(); 29 if (extension->location() != Extension::COMPONENT)
30 full_name += extension->id();
27 return full_name; 31 return full_name;
28 } 32 }
29 33
30 } // anonymous namespace 34 } // anonymous namespace
31 35
32 // These extension function classes are enabled only if the
33 // enable-metrics-extension-api command line switch is used. Refer to
34 // extension_function_dispatcher.cc to see how they are enabled.
35
36 bool MetricsSetEnabledFunction::RunImpl() { 36 bool MetricsSetEnabledFunction::RunImpl() {
37 bool enabled = false; 37 bool enabled = false;
38 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &enabled)); 38 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &enabled));
39 39
40 // Using OptionsUtil is better because it actually ensures we reset all the 40 // Using OptionsUtil is better because it actually ensures we reset all the
41 // necessary threads. This is the main way for starting / stopping UMA and 41 // necessary threads. This is the main way for starting / stopping UMA and
42 // crash reporting. 42 // crash reporting.
43 // This method will return the resulting enabled, which we send to JS. 43 // This method will return the resulting enabled, which we send to JS.
44 bool result = OptionsUtil::ResolveMetricsReportingEnabled(enabled); 44 bool result = OptionsUtil::ResolveMetricsReportingEnabled(enabled);
45 result_.reset(Value::CreateBooleanValue(result)); 45 result_.reset(Value::CreateBooleanValue(result));
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 return RecordValue(name, Histogram::HISTOGRAM, 1, kThreeMinMs, 50, sample); 162 return RecordValue(name, Histogram::HISTOGRAM, 1, kThreeMinMs, 50, sample);
163 } 163 }
164 164
165 bool MetricsRecordLongTimeFunction::RunImpl() { 165 bool MetricsRecordLongTimeFunction::RunImpl() {
166 std::string name; 166 std::string name;
167 int sample; 167 int sample;
168 EXTENSION_FUNCTION_VALIDATE(GetNameAndSample(&name, &sample)); 168 EXTENSION_FUNCTION_VALIDATE(GetNameAndSample(&name, &sample));
169 static const int kOneHourMs = 60 * 60 * 1000; 169 static const int kOneHourMs = 60 * 60 * 1000;
170 return RecordValue(name, Histogram::HISTOGRAM, 1, kOneHourMs, 50, sample); 170 return RecordValue(name, Histogram::HISTOGRAM, 1, kOneHourMs, 50, sample);
171 } 171 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698