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