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
3 // found in the LICENSE file.
5 #ifndef SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_
6 #define SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_
10 #include "base/metrics/histogram_macros.h"
11 #include "base/time/time.h"
12 #include "sync/internal_api/public/base/model_type.h"
14 // This function adds |value| to |sample| bucket of histogram |name|. |value|
15 // should be greater or equal to 1 and |name| can be variable. DataTypes are
16 // mapped to proper |sample| bucket by using ModelTypeToHistogramInt() function.
17 // So different DataTypes play the role of different buckets in this histogram.
18 void SyncRecordDatatypeBin(const std::string
& name
, int sample
, int value
);
20 // For now, this just implements UMA_HISTOGRAM_LONG_TIMES. This can be adjusted
21 // if we feel the min, max, or bucket count amount are not appropriate.
22 #define SYNC_FREQ_HISTOGRAM(name, time) UMA_HISTOGRAM_CUSTOM_TIMES( \
23 name, time, base::TimeDelta::FromMilliseconds(1), \
24 base::TimeDelta::FromHours(1), 50)
26 // Helper macro for datatype specific histograms. For each datatype, invokes
27 // a pre-defined PER_DATA_TYPE_MACRO(type_str), where |type_str| is the string
28 // version of the datatype.
30 // Example usage (ignoring newlines necessary for multiline macro):
31 // std::vector<syncer::ModelType> types = GetEntryTypes();
32 // for (int i = 0; i < types.size(); ++i) {
33 // #define PER_DATA_TYPE_MACRO(type_str)
34 // UMA_HISTOGRAM_ENUMERATION("Sync." type_str "StartFailures",
36 // SYNC_DATA_TYPE_HISTOGRAM(types[i]);
37 // #undef PER_DATA_TYPE_MACRO
40 // TODO(zea): Once visual studio supports proper variadic argument replacement
41 // in macros, pass in the histogram method directly as a parameter.
42 // See http://connect.microsoft.com/VisualStudio/feedback/details/380090/
43 // variadic-macro-replacement#details
44 #define SYNC_DATA_TYPE_HISTOGRAM(datatype) \
47 case ::syncer::BOOKMARKS: \
48 PER_DATA_TYPE_MACRO("Bookmarks"); \
50 case ::syncer::PREFERENCES: \
51 PER_DATA_TYPE_MACRO("Preferences"); \
53 case ::syncer::PASSWORDS: \
54 PER_DATA_TYPE_MACRO("Passwords"); \
56 case ::syncer::AUTOFILL: \
57 PER_DATA_TYPE_MACRO("Autofill"); \
59 case ::syncer::AUTOFILL_PROFILE: \
60 PER_DATA_TYPE_MACRO("AutofillProfiles"); \
62 case ::syncer::AUTOFILL_WALLET_DATA: \
63 PER_DATA_TYPE_MACRO("AutofillWallet"); \
65 case ::syncer::AUTOFILL_WALLET_METADATA: \
66 PER_DATA_TYPE_MACRO("AutofillWalletMetadata"); \
68 case ::syncer::THEMES: \
69 PER_DATA_TYPE_MACRO("Themes"); \
71 case ::syncer::TYPED_URLS: \
72 PER_DATA_TYPE_MACRO("TypedUrls"); \
74 case ::syncer::EXTENSIONS: \
75 PER_DATA_TYPE_MACRO("Extensions"); \
77 case ::syncer::NIGORI: \
78 PER_DATA_TYPE_MACRO("Nigori"); \
80 case ::syncer::SEARCH_ENGINES: \
81 PER_DATA_TYPE_MACRO("SearchEngines"); \
83 case ::syncer::SESSIONS: \
84 PER_DATA_TYPE_MACRO("Sessions"); \
86 case ::syncer::APPS: \
87 PER_DATA_TYPE_MACRO("Apps"); \
89 case ::syncer::APP_LIST: \
90 PER_DATA_TYPE_MACRO("AppList"); \
92 case ::syncer::APP_SETTINGS: \
93 PER_DATA_TYPE_MACRO("AppSettings"); \
95 case ::syncer::EXTENSION_SETTINGS: \
96 PER_DATA_TYPE_MACRO("ExtensionSettings"); \
98 case ::syncer::APP_NOTIFICATIONS: \
99 PER_DATA_TYPE_MACRO("AppNotifications"); \
101 case ::syncer::HISTORY_DELETE_DIRECTIVES: \
102 PER_DATA_TYPE_MACRO("HistoryDeleteDirectives"); \
104 case ::syncer::SYNCED_NOTIFICATIONS: \
105 PER_DATA_TYPE_MACRO("SyncedNotifications"); \
107 case ::syncer::SYNCED_NOTIFICATION_APP_INFO: \
108 PER_DATA_TYPE_MACRO("SyncedNotificationAppInfo"); \
110 case ::syncer::DEVICE_INFO: \
111 PER_DATA_TYPE_MACRO("DeviceInfo"); \
113 case ::syncer::EXPERIMENTS: \
114 PER_DATA_TYPE_MACRO("Experiments"); \
116 case ::syncer::PRIORITY_PREFERENCES :\
117 PER_DATA_TYPE_MACRO("PriorityPreferences"); \
119 case ::syncer::DICTIONARY: \
120 PER_DATA_TYPE_MACRO("Dictionary"); \
122 case ::syncer::FAVICON_IMAGES: \
123 PER_DATA_TYPE_MACRO("FaviconImages"); \
125 case ::syncer::FAVICON_TRACKING: \
126 PER_DATA_TYPE_MACRO("FaviconTracking"); \
128 case ::syncer::SUPERVISED_USER_SETTINGS: \
129 PER_DATA_TYPE_MACRO("ManagedUserSetting"); \
131 case ::syncer::SUPERVISED_USERS: \
132 PER_DATA_TYPE_MACRO("ManagedUser"); \
134 case ::syncer::SUPERVISED_USER_SHARED_SETTINGS: \
135 PER_DATA_TYPE_MACRO("ManagedUserSharedSetting"); \
137 case ::syncer::SUPERVISED_USER_WHITELISTS: \
138 PER_DATA_TYPE_MACRO("ManagedUserWhitelist"); \
140 case ::syncer::ARTICLES: \
141 PER_DATA_TYPE_MACRO("Article"); \
143 case ::syncer::WIFI_CREDENTIALS: \
144 PER_DATA_TYPE_MACRO("WifiCredentials"); \
146 case ::syncer::PROXY_TABS: \
147 PER_DATA_TYPE_MACRO("Tabs"); \
150 NOTREACHED() << "Unknown datatype " \
151 << ::syncer::ModelTypeToString(datatype); \
155 #endif // SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_