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_
8 #include "base/metrics/histogram.h"
9 #include "base/time/time.h"
10 #include "sync/internal_api/public/base/model_type.h"
12 // For now, this just implements UMA_HISTOGRAM_LONG_TIMES. This can be adjusted
13 // if we feel the min, max, or bucket count amount are not appropriate.
14 #define SYNC_FREQ_HISTOGRAM(name, time) UMA_HISTOGRAM_CUSTOM_TIMES( \
15 name, time, base::TimeDelta::FromMilliseconds(1), \
16 base::TimeDelta::FromHours(1), 50)
18 // Helper macro for datatype specific histograms. For each datatype, invokes
19 // a pre-defined PER_DATA_TYPE_MACRO(type_str), where |type_str| is the string
20 // version of the datatype.
22 // Example usage (ignoring newlines necessary for multiline macro):
23 // std::vector<syncer::ModelType> types = GetEntryTypes();
24 // for (int i = 0; i < types.size(); ++i) {
25 // #define PER_DATA_TYPE_MACRO(type_str)
26 // UMA_HISTOGRAM_ENUMERATION("Sync." type_str "StartFailures",
28 // SYNC_DATA_TYPE_HISTOGRAM(types[i]);
29 // #undef PER_DATA_TYPE_MACRO
32 // TODO(zea): Once visual studio supports proper variadic argument replacement
33 // in macros, pass in the histogram method directly as a parameter.
34 // See http://connect.microsoft.com/VisualStudio/feedback/details/380090/
35 // variadic-macro-replacement#details
36 #define SYNC_DATA_TYPE_HISTOGRAM(datatype) \
39 case ::syncer::BOOKMARKS: \
40 PER_DATA_TYPE_MACRO("Bookmarks"); \
42 case ::syncer::PREFERENCES: \
43 PER_DATA_TYPE_MACRO("Preferences"); \
45 case ::syncer::PASSWORDS: \
46 PER_DATA_TYPE_MACRO("Passwords"); \
48 case ::syncer::AUTOFILL: \
49 PER_DATA_TYPE_MACRO("Autofill"); \
51 case ::syncer::AUTOFILL_PROFILE: \
52 PER_DATA_TYPE_MACRO("AutofillProfiles"); \
54 case ::syncer::AUTOFILL_WALLET_DATA: \
55 PER_DATA_TYPE_MACRO("AutofillWallet"); \
57 case ::syncer::AUTOFILL_WALLET_METADATA: \
58 PER_DATA_TYPE_MACRO("AutofillWalletMetadata"); \
60 case ::syncer::THEMES: \
61 PER_DATA_TYPE_MACRO("Themes"); \
63 case ::syncer::TYPED_URLS: \
64 PER_DATA_TYPE_MACRO("TypedUrls"); \
66 case ::syncer::EXTENSIONS: \
67 PER_DATA_TYPE_MACRO("Extensions"); \
69 case ::syncer::NIGORI: \
70 PER_DATA_TYPE_MACRO("Nigori"); \
72 case ::syncer::SEARCH_ENGINES: \
73 PER_DATA_TYPE_MACRO("SearchEngines"); \
75 case ::syncer::SESSIONS: \
76 PER_DATA_TYPE_MACRO("Sessions"); \
78 case ::syncer::APPS: \
79 PER_DATA_TYPE_MACRO("Apps"); \
81 case ::syncer::APP_LIST: \
82 PER_DATA_TYPE_MACRO("AppList"); \
84 case ::syncer::APP_SETTINGS: \
85 PER_DATA_TYPE_MACRO("AppSettings"); \
87 case ::syncer::EXTENSION_SETTINGS: \
88 PER_DATA_TYPE_MACRO("ExtensionSettings"); \
90 case ::syncer::APP_NOTIFICATIONS: \
91 PER_DATA_TYPE_MACRO("AppNotifications"); \
93 case ::syncer::HISTORY_DELETE_DIRECTIVES: \
94 PER_DATA_TYPE_MACRO("HistoryDeleteDirectives"); \
96 case ::syncer::SYNCED_NOTIFICATIONS: \
97 PER_DATA_TYPE_MACRO("SyncedNotifications"); \
99 case ::syncer::SYNCED_NOTIFICATION_APP_INFO: \
100 PER_DATA_TYPE_MACRO("SyncedNotificationAppInfo"); \
102 case ::syncer::DEVICE_INFO: \
103 PER_DATA_TYPE_MACRO("DeviceInfo"); \
105 case ::syncer::EXPERIMENTS: \
106 PER_DATA_TYPE_MACRO("Experiments"); \
108 case ::syncer::PRIORITY_PREFERENCES :\
109 PER_DATA_TYPE_MACRO("PriorityPreferences"); \
111 case ::syncer::DICTIONARY: \
112 PER_DATA_TYPE_MACRO("Dictionary"); \
114 case ::syncer::FAVICON_IMAGES: \
115 PER_DATA_TYPE_MACRO("FaviconImages"); \
117 case ::syncer::FAVICON_TRACKING: \
118 PER_DATA_TYPE_MACRO("FaviconTracking"); \
120 case ::syncer::SUPERVISED_USER_SETTINGS: \
121 PER_DATA_TYPE_MACRO("ManagedUserSetting"); \
123 case ::syncer::SUPERVISED_USERS: \
124 PER_DATA_TYPE_MACRO("ManagedUser"); \
126 case ::syncer::SUPERVISED_USER_SHARED_SETTINGS: \
127 PER_DATA_TYPE_MACRO("ManagedUserSharedSetting"); \
129 case ::syncer::SUPERVISED_USER_WHITELISTS: \
130 PER_DATA_TYPE_MACRO("ManagedUserWhitelist"); \
132 case ::syncer::ARTICLES: \
133 PER_DATA_TYPE_MACRO("Article"); \
135 case ::syncer::WIFI_CREDENTIALS: \
136 PER_DATA_TYPE_MACRO("WifiCredentials"); \
138 case ::syncer::PROXY_TABS: \
139 PER_DATA_TYPE_MACRO("Tabs"); \
142 NOTREACHED() << "Unknown datatype " \
143 << ::syncer::ModelTypeToString(datatype); \
147 #endif // SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_