summaryrefslogtreecommitdiffstats
path: root/sync/util/data_type_histogram.h
blob: 11be1ec33e4f4b111e864154ee8c605786d098ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// 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 SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_
#define SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_

#include "base/metrics/histogram.h"
#include "base/time/time.h"
#include "sync/internal_api/public/base/model_type.h"

// 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::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::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::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::MANAGED_USER_SETTINGS: \
        PER_DATA_TYPE_MACRO("ManagedUserSetting"); \
        break; \
      case ::syncer::MANAGED_USERS: \
        PER_DATA_TYPE_MACRO("ManagedUser"); \
        break; \
      case ::syncer::MANAGED_USER_SHARED_SETTINGS: \
        PER_DATA_TYPE_MACRO("ManagedUserSharedSetting"); \
        break; \
      case ::syncer::ARTICLES: \
        PER_DATA_TYPE_MACRO("Article"); \
        break; \
      case ::syncer::PROXY_TABS: \
        PER_DATA_TYPE_MACRO("Tabs"); \
        break; \
      default: \
        NOTREACHED() << "Unknown datatype " \
                     << ::syncer::ModelTypeToString(datatype);  \
    } \
  } while (0)

#endif  // SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_