Fix UserSessionManager::Shutdown ordering.
[chromium-blink-merge.git] / sync / util / data_type_histogram.h
blob0f7e6a99e594fb5d678ae8a4d4a3a875a3dc3584
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",
27 // error, max_error);
28 // SYNC_DATA_TYPE_HISTOGRAM(types[i]);
29 // #undef PER_DATA_TYPE_MACRO
30 // }
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) \
37 do { \
38 switch (datatype) { \
39 case ::syncer::BOOKMARKS: \
40 PER_DATA_TYPE_MACRO("Bookmarks"); \
41 break; \
42 case ::syncer::PREFERENCES: \
43 PER_DATA_TYPE_MACRO("Preferences"); \
44 break; \
45 case ::syncer::PASSWORDS: \
46 PER_DATA_TYPE_MACRO("Passwords"); \
47 break; \
48 case ::syncer::AUTOFILL: \
49 PER_DATA_TYPE_MACRO("Autofill"); \
50 break; \
51 case ::syncer::AUTOFILL_PROFILE: \
52 PER_DATA_TYPE_MACRO("AutofillProfiles"); \
53 break; \
54 case ::syncer::AUTOFILL_WALLET_DATA: \
55 PER_DATA_TYPE_MACRO("AutofillWallet"); \
56 break; \
57 case ::syncer::AUTOFILL_WALLET_METADATA: \
58 PER_DATA_TYPE_MACRO("AutofillWalletMetadata"); \
59 break; \
60 case ::syncer::THEMES: \
61 PER_DATA_TYPE_MACRO("Themes"); \
62 break; \
63 case ::syncer::TYPED_URLS: \
64 PER_DATA_TYPE_MACRO("TypedUrls"); \
65 break; \
66 case ::syncer::EXTENSIONS: \
67 PER_DATA_TYPE_MACRO("Extensions"); \
68 break; \
69 case ::syncer::NIGORI: \
70 PER_DATA_TYPE_MACRO("Nigori"); \
71 break; \
72 case ::syncer::SEARCH_ENGINES: \
73 PER_DATA_TYPE_MACRO("SearchEngines"); \
74 break; \
75 case ::syncer::SESSIONS: \
76 PER_DATA_TYPE_MACRO("Sessions"); \
77 break; \
78 case ::syncer::APPS: \
79 PER_DATA_TYPE_MACRO("Apps"); \
80 break; \
81 case ::syncer::APP_LIST: \
82 PER_DATA_TYPE_MACRO("AppList"); \
83 break; \
84 case ::syncer::APP_SETTINGS: \
85 PER_DATA_TYPE_MACRO("AppSettings"); \
86 break; \
87 case ::syncer::EXTENSION_SETTINGS: \
88 PER_DATA_TYPE_MACRO("ExtensionSettings"); \
89 break; \
90 case ::syncer::APP_NOTIFICATIONS: \
91 PER_DATA_TYPE_MACRO("AppNotifications"); \
92 break; \
93 case ::syncer::HISTORY_DELETE_DIRECTIVES: \
94 PER_DATA_TYPE_MACRO("HistoryDeleteDirectives"); \
95 break; \
96 case ::syncer::SYNCED_NOTIFICATIONS: \
97 PER_DATA_TYPE_MACRO("SyncedNotifications"); \
98 break; \
99 case ::syncer::SYNCED_NOTIFICATION_APP_INFO: \
100 PER_DATA_TYPE_MACRO("SyncedNotificationAppInfo"); \
101 break; \
102 case ::syncer::DEVICE_INFO: \
103 PER_DATA_TYPE_MACRO("DeviceInfo"); \
104 break; \
105 case ::syncer::EXPERIMENTS: \
106 PER_DATA_TYPE_MACRO("Experiments"); \
107 break; \
108 case ::syncer::PRIORITY_PREFERENCES :\
109 PER_DATA_TYPE_MACRO("PriorityPreferences"); \
110 break; \
111 case ::syncer::DICTIONARY: \
112 PER_DATA_TYPE_MACRO("Dictionary"); \
113 break; \
114 case ::syncer::FAVICON_IMAGES: \
115 PER_DATA_TYPE_MACRO("FaviconImages"); \
116 break; \
117 case ::syncer::FAVICON_TRACKING: \
118 PER_DATA_TYPE_MACRO("FaviconTracking"); \
119 break; \
120 case ::syncer::SUPERVISED_USER_SETTINGS: \
121 PER_DATA_TYPE_MACRO("ManagedUserSetting"); \
122 break; \
123 case ::syncer::SUPERVISED_USERS: \
124 PER_DATA_TYPE_MACRO("ManagedUser"); \
125 break; \
126 case ::syncer::SUPERVISED_USER_SHARED_SETTINGS: \
127 PER_DATA_TYPE_MACRO("ManagedUserSharedSetting"); \
128 break; \
129 case ::syncer::SUPERVISED_USER_WHITELISTS: \
130 PER_DATA_TYPE_MACRO("ManagedUserWhitelist"); \
131 break; \
132 case ::syncer::ARTICLES: \
133 PER_DATA_TYPE_MACRO("Article"); \
134 break; \
135 case ::syncer::WIFI_CREDENTIALS: \
136 PER_DATA_TYPE_MACRO("WifiCredentials"); \
137 break; \
138 case ::syncer::PROXY_TABS: \
139 PER_DATA_TYPE_MACRO("Tabs"); \
140 break; \
141 default: \
142 NOTREACHED() << "Unknown datatype " \
143 << ::syncer::ModelTypeToString(datatype); \
145 } while (0)
147 #endif // SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_