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

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

Issue 1913373002: Revert "Refactor ProfileInfoCache in most of c/b/profiles" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 <vector>
8
9 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
10 #include "base/logging.h" 8 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
12 #include "build/build_config.h" 10 #include "build/build_config.h"
13 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/profiles/profile_attributes_entry.h" 13 #include "chrome/browser/profiles/profile_info_cache.h"
16 #include "chrome/browser/profiles/profile_attributes_storage.h"
17 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/browser/signin/chrome_signin_helper.h" 15 #include "chrome/browser/signin/chrome_signin_helper.h"
19 #include "chrome/browser/ui/browser_finder.h" 16 #include "chrome/browser/ui/browser_finder.h"
20 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
21 #include "chrome/installer/util/google_update_settings.h" 18 #include "chrome/installer/util/google_update_settings.h"
22 #include "components/profile_metrics/counts.h" 19 #include "components/profile_metrics/counts.h"
23 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/user_metrics.h" 21 #include "content/public/browser/user_metrics.h"
25 22
26 namespace { 23 namespace {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (manager) { 67 if (manager) {
71 user_data_dir = manager->user_data_dir(); 68 user_data_dir = manager->user_data_dir();
72 } 69 }
73 if (profile_path == user_data_dir.AppendASCII(chrome::kInitialProfile)) { 70 if (profile_path == user_data_dir.AppendASCII(chrome::kInitialProfile)) {
74 metric = ProfileMetrics::ORIGINAL; 71 metric = ProfileMetrics::ORIGINAL;
75 } 72 }
76 return metric; 73 return metric;
77 } 74 }
78 75
79 void LogLockedProfileInformation(ProfileManager* manager) { 76 void LogLockedProfileInformation(ProfileManager* manager) {
77 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache();
78 size_t number_of_profiles = info_cache.GetNumberOfProfiles();
79
80 base::Time now = base::Time::Now(); 80 base::Time now = base::Time::Now();
81 const int kMinutesInProfileValidDuration = 81 const int kMinutesInProfileValidDuration =
82 base::TimeDelta::FromDays(28).InMinutes(); 82 base::TimeDelta::FromDays(28).InMinutes();
83 std::vector<ProfileAttributesEntry*> entries = 83 for (size_t i = 0; i < number_of_profiles; ++i) {
84 manager->GetProfileAttributesStorage().GetAllProfilesAttributes();
85 for (ProfileAttributesEntry* entry : entries) {
86 // Find when locked profiles were locked 84 // Find when locked profiles were locked
87 if (entry->IsSigninRequired()) { 85 if (info_cache.ProfileIsSigninRequiredAtIndex(i)) {
88 base::TimeDelta time_since_lock = now - entry->GetActiveTime(); 86 base::TimeDelta time_since_lock = now -
87 info_cache.GetProfileActiveTimeAtIndex(i);
89 // Specifying 100 buckets for the histogram to get a higher level of 88 // Specifying 100 buckets for the histogram to get a higher level of
90 // granularity in the reported data, given the large number of possible 89 // granularity in the reported data, given the large number of possible
91 // values (kMinutesInProfileValidDuration > 40,000). 90 // values (kMinutesInProfileValidDuration > 40,000).
92 UMA_HISTOGRAM_CUSTOM_COUNTS("Profile.LockedProfilesDuration", 91 UMA_HISTOGRAM_CUSTOM_COUNTS("Profile.LockedProfilesDuration",
93 time_since_lock.InMinutes(), 92 time_since_lock.InMinutes(),
94 1, 93 1,
95 kMinutesInProfileValidDuration, 94 kMinutesInProfileValidDuration,
96 100); 95 100);
97 } 96 }
98 } 97 }
99 } 98 }
100 99
101 bool HasProfileBeenActiveSince(const ProfileAttributesEntry* entry, 100 bool HasProfileAtIndexBeenActiveSince(const ProfileInfoCache& info_cache,
102 const base::Time& active_limit) { 101 int index,
102 const base::Time& active_limit) {
103 #if !defined(OS_ANDROID) 103 #if !defined(OS_ANDROID)
104 // TODO(mlerman): iOS and Android should set an ActiveTime in the 104 // TODO(mlerman): iOS and Android should set an ActiveTime in the
105 // ProfileAttributesStorage. (see ProfileManager::OnBrowserSetLastActive) 105 // ProfileInfoCache. (see ProfileManager::OnBrowserSetLastActive)
106 if (entry->GetActiveTime() < active_limit) 106 if (info_cache.GetProfileActiveTimeAtIndex(index) < active_limit)
107 return false; 107 return false;
108 #endif 108 #endif
109 return true; 109 return true;
110 } 110 }
111 111
112 } // namespace 112 } // namespace
113 113
114 enum ProfileAvatar { 114 enum ProfileAvatar {
115 AVATAR_GENERIC = 0, // The names for avatar icons 115 AVATAR_GENERIC = 0, // The names for avatar icons
116 AVATAR_GENERIC_AQUA, 116 AVATAR_GENERIC_AQUA,
(...skipping 22 matching lines...) Expand all
139 AVATAR_NOTE, 139 AVATAR_NOTE,
140 AVATAR_SUN_CLOUD, 140 AVATAR_SUN_CLOUD,
141 AVATAR_PLACEHOLDER, 141 AVATAR_PLACEHOLDER,
142 AVATAR_UNKNOWN, // 27 142 AVATAR_UNKNOWN, // 27
143 AVATAR_GAIA, // 28 143 AVATAR_GAIA, // 28
144 NUM_PROFILE_AVATAR_METRICS 144 NUM_PROFILE_AVATAR_METRICS
145 }; 145 };
146 146
147 bool ProfileMetrics::CountProfileInformation(ProfileManager* manager, 147 bool ProfileMetrics::CountProfileInformation(ProfileManager* manager,
148 profile_metrics::Counts* counts) { 148 profile_metrics::Counts* counts) {
149 ProfileAttributesStorage& storage = manager->GetProfileAttributesStorage(); 149 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache();
150 size_t number_of_profiles = storage.GetNumberOfProfiles(); 150 size_t number_of_profiles = info_cache.GetNumberOfProfiles();
151 counts->total = number_of_profiles; 151 counts->total = number_of_profiles;
152 152
153 // Ignore other metrics if we have no profiles. 153 // Ignore other metrics if we have no profiles.
154 if (!number_of_profiles) 154 if (!number_of_profiles)
155 return false; 155 return false;
156 156
157 // Maximum age for "active" profile is 4 weeks. 157 // Maximum age for "active" profile is 4 weeks.
158 base::Time oldest = base::Time::Now() - 158 base::Time oldest = base::Time::Now() -
159 base::TimeDelta::FromDays(kMaximumDaysOfDisuse); 159 base::TimeDelta::FromDays(kMaximumDaysOfDisuse);
160 160
161 std::vector<ProfileAttributesEntry*> entries = 161 for (size_t i = 0; i < number_of_profiles; ++i) {
162 storage.GetAllProfilesAttributes(); 162 if (!HasProfileAtIndexBeenActiveSince(info_cache, i, oldest)) {
163 for (ProfileAttributesEntry* entry : entries) {
164 if (!HasProfileBeenActiveSince(entry, oldest)) {
165 counts->unused++; 163 counts->unused++;
166 } else { 164 } else {
167 if (entry->IsSupervised()) 165 if (info_cache.ProfileIsSupervisedAtIndex(i))
168 counts->supervised++; 166 counts->supervised++;
169 if (entry->IsAuthenticated()) { 167 if (info_cache.ProfileIsAuthenticatedAtIndex(i)) {
170 counts->signedin++; 168 counts->signedin++;
171 if (entry->IsUsingGAIAPicture()) 169 if (info_cache.IsUsingGAIAPictureOfProfileAtIndex(i))
172 counts->gaia_icon++; 170 counts->gaia_icon++;
173 if (entry->IsAuthError()) 171 if (info_cache.ProfileIsAuthErrorAtIndex(i))
174 counts->auth_errors++; 172 counts->auth_errors++;
175 } 173 }
176 } 174 }
177 } 175 }
178 return true; 176 return true;
179 } 177 }
180 178
181 void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) { 179 void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) {
182 #if defined(OS_WIN) || defined(OS_MACOSX) 180 #if defined(OS_WIN) || defined(OS_MACOSX)
183 profile_metrics::Counts counts; 181 profile_metrics::Counts counts;
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", 542 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn",
545 GetProfileType(profile_path), 543 GetProfileType(profile_path),
546 NUM_PROFILE_TYPE_METRICS); 544 NUM_PROFILE_TYPE_METRICS);
547 } 545 }
548 546
549 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { 547 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) {
550 UMA_HISTOGRAM_ENUMERATION("Profile.Update", 548 UMA_HISTOGRAM_ENUMERATION("Profile.Update",
551 GetProfileType(profile_path), 549 GetProfileType(profile_path),
552 NUM_PROFILE_TYPE_METRICS); 550 NUM_PROFILE_TYPE_METRICS);
553 } 551 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager_unittest.cc ('k') | chrome/browser/profiles/profile_shortcut_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698