Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: chrome/browser/profiles/profile_metrics.cc

Issue 593243002: Profile_Metrics integration with Keystone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove separate attribute header; refactor setActive methods. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/profiles/profile_metrics.h" 5 #include "chrome/browser/profiles/profile_metrics.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 20 matching lines...) Expand all
31 // In unittests, we do not always have a profile_manager so check. 31 // In unittests, we do not always have a profile_manager so check.
32 if (manager) { 32 if (manager) {
33 user_data_dir = manager->user_data_dir(); 33 user_data_dir = manager->user_data_dir();
34 } 34 }
35 if (profile_path == user_data_dir.AppendASCII(chrome::kInitialProfile)) { 35 if (profile_path == user_data_dir.AppendASCII(chrome::kInitialProfile)) {
36 metric = ProfileMetrics::ORIGINAL; 36 metric = ProfileMetrics::ORIGINAL;
37 } 37 }
38 return metric; 38 return metric;
39 } 39 }
40 40
41 void UpdateReportedOSProfileStatistics(int active, int signedin) {
42 #if defined(OS_WIN)
43 GoogleUpdateSettings::UpdateProfileCounts(active, signedin);
44 #endif
45 }
46
47 void LogLockedProfileInformation(ProfileManager* manager) { 41 void LogLockedProfileInformation(ProfileManager* manager) {
48 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache(); 42 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache();
49 size_t number_of_profiles = info_cache.GetNumberOfProfiles(); 43 size_t number_of_profiles = info_cache.GetNumberOfProfiles();
50 44
51 base::Time now = base::Time::Now(); 45 base::Time now = base::Time::Now();
52 const int kMinutesInProfileValidDuration = 46 const int kMinutesInProfileValidDuration =
53 base::TimeDelta::FromDays(28).InMinutes(); 47 base::TimeDelta::FromDays(28).InMinutes();
54 for (size_t i = 0; i < number_of_profiles; ++i) { 48 for (size_t i = 0; i < number_of_profiles; ++i) {
55 // Find when locked profiles were locked 49 // Find when locked profiles were locked
56 if (info_cache.ProfileIsSigninRequiredAtIndex(i)) { 50 if (info_cache.ProfileIsSigninRequiredAtIndex(i)) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 136 }
143 } 137 }
144 } 138 }
145 return true; 139 return true;
146 } 140 }
147 141
148 142
149 void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) { 143 void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) {
150 ProfileCounts counts; 144 ProfileCounts counts;
151 if (CountProfileInformation(manager, &counts)) { 145 if (CountProfileInformation(manager, &counts)) {
152 int limited_total = counts.total; 146 int limited_total = counts.total;
Mark Mentovai 2014/10/09 21:26:21 Other option: change these to size_t. All of the f
Mike Lerman 2014/10/10 15:32:29 Ok. I changed the profile_metrics code to work wit
153 int limited_signedin = counts.signedin; 147 int limited_signedin = counts.signedin;
154 if (limited_total > kMaximumReportedProfileCount) { 148 if (limited_total > kMaximumReportedProfileCount) {
155 limited_total = kMaximumReportedProfileCount + 1; 149 limited_total = kMaximumReportedProfileCount + 1;
156 limited_signedin = 150 limited_signedin =
157 (int)((float)(counts.signedin * limited_total) 151 (int)((float)(counts.signedin * limited_total)
158 / counts.total + 0.5); 152 / counts.total + 0.5);
159 } 153 }
154 #if defined(OS_WIN) || defined(OS_MACOSX)
160 UpdateReportedOSProfileStatistics(limited_total, limited_signedin); 155 UpdateReportedOSProfileStatistics(limited_total, limited_signedin);
156 #endif
161 } 157 }
162 } 158 }
163 159
160 // The MACOSX implementation of this function is in profile_metrics_mac.mm.
161 #if defined(OS_WIN)
162 void ProfileMetrics::UpdateReportedOSProfileStatistics(
163 int active, int signedin) {
164 GoogleUpdateSettings::UpdateProfileCounts(active, signedin);
165 }
166 #endif
167
164 void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager) { 168 void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager) {
165 ProfileCounts counts; 169 ProfileCounts counts;
166 bool success = CountProfileInformation(manager, &counts); 170 bool success = CountProfileInformation(manager, &counts);
167 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfiles", counts.total); 171 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfiles", counts.total);
168 172
169 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. 173 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests.
170 if (success) { 174 if (success) {
171 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfManagedProfiles", 175 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfManagedProfiles",
172 counts.supervised); 176 counts.supervised);
173 UMA_HISTOGRAM_COUNTS_100("Profile.PercentageOfManagedProfiles", 177 UMA_HISTOGRAM_COUNTS_100("Profile.PercentageOfManagedProfiles",
174 100 * counts.supervised / counts.total); 178 100 * counts.supervised / counts.total);
175 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfiles", 179 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfiles",
176 counts.signedin); 180 counts.signedin);
177 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfUnusedProfiles", 181 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfUnusedProfiles",
178 counts.unused); 182 counts.unused);
179 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfilesWithGAIAIcons", 183 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfilesWithGAIAIcons",
180 counts.gaia_icon); 184 counts.gaia_icon);
181 185
182 LogLockedProfileInformation(manager); 186 LogLockedProfileInformation(manager);
187
188 #if defined(OS_WIN) || defined(OS_MACOSX)
183 UpdateReportedOSProfileStatistics(counts.total, counts.signedin); 189 UpdateReportedOSProfileStatistics(counts.total, counts.signedin);
190 #endif
184 } 191 }
185 } 192 }
186 193
187 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) { 194 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) {
188 DCHECK(metric < NUM_PROFILE_ADD_METRICS); 195 DCHECK(metric < NUM_PROFILE_ADD_METRICS);
189 UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric, 196 UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric,
190 NUM_PROFILE_ADD_METRICS); 197 NUM_PROFILE_ADD_METRICS);
191 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER, 198 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER,
192 NUM_PROFILE_NET_METRICS); 199 NUM_PROFILE_NET_METRICS);
193 } 200 }
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", 467 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn",
461 GetProfileType(profile_path), 468 GetProfileType(profile_path),
462 NUM_PROFILE_TYPE_METRICS); 469 NUM_PROFILE_TYPE_METRICS);
463 } 470 }
464 471
465 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { 472 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) {
466 UMA_HISTOGRAM_ENUMERATION("Profile.Update", 473 UMA_HISTOGRAM_ENUMERATION("Profile.Update",
467 GetProfileType(profile_path), 474 GetProfileType(profile_path),
468 NUM_PROFILE_TYPE_METRICS); 475 NUM_PROFILE_TYPE_METRICS);
469 } 476 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698