1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_METRICS_MODULE_H__ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_METRICS_MODULE_H__ 7 #pragma once 8 9 #include <string> 10 11 #include "base/metrics/histogram.h" 12 #include "chrome/browser/extensions/extension_function.h" 13 14 class MetricsSetEnabledFunction : public SyncExtensionFunction { 15 DECLARE_EXTENSION_FUNCTION_NAME("experimental.metrics.setEnabled") 16 protected: 17 virtual bool RunImpl(); 18 }; 19 20 class MetricsGetEnabledFunction : public SyncExtensionFunction { 21 DECLARE_EXTENSION_FUNCTION_NAME("experimental.metrics.getEnabled") 22 protected: 23 virtual bool RunImpl(); 24 }; 25 26 class MetricsRecordUserActionFunction : public SyncExtensionFunction { 27 virtual bool RunImpl(); 28 DECLARE_EXTENSION_FUNCTION_NAME("experimental.metrics.recordUserAction") 29 }; 30 31 class MetricsHistogramHelperFunction : public SyncExtensionFunction { 32 protected: 33 bool GetNameAndSample(std::string* name, int* sample); 34 virtual bool RecordValue(const std::string& name, 35 base::Histogram::ClassType type, 36 int min, int max, size_t buckets, int sample); 37 }; 38 39 class MetricsRecordValueFunction : public MetricsHistogramHelperFunction { 40 virtual bool RunImpl(); 41 DECLARE_EXTENSION_FUNCTION_NAME("experimental.metrics.recordValue") 42 }; 43 44 class MetricsRecordPercentageFunction : public MetricsHistogramHelperFunction { 45 virtual bool RunImpl(); 46 DECLARE_EXTENSION_FUNCTION_NAME("experimental.metrics.recordPercentage") 47 }; 48 49 class MetricsRecordCountFunction : public MetricsHistogramHelperFunction { 50 virtual bool RunImpl(); 51 DECLARE_EXTENSION_FUNCTION_NAME("experimental.metrics.recordCount") 52 }; 53 54 class MetricsRecordSmallCountFunction : public MetricsHistogramHelperFunction { 55 virtual bool RunImpl(); 56 DECLARE_EXTENSION_FUNCTION_NAME("experimental.metrics.recordSmallCount") 57 }; 58 59 class MetricsRecordMediumCountFunction : public MetricsHistogramHelperFunction { 60 virtual bool RunImpl(); 61 DECLARE_EXTENSION_FUNCTION_NAME("experimental.metrics.recordMediumCount") 62 }; 63 64 class MetricsRecordTimeFunction : public MetricsHistogramHelperFunction { 65 virtual bool RunImpl(); 66 DECLARE_EXTENSION_FUNCTION_NAME("experimental.metrics.recordTime") 67 }; 68 69 class MetricsRecordMediumTimeFunction : public MetricsHistogramHelperFunction { 70 virtual bool RunImpl(); 71 DECLARE_EXTENSION_FUNCTION_NAME("experimental.metrics.recordMediumTime") 72 }; 73 74 class MetricsRecordLongTimeFunction : public MetricsHistogramHelperFunction { 75 virtual bool RunImpl(); 76 DECLARE_EXTENSION_FUNCTION_NAME("experimental.metrics.recordLongTime") 77 }; 78 79 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_METRICS_MODULE_H__ 80