Index: components/sync/base/data_type_histogram.h |
diff --git a/components/sync/base/data_type_histogram.h b/components/sync/base/data_type_histogram.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b282b12affee9d7b7a9950b8c995a5a6531e789e |
--- /dev/null |
+++ b/components/sync/base/data_type_histogram.h |
@@ -0,0 +1,158 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_SYNC_BASE_DATA_TYPE_HISTOGRAM_H_ |
+#define COMPONENTS_SYNC_BASE_DATA_TYPE_HISTOGRAM_H_ |
+ |
+#include <string> |
+ |
+#include "base/metrics/histogram_macros.h" |
+#include "base/time/time.h" |
+#include "components/sync/base/model_type.h" |
+ |
+// This function adds |value| to |sample| bucket of histogram |name|. |value| |
+// should be greater or equal to 1 and |name| can be variable. DataTypes are |
+// mapped to proper |sample| bucket by using ModelTypeToHistogramInt() function. |
+// So different DataTypes play the role of different buckets in this histogram. |
+void SyncRecordDatatypeBin(const std::string& name, int sample, int value); |
+ |
+// For now, this just implements UMA_HISTOGRAM_LONG_TIMES. This can be adjusted |
+// if we feel the min, max, or bucket count amount are not appropriate. |
+#define SYNC_FREQ_HISTOGRAM(name, time) \ |
+ UMA_HISTOGRAM_CUSTOM_TIMES(name, time, base::TimeDelta::FromMilliseconds(1), \ |
+ base::TimeDelta::FromHours(1), 50) |
+ |
+// Helper macro for datatype specific histograms. For each datatype, invokes |
+// a pre-defined PER_DATA_TYPE_MACRO(type_str), where |type_str| is the string |
+// version of the datatype. |
+// |
+// Example usage (ignoring newlines necessary for multiline macro): |
+// std::vector<syncer::ModelType> types = GetEntryTypes(); |
+// for (int i = 0; i < types.size(); ++i) { |
+// #define PER_DATA_TYPE_MACRO(type_str) |
+// UMA_HISTOGRAM_ENUMERATION("Sync." type_str "StartFailures", |
+// error, max_error); |
+// SYNC_DATA_TYPE_HISTOGRAM(types[i]); |
+// #undef PER_DATA_TYPE_MACRO |
+// } |
+// |
+// TODO(zea): Once visual studio supports proper variadic argument replacement |
+// in macros, pass in the histogram method directly as a parameter. |
+// See http://connect.microsoft.com/VisualStudio/feedback/details/380090/ |
+// variadic-macro-replacement#details |
+#define SYNC_DATA_TYPE_HISTOGRAM(datatype) \ |
+ do { \ |
+ switch (datatype) { \ |
+ case ::syncer::BOOKMARKS: \ |
+ PER_DATA_TYPE_MACRO("Bookmarks"); \ |
+ break; \ |
+ case ::syncer::PREFERENCES: \ |
+ PER_DATA_TYPE_MACRO("Preferences"); \ |
+ break; \ |
+ case ::syncer::PASSWORDS: \ |
+ PER_DATA_TYPE_MACRO("Passwords"); \ |
+ break; \ |
+ case ::syncer::AUTOFILL: \ |
+ PER_DATA_TYPE_MACRO("Autofill"); \ |
+ break; \ |
+ case ::syncer::AUTOFILL_PROFILE: \ |
+ PER_DATA_TYPE_MACRO("AutofillProfiles"); \ |
+ break; \ |
+ case ::syncer::AUTOFILL_WALLET_DATA: \ |
+ PER_DATA_TYPE_MACRO("AutofillWallet"); \ |
+ break; \ |
+ case ::syncer::AUTOFILL_WALLET_METADATA: \ |
+ PER_DATA_TYPE_MACRO("AutofillWalletMetadata"); \ |
+ break; \ |
+ case ::syncer::THEMES: \ |
+ PER_DATA_TYPE_MACRO("Themes"); \ |
+ break; \ |
+ case ::syncer::TYPED_URLS: \ |
+ PER_DATA_TYPE_MACRO("TypedUrls"); \ |
+ break; \ |
+ case ::syncer::EXTENSIONS: \ |
+ PER_DATA_TYPE_MACRO("Extensions"); \ |
+ break; \ |
+ case ::syncer::NIGORI: \ |
+ PER_DATA_TYPE_MACRO("Nigori"); \ |
+ break; \ |
+ case ::syncer::SEARCH_ENGINES: \ |
+ PER_DATA_TYPE_MACRO("SearchEngines"); \ |
+ break; \ |
+ case ::syncer::SESSIONS: \ |
+ PER_DATA_TYPE_MACRO("Sessions"); \ |
+ break; \ |
+ case ::syncer::APPS: \ |
+ PER_DATA_TYPE_MACRO("Apps"); \ |
+ break; \ |
+ case ::syncer::APP_LIST: \ |
+ PER_DATA_TYPE_MACRO("AppList"); \ |
+ break; \ |
+ case ::syncer::APP_SETTINGS: \ |
+ PER_DATA_TYPE_MACRO("AppSettings"); \ |
+ break; \ |
+ case ::syncer::ARC_PACKAGE: \ |
+ PER_DATA_TYPE_MACRO("ArcPackage"); \ |
+ break; \ |
+ case ::syncer::EXTENSION_SETTINGS: \ |
+ PER_DATA_TYPE_MACRO("ExtensionSettings"); \ |
+ break; \ |
+ case ::syncer::APP_NOTIFICATIONS: \ |
+ PER_DATA_TYPE_MACRO("AppNotifications"); \ |
+ break; \ |
+ case ::syncer::HISTORY_DELETE_DIRECTIVES: \ |
+ PER_DATA_TYPE_MACRO("HistoryDeleteDirectives"); \ |
+ break; \ |
+ case ::syncer::SYNCED_NOTIFICATIONS: \ |
+ PER_DATA_TYPE_MACRO("SyncedNotifications"); \ |
+ break; \ |
+ case ::syncer::SYNCED_NOTIFICATION_APP_INFO: \ |
+ PER_DATA_TYPE_MACRO("SyncedNotificationAppInfo"); \ |
+ break; \ |
+ case ::syncer::DEVICE_INFO: \ |
+ PER_DATA_TYPE_MACRO("DeviceInfo"); \ |
+ break; \ |
+ case ::syncer::EXPERIMENTS: \ |
+ PER_DATA_TYPE_MACRO("Experiments"); \ |
+ break; \ |
+ case ::syncer::PRIORITY_PREFERENCES: \ |
+ PER_DATA_TYPE_MACRO("PriorityPreferences"); \ |
+ break; \ |
+ case ::syncer::DICTIONARY: \ |
+ PER_DATA_TYPE_MACRO("Dictionary"); \ |
+ break; \ |
+ case ::syncer::FAVICON_IMAGES: \ |
+ PER_DATA_TYPE_MACRO("FaviconImages"); \ |
+ break; \ |
+ case ::syncer::FAVICON_TRACKING: \ |
+ PER_DATA_TYPE_MACRO("FaviconTracking"); \ |
+ break; \ |
+ case ::syncer::SUPERVISED_USER_SETTINGS: \ |
+ PER_DATA_TYPE_MACRO("ManagedUserSetting"); \ |
+ break; \ |
+ case ::syncer::SUPERVISED_USERS: \ |
+ PER_DATA_TYPE_MACRO("ManagedUser"); \ |
+ break; \ |
+ case ::syncer::SUPERVISED_USER_SHARED_SETTINGS: \ |
+ PER_DATA_TYPE_MACRO("ManagedUserSharedSetting"); \ |
+ break; \ |
+ case ::syncer::SUPERVISED_USER_WHITELISTS: \ |
+ PER_DATA_TYPE_MACRO("ManagedUserWhitelist"); \ |
+ break; \ |
+ case ::syncer::ARTICLES: \ |
+ PER_DATA_TYPE_MACRO("Article"); \ |
+ break; \ |
+ case ::syncer::WIFI_CREDENTIALS: \ |
+ PER_DATA_TYPE_MACRO("WifiCredentials"); \ |
+ break; \ |
+ case ::syncer::PROXY_TABS: \ |
+ PER_DATA_TYPE_MACRO("Tabs"); \ |
+ break; \ |
+ default: \ |
+ NOTREACHED() << "Unknown datatype " \ |
+ << ::syncer::ModelTypeToString(datatype); \ |
+ } \ |
+ } while (0) |
+ |
+#endif // COMPONENTS_SYNC_BASE_DATA_TYPE_HISTOGRAM_H_ |