Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / profiles / profile_metrics.h
blob0f343121338007ec5de73f24996936f6cc1cd9fa
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 CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_
8 #include <stddef.h>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "chrome/browser/signin/signin_header_helper.h"
14 class Profile;
15 class ProfileManager;
17 namespace base {
18 class FilePath;
21 class ProfileMetrics {
22 public:
23 struct ProfileCounts {
24 size_t total;
25 size_t signedin;
26 size_t supervised;
27 size_t unused;
28 size_t gaia_icon;
30 ProfileCounts()
31 : total(0), signedin(0), supervised(0), unused(0), gaia_icon(0) {}
34 // Enum for counting the ways users were added.
35 enum ProfileAdd {
36 ADD_NEW_USER_ICON = 0, // User adds new user from icon menu
37 ADD_NEW_USER_MENU, // User adds new user from menu bar
38 ADD_NEW_USER_DIALOG, // User adds new user from create-profile dialog
39 ADD_NEW_USER_MANAGER, // User adds new user from User Manager
40 ADD_NEW_USER_LAST_DELETED, // Auto-created after deleting last user
41 NUM_PROFILE_ADD_METRICS
44 enum ProfileDelete {
45 DELETE_PROFILE_SETTINGS = 0, // Delete profile from settings page.
46 DELETE_PROFILE_USER_MANAGER, // Delete profile from User Manager.
47 NUM_DELETE_PROFILE_METRICS
50 // Enum for counting the ways user profiles and menus were opened.
51 enum ProfileOpen {
52 NTP_AVATAR_BUBBLE = 0, // User opens avatar icon menu from NTP
53 ICON_AVATAR_BUBBLE, // User opens avatar icon menu from icon
54 SWITCH_PROFILE_ICON, // User switches profiles from icon menu
55 SWITCH_PROFILE_MENU, // User switches profiles from menu bar
56 SWITCH_PROFILE_DOCK, // User switches profiles from dock (Mac-only)
57 OPEN_USER_MANAGER, // User opens the User Manager
58 SWITCH_PROFILE_MANAGER, // User switches profiles from the User Manager
59 SWITCH_PROFILE_UNLOCK, // User switches to lockd profile via User Manager
60 SWITCH_PROFILE_GUEST, // User switches to guest profile
61 NUM_PROFILE_OPEN_METRICS
64 // Enum for getting net counts for adding and deleting users.
65 enum ProfileNetUserCounts {
66 ADD_NEW_USER = 0, // Total count of add new user
67 PROFILE_DELETED, // User deleted a profile
68 NUM_PROFILE_NET_METRICS
71 // Sign in is logged once the user has entered their GAIA information.
72 // The options for sync are logged after the user has submitted the options
73 // form. See sync_setup_handler.h.
74 enum ProfileSync {
75 SYNC_CUSTOMIZE = 0, // User decided to customize sync
76 SYNC_CHOOSE, // User chose what to sync
77 SYNC_ENCRYPT, // User has chosen to encrypt all data
78 SYNC_PASSPHRASE, // User is using a passphrase
79 NUM_PROFILE_SYNC_METRICS
82 enum ProfileType {
83 ORIGINAL = 0, // Refers to the original/default profile
84 SECONDARY, // Refers to a user-created profile
85 NUM_PROFILE_TYPE_METRICS
88 enum ProfileGaia {
89 GAIA_OPT_IN = 0, // User changed to GAIA photo as avatar
90 GAIA_OPT_OUT, // User changed to not use GAIA photo as avatar
91 NUM_PROFILE_GAIA_METRICS
94 enum ProfileAuth {
95 AUTH_UNNECESSARY, // Profile was not locked
96 AUTH_LOCAL, // Profile was authenticated locally
97 AUTH_ONLINE, // Profile was authenticated on-line
98 AUTH_FAILED, // Profile failed authentication
99 AUTH_FAILED_OFFLINE, // Profile failed authentication and was offline
100 NUM_PROFILE_AUTH_METRICS
103 // Enum for tracking user interactions with the user menu and user manager.
104 // Interactions initiated from the content area are logged into a different
105 // histogram from those that were initiated from the avatar button.
106 // An example of the interaction beginning in the content area is
107 // clicking "Manage Accounts" within account selection on a Google property.
108 enum ProfileDesktopMenu {
109 // User opened the user menu, and clicked lock.
110 PROFILE_DESKTOP_MENU_LOCK = 0,
111 // User opened the user menu, and removed an account.
112 PROFILE_DESKTOP_MENU_REMOVE_ACCT,
113 // User opened the user menu, and started adding an account.
114 PROFILE_DESKTOP_MENU_ADD_ACCT,
115 // User opened the user menu, and changed the profile name.
116 PROFILE_DESKTOP_MENU_EDIT_NAME,
117 // User opened the user menu, and started selecting a new profile image.
118 PROFILE_DESKTOP_MENU_EDIT_IMAGE,
119 // User opened the user menu, and opened the user manager.
120 PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER,
121 NUM_PROFILE_DESKTOP_MENU_METRICS,
124 #if defined(OS_ANDROID)
125 // Enum for tracking user interactions with the account management menu
126 // on Android.
127 enum ProfileAndroidAccountManagementMenu {
129 #define PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU(label, value) \
130 PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_##label = value,
131 #include "profile_metrics_list.h"
132 #undef PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU
134 NUM_PROFILE_ANDROID_ACCOUNT_MANAGEMENT_MENU_METRICS,
136 #endif // defined(OS_ANDROID)
138 // Enum for tracking user interactions with the 'Not You?' bubble that users
139 // can navigate to from the Upgrade bubble after upgrade.
140 enum ProfileNewAvatarMenuNotYou {
141 // User views the 'Not You?' bubble.
142 PROFILE_AVATAR_MENU_NOT_YOU_VIEW = 0,
143 // User selects back from within the 'Not You?' bubble.
144 PROFILE_AVATAR_MENU_NOT_YOU_BACK,
145 // User adds a person from within the 'Not You?' bubble.
146 PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON,
147 // User chooses to disconnect (sign out) from within the 'Not You?' bubble.
148 PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT,
149 NUM_PROFILE_AVATAR_MENU_NOT_YOU_METRICS,
152 // Enum for tracking user interactions with the signin bubble that appears
153 // in the New Avatar Menu after using the Inline Signin flow.
154 enum ProfileNewAvatarMenuSignin {
155 // User viewed the signin bubble after successfully using the inline signin.
156 PROFILE_AVATAR_MENU_SIGNIN_VIEW = 0,
157 // User selected ok to dismiss the signin bubble.
158 PROFILE_AVATAR_MENU_SIGNIN_OK,
159 // User opened the settings from the signin bubble.
160 PROFILE_AVATAR_MENU_SIGNIN_SETTINGS,
161 NUM_PROFILE_AVATAR_MENU_SIGNIN_METRICS,
164 // Enum for tracking user interactions with the bubble that appears for all
165 // users in the new avatar menu after upgrading.
166 enum ProfileNewAvatarMenuUpgrade {
167 // User views the upgrade bubble.
168 PROFILE_AVATAR_MENU_UPGRADE_VIEW = 0,
169 // User dismissed the upgrade bubble.
170 PROFILE_AVATAR_MENU_UPGRADE_DISMISS,
171 // User selects 'What's New' in the upgrade bubble.
172 PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW,
173 // User selects 'Not You?' in the upgrade bubble.
174 PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU,
175 NUM_PROFILE_AVATAR_MENU_UPGRADE_METRICS,
178 static void UpdateReportedProfilesStatistics(ProfileManager* manager);
179 // Count and return summary information about the profiles currently in the
180 // |manager|. This information is returned in the output variable |counts|.
181 static bool CountProfileInformation(ProfileManager* manager,
182 ProfileCounts* counts);
184 static void LogNumberOfProfiles(ProfileManager* manager);
185 static void LogProfileAddNewUser(ProfileAdd metric);
186 static void LogProfileAvatarSelection(size_t icon_index);
187 static void LogProfileDeleteUser(ProfileDelete metric);
188 static void LogProfileOpenMethod(ProfileOpen metric);
189 static void LogProfileSwitchGaia(ProfileGaia metric);
190 static void LogProfileSwitchUser(ProfileOpen metric);
191 static void LogProfileSyncInfo(ProfileSync metric);
192 static void LogProfileAuthResult(ProfileAuth metric);
193 static void LogProfileDesktopMenu(ProfileDesktopMenu metric,
194 signin::GAIAServiceType gaia_service);
195 static void LogProfileDelete(bool profile_was_signed_in);
196 static void LogProfileNewAvatarMenuNotYou(ProfileNewAvatarMenuNotYou metric);
197 static void LogProfileNewAvatarMenuSignin(ProfileNewAvatarMenuSignin metric);
198 static void LogProfileNewAvatarMenuUpgrade(
199 ProfileNewAvatarMenuUpgrade metric);
201 #if defined(OS_ANDROID)
202 static void LogProfileAndroidAccountManagementMenu(
203 ProfileAndroidAccountManagementMenu metric,
204 signin::GAIAServiceType gaia_service);
205 #endif // defined(OS_ANDROID)
207 // These functions should only be called on the UI thread because they hook
208 // into g_browser_process through a helper function.
209 static void LogProfileLaunch(Profile* profile);
210 static void LogProfileSyncSignIn(const base::FilePath& profile_path);
211 static void LogProfileUpdate(const base::FilePath& profile_path);
215 #endif // CHROME_BROWSER_PROFILES_PROFILE_METRICS_H_