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::THEMES: \
55 PER_DATA_TYPE_MACRO("Themes"); \
57 case ::syncer::TYPED_URLS: \
58 PER_DATA_TYPE_MACRO("TypedUrls"); \
60 case ::syncer::EXTENSIONS: \
61 PER_DATA_TYPE_MACRO("Extensions"); \
63 case ::syncer::NIGORI: \
64 PER_DATA_TYPE_MACRO("Nigori"); \
66 case ::syncer::SEARCH_ENGINES: \
67 PER_DATA_TYPE_MACRO("SearchEngines"); \
69 case ::syncer::SESSIONS: \
70 PER_DATA_TYPE_MACRO("Sessions"); \
72 case ::syncer::APPS: \
73 PER_DATA_TYPE_MACRO("Apps"); \
75 case ::syncer::APP_LIST: \
76 PER_DATA_TYPE_MACRO("AppList"); \
78 case ::syncer::APP_SETTINGS: \
79 PER_DATA_TYPE_MACRO("AppSettings"); \
81 case ::syncer::EXTENSION_SETTINGS: \
82 PER_DATA_TYPE_MACRO("ExtensionSettings"); \
84 case ::syncer::APP_NOTIFICATIONS: \
85 PER_DATA_TYPE_MACRO("AppNotifications"); \
87 case ::syncer::HISTORY_DELETE_DIRECTIVES: \
88 PER_DATA_TYPE_MACRO("HistoryDeleteDirectives"); \
90 case ::syncer::SYNCED_NOTIFICATIONS: \
91 PER_DATA_TYPE_MACRO("SyncedNotifications"); \
93 case ::syncer::SYNCED_NOTIFICATION_APP_INFO: \
94 PER_DATA_TYPE_MACRO("SyncedNotificationAppInfo"); \
96 case ::syncer::DEVICE_INFO: \
97 PER_DATA_TYPE_MACRO("DeviceInfo"); \
99 case ::syncer::EXPERIMENTS: \
100 PER_DATA_TYPE_MACRO("Experiments"); \
102 case ::syncer::PRIORITY_PREFERENCES :\
103 PER_DATA_TYPE_MACRO("PriorityPreferences"); \
105 case ::syncer::DICTIONARY: \
106 PER_DATA_TYPE_MACRO("Dictionary"); \
108 case ::syncer::FAVICON_IMAGES: \
109 PER_DATA_TYPE_MACRO("FaviconImages"); \
111 case ::syncer::FAVICON_TRACKING: \
112 PER_DATA_TYPE_MACRO("FaviconTracking"); \
114 case ::syncer::MANAGED_USER_SETTINGS: \
115 PER_DATA_TYPE_MACRO("ManagedUserSetting"); \
117 case ::syncer::MANAGED_USERS: \
118 PER_DATA_TYPE_MACRO("ManagedUser"); \
120 case ::syncer::MANAGED_USER_SHARED_SETTINGS: \
121 PER_DATA_TYPE_MACRO("ManagedUserSharedSetting"); \
123 case ::syncer::ARTICLES: \
124 PER_DATA_TYPE_MACRO("Article"); \
126 case ::syncer::PROXY_TABS: \
127 PER_DATA_TYPE_MACRO("Tabs"); \
130 NOTREACHED() << "Unknown datatype " \
131 << ::syncer::ModelTypeToString(datatype); \
135 #endif // SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_