diff options
author | vabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 09:42:24 +0000 |
---|---|---|
committer | vabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 09:42:24 +0000 |
commit | 737a9f06aae4526457ed9cb68046d5e7eecf3c88 (patch) | |
tree | e6d33b441fec5b18aa2187111f699f23f316dbd0 | |
parent | bf48a1f41b08e8abb0569aeffa539e8bef506d56 (diff) | |
download | chromium_src-737a9f06aae4526457ed9cb68046d5e7eecf3c88.zip chromium_src-737a9f06aae4526457ed9cb68046d5e7eecf3c88.tar.gz chromium_src-737a9f06aae4526457ed9cb68046d5e7eecf3c88.tar.bz2 |
Moving metrics to api/ .
BUG=101244
TEST=N/A, only moving code, no change in functionality
Review URL: https://chromiumcodereview.appspot.com/10696145
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146092 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | WATCHLISTS | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/api/metrics/metrics.cc (renamed from chrome/browser/extensions/extension_metrics_module.cc) | 34 | ||||
-rw-r--r-- | chrome/browser/extensions/api/metrics/metrics.h (renamed from chrome/browser/extensions/extension_metrics_module.h) | 13 | ||||
-rw-r--r-- | chrome/browser/extensions/api/metrics/metrics_apitest.cc (renamed from chrome/browser/extensions/extension_metrics_apitest.cc) | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_function_registry.cc | 20 | ||||
-rw-r--r-- | chrome/chrome_browser_extensions.gypi | 4 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 2 | ||||
-rw-r--r-- | chrome/test/data/extensions/api_test/metrics/test.js | 4 |
8 files changed, 45 insertions, 36 deletions
@@ -197,7 +197,7 @@ '|chrome/common/metrics/.*'\ '|chrome_frame/metrics.*'\ '|chrome/browser/chromeos/external_metrics.*'\ - '|chrome/browser/extensions/extension_metrics_module.*'\ + '|chrome/browser/extensions/api/metrics/metrics.*'\ '|chrome/browser/ui/webui/metrics_handler.*'\ '|content/browser/user_metrics.cc'\ '|content/public/browser/user_metrics.h'\ diff --git a/chrome/browser/extensions/extension_metrics_module.cc b/chrome/browser/extensions/api/metrics/metrics.cc index 0c63a7a..eb7c924 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,17 @@ #include "chrome/common/extensions/extension.h" #include "content/public/browser/user_metrics.h" +namespace extensions { + using base::Histogram; using base::LinearHistogram; -using content::UserMetricsAction; + +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 +37,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, + 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); @@ -55,15 +58,11 @@ bool MetricsHistogramHelperFunction::RecordValue(const std::string& name, Histogram* counter; if (type == Histogram::LINEAR_HISTOGRAM) { counter = LinearHistogram::FactoryGet(name, - min, - max, - buckets, + min, max, buckets, Histogram::kUmaTargetedHistogramFlag); } else { counter = Histogram::FactoryGet(name, - min, - max, - buckets, + min, max, buckets, Histogram::kUmaTargetedHistogramFlag); } @@ -99,7 +98,10 @@ 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, + Histogram::LINEAR_HISTOGRAM, + 1, 101, 102, + sample); } bool MetricsRecordCountFunction::RunImpl() { @@ -146,3 +148,5 @@ bool MetricsRecordLongTimeFunction::RunImpl() { static const int kOneHourMs = 60 * 60 * 1000; return RecordValue(name, Histogram::HISTOGRAM, 1, kOneHourMs, 50, sample); } + +} // namespace extensions diff --git a/chrome/browser/extensions/extension_metrics_module.h b/chrome/browser/extensions/api/metrics/metrics.h index fcb4307..eefddf4 100644 --- a/chrome/browser/extensions/extension_metrics_module.h +++ b/chrome/browser/extensions/api/metrics/metrics.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_METRICS_MODULE_H__ -#define CHROME_BROWSER_EXTENSIONS_EXTENSION_METRICS_MODULE_H__ +#ifndef CHROME_BROWSER_EXTENSIONS_API_METRICS_METRICS_H_ +#define CHROME_BROWSER_EXTENSIONS_API_METRICS_METRICS_H_ #pragma once #include <string> @@ -11,6 +11,8 @@ #include "base/metrics/histogram.h" #include "chrome/browser/extensions/extension_function.h" +namespace extensions { + class MetricsRecordUserActionFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("metricsPrivate.recordUserAction") @@ -28,7 +30,8 @@ class MetricsHistogramHelperFunction : public SyncExtensionFunction { bool GetNameAndSample(std::string* name, int* sample); virtual bool RecordValue(const std::string& name, base::Histogram::ClassType type, - int min, int max, size_t buckets, int sample); + int min, int max, size_t buckets, + int sample); }; class MetricsRecordValueFunction : public MetricsHistogramHelperFunction { @@ -119,4 +122,6 @@ class MetricsRecordLongTimeFunction : public MetricsHistogramHelperFunction { virtual bool RunImpl() OVERRIDE; }; -#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_METRICS_MODULE_H__ +} // namespace extensions + +#endif // CHROME_BROWSER_EXTENSIONS_API_METRICS_METRICS_H_ diff --git a/chrome/browser/extensions/extension_metrics_apitest.cc b/chrome/browser/extensions/api/metrics/metrics_apitest.cc index 3d8b506..5194977 100644 --- a/chrome/browser/extensions/extension_metrics_apitest.cc +++ b/chrome/browser/extensions/api/metrics/metrics_apitest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/chrome/browser/extensions/extension_function_registry.cc b/chrome/browser/extensions/extension_function_registry.cc index 87a08be..96deac5 100644 --- a/chrome/browser/extensions/extension_function_registry.cc +++ b/chrome/browser/extensions/extension_function_registry.cc @@ -19,6 +19,7 @@ #include "chrome/browser/extensions/api/extension_action/extension_script_badge_api.h" #include "chrome/browser/extensions/api/identity/identity_api.h" #include "chrome/browser/extensions/api/media_gallery/media_gallery_api.h" +#include "chrome/browser/extensions/api/metrics/metrics.h" #include "chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.h" #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" #include "chrome/browser/extensions/api/permissions/permissions_api.h" @@ -39,7 +40,6 @@ #include "chrome/browser/extensions/extension_idle_api.h" #include "chrome/browser/extensions/extension_managed_mode_api.h" #include "chrome/browser/extensions/extension_management_api.h" -#include "chrome/browser/extensions/extension_metrics_module.h" #include "chrome/browser/extensions/extension_module.h" #include "chrome/browser/extensions/extension_page_capture_api.h" #include "chrome/browser/extensions/extension_preference_api.h" @@ -207,15 +207,15 @@ void ExtensionFunctionRegistry::ResetFunctions() { RegisterFunction<GetProcessInfoFunction>(); // Metrics. - RegisterFunction<MetricsRecordUserActionFunction>(); - RegisterFunction<MetricsRecordValueFunction>(); - RegisterFunction<MetricsRecordPercentageFunction>(); - RegisterFunction<MetricsRecordCountFunction>(); - RegisterFunction<MetricsRecordSmallCountFunction>(); - RegisterFunction<MetricsRecordMediumCountFunction>(); - RegisterFunction<MetricsRecordTimeFunction>(); - RegisterFunction<MetricsRecordMediumTimeFunction>(); - RegisterFunction<MetricsRecordLongTimeFunction>(); + RegisterFunction<extensions::MetricsRecordUserActionFunction>(); + RegisterFunction<extensions::MetricsRecordValueFunction>(); + RegisterFunction<extensions::MetricsRecordPercentageFunction>(); + RegisterFunction<extensions::MetricsRecordCountFunction>(); + RegisterFunction<extensions::MetricsRecordSmallCountFunction>(); + RegisterFunction<extensions::MetricsRecordMediumCountFunction>(); + RegisterFunction<extensions::MetricsRecordTimeFunction>(); + RegisterFunction<extensions::MetricsRecordMediumTimeFunction>(); + RegisterFunction<extensions::MetricsRecordLongTimeFunction>(); // RLZ. #if defined(OS_WIN) || defined(OS_MACOSX) diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index f2a507d..5884f974 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -528,6 +528,8 @@ }], ['enable_extensions==1', { 'sources': [ + 'browser/extensions/api/metrics/metrics.cc', + 'browser/extensions/api/metrics/metrics.h', 'browser/extensions/api/tabs/execute_code_in_tab_function.cc', 'browser/extensions/api/tabs/execute_code_in_tab_function.h', 'browser/extensions/api/tabs/tabs.cc', @@ -556,8 +558,6 @@ 'browser/extensions/extension_managed_mode_api.h', 'browser/extensions/extension_management_api.cc', 'browser/extensions/extension_management_api.h', - 'browser/extensions/extension_metrics_module.cc', - 'browser/extensions/extension_metrics_module.h', 'browser/extensions/extension_page_capture_api.cc', 'browser/extensions/extension_page_capture_api.h', 'browser/extensions/extension_preference_api.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index aaead20..c70384f 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2732,6 +2732,7 @@ 'browser/extensions/api/identity/identity_apitest.cc', 'browser/extensions/api/idltest/idltest_apitest.cc', 'browser/extensions/api/media_gallery/media_gallery_apitest.cc', + 'browser/extensions/api/metrics/metrics_apitest.cc', 'browser/extensions/api/offscreen_tabs/offscreen_tabs_apitest.cc', 'browser/extensions/api/omnibox/omnibox_apitest.cc', 'browser/extensions/api/permissions/permissions_apitest.cc', @@ -2798,7 +2799,6 @@ 'browser/extensions/extension_management_apitest.cc', 'browser/extensions/extension_management_browsertest.cc', 'browser/extensions/extension_messages_apitest.cc', - 'browser/extensions/extension_metrics_apitest.cc', 'browser/extensions/extension_module_apitest.cc', 'browser/extensions/extension_override_apitest.cc', 'browser/extensions/extension_page_capture_apitest.cc', diff --git a/chrome/test/data/extensions/api_test/metrics/test.js b/chrome/test/data/extensions/api_test/metrics/test.js index 4083e94..6389742 100644 --- a/chrome/test/data/extensions/api_test/metrics/test.js +++ b/chrome/test/data/extensions/api_test/metrics/test.js @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,7 +7,7 @@ // Any changes to the logging done in these functions should be matched // with the checks done in IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Metrics). -// See extension_metrics_apitest.cc. +// See metrics_apitest.cc. chrome.test.runTests([ function recordUserAction() { // Log a metric once. |