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

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

Issue 928633002: Add some tracing for Profiles and Extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: additionally mark some of the traces as startup Created 5 years, 10 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
« no previous file with comments | « chrome/browser/extensions/installed_loader.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_manager.h" 5 #include "chrome/browser/profiles/profile_manager.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 std::vector<Profile*> profiles; 554 std::vector<Profile*> profiles;
555 for (ProfilesInfoMap::const_iterator iter = profiles_info_.begin(); 555 for (ProfilesInfoMap::const_iterator iter = profiles_info_.begin();
556 iter != profiles_info_.end(); ++iter) { 556 iter != profiles_info_.end(); ++iter) {
557 if (iter->second->created) 557 if (iter->second->created)
558 profiles.push_back(iter->second->profile.get()); 558 profiles.push_back(iter->second->profile.get());
559 } 559 }
560 return profiles; 560 return profiles;
561 } 561 }
562 562
563 Profile* ProfileManager::GetProfileByPath(const base::FilePath& path) const { 563 Profile* ProfileManager::GetProfileByPath(const base::FilePath& path) const {
564 TRACE_EVENT0("browser", "ProfileManager::GetProfileByPath");
564 ProfileInfo* profile_info = GetProfileInfoByPath(path); 565 ProfileInfo* profile_info = GetProfileInfoByPath(path);
565 return profile_info ? profile_info->profile.get() : NULL; 566 return profile_info ? profile_info->profile.get() : NULL;
566 } 567 }
567 568
568 // static 569 // static
569 base::FilePath ProfileManager::CreateMultiProfileAsync( 570 base::FilePath ProfileManager::CreateMultiProfileAsync(
570 const base::string16& name, 571 const base::string16& name,
571 const base::string16& icon_url, 572 const base::string16& icon_url,
572 const CreateCallback& callback, 573 const CreateCallback& callback,
573 const std::string& supervised_user_id) { 574 const std::string& supervised_user_id) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 #if defined(OS_WIN) 620 #if defined(OS_WIN)
620 new_path = new_path.Append(base::ASCIIToUTF16(profile_name)); 621 new_path = new_path.Append(base::ASCIIToUTF16(profile_name));
621 #else 622 #else
622 new_path = new_path.Append(profile_name); 623 new_path = new_path.Append(profile_name);
623 #endif 624 #endif
624 local_state->SetInteger(prefs::kProfilesNumCreated, ++next_directory); 625 local_state->SetInteger(prefs::kProfilesNumCreated, ++next_directory);
625 return new_path; 626 return new_path;
626 } 627 }
627 628
628 ProfileInfoCache& ProfileManager::GetProfileInfoCache() { 629 ProfileInfoCache& ProfileManager::GetProfileInfoCache() {
630 TRACE_EVENT0("browser", "ProfileManager::GetProfileInfoCache");
629 if (!profile_info_cache_) { 631 if (!profile_info_cache_) {
630 profile_info_cache_.reset(new ProfileInfoCache( 632 profile_info_cache_.reset(new ProfileInfoCache(
631 g_browser_process->local_state(), user_data_dir_)); 633 g_browser_process->local_state(), user_data_dir_));
632 } 634 }
633 return *profile_info_cache_.get(); 635 return *profile_info_cache_.get();
634 } 636 }
635 637
636 ProfileShortcutManager* ProfileManager::profile_shortcut_manager() { 638 ProfileShortcutManager* ProfileManager::profile_shortcut_manager() {
637 return profile_shortcut_manager_.get(); 639 return profile_shortcut_manager_.get();
638 } 640 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 if (cache.GetBackgroundStatusOfProfileAtIndex(p)) { 759 if (cache.GetBackgroundStatusOfProfileAtIndex(p)) {
758 // If status is true, that profile is running background apps. By calling 760 // If status is true, that profile is running background apps. By calling
759 // GetProfile, we automatically cause the profile to be loaded which will 761 // GetProfile, we automatically cause the profile to be loaded which will
760 // register it with the BackgroundModeManager. 762 // register it with the BackgroundModeManager.
761 GetProfile(cache.GetPathOfProfileAtIndex(p)); 763 GetProfile(cache.GetPathOfProfileAtIndex(p));
762 } 764 }
763 } 765 }
764 } 766 }
765 767
766 void ProfileManager::InitProfileUserPrefs(Profile* profile) { 768 void ProfileManager::InitProfileUserPrefs(Profile* profile) {
769 TRACE_EVENT0("browser", "ProfileManager::InitProfileUserPrefs");
767 ProfileInfoCache& cache = GetProfileInfoCache(); 770 ProfileInfoCache& cache = GetProfileInfoCache();
768 771
769 if (profile->GetPath().DirName() != cache.GetUserDataDir()) 772 if (profile->GetPath().DirName() != cache.GetUserDataDir())
770 return; 773 return;
771 774
772 size_t avatar_index; 775 size_t avatar_index;
773 std::string profile_name; 776 std::string profile_name;
774 std::string supervised_user_id; 777 std::string supervised_user_id;
775 if (profile->IsGuestSession()) { 778 if (profile->IsGuestSession()) {
776 profile_name = l10n_util::GetStringUTF8(IDS_PROFILES_GUEST_PROFILE_NAME); 779 profile_name = l10n_util::GetStringUTF8(IDS_PROFILES_GUEST_PROFILE_NAME);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 RunCallbacks(callbacks, profile, Profile::CREATE_STATUS_CREATED); 996 RunCallbacks(callbacks, profile, Profile::CREATE_STATUS_CREATED);
994 } 997 }
995 998
996 // Invoke INITIALIZED or FAIL for all profiles. 999 // Invoke INITIALIZED or FAIL for all profiles.
997 RunCallbacks(callbacks, profile, 1000 RunCallbacks(callbacks, profile,
998 profile ? Profile::CREATE_STATUS_INITIALIZED : 1001 profile ? Profile::CREATE_STATUS_INITIALIZED :
999 Profile::CREATE_STATUS_LOCAL_FAIL); 1002 Profile::CREATE_STATUS_LOCAL_FAIL);
1000 } 1003 }
1001 1004
1002 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) { 1005 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) {
1006 TRACE_EVENT0("browser", "ProfileManager::DoFinalInit");
1003 DoFinalInitForServices(profile, go_off_the_record); 1007 DoFinalInitForServices(profile, go_off_the_record);
1004 AddProfileToCache(profile); 1008 AddProfileToCache(profile);
1005 DoFinalInitLogging(profile); 1009 DoFinalInitLogging(profile);
1006 1010
1007 ProfileMetrics::LogNumberOfProfiles(this); 1011 ProfileMetrics::LogNumberOfProfiles(this);
1008 content::NotificationService::current()->Notify( 1012 content::NotificationService::current()->Notify(
1009 chrome::NOTIFICATION_PROFILE_ADDED, 1013 chrome::NOTIFICATION_PROFILE_ADDED,
1010 content::Source<Profile>(profile), 1014 content::Source<Profile>(profile),
1011 content::NotificationService::NoDetails()); 1015 content::NotificationService::NoDetails());
1012 } 1016 }
1013 1017
1014 void ProfileManager::DoFinalInitForServices(Profile* profile, 1018 void ProfileManager::DoFinalInitForServices(Profile* profile,
1015 bool go_off_the_record) { 1019 bool go_off_the_record) {
1020 TRACE_EVENT0("browser", "ProfileManager::DoFinalInitForServices");
1016 #if defined(ENABLE_EXTENSIONS) 1021 #if defined(ENABLE_EXTENSIONS)
1017 ProfileInfoCache& cache = GetProfileInfoCache(); 1022 ProfileInfoCache& cache = GetProfileInfoCache();
1018 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( 1023 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile(
1019 !go_off_the_record); 1024 !go_off_the_record);
1020 // During tests, when |profile| is an instance of TestingProfile, 1025 // During tests, when |profile| is an instance of TestingProfile,
1021 // ExtensionSystem might not create an ExtensionService. 1026 // ExtensionSystem might not create an ExtensionService.
1022 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { 1027 if (extensions::ExtensionSystem::Get(profile)->extension_service()) {
1023 extensions::ExtensionSystem::Get(profile)->extension_service()-> 1028 extensions::ExtensionSystem::Get(profile)->extension_service()->
1024 RegisterContentSettings(profile->GetHostContentSettingsMap()); 1029 RegisterContentSettings(profile->GetHostContentSettingsMap());
1025 } 1030 }
(...skipping 22 matching lines...) Expand all
1048 // Activate data reduction proxy. This creates a request context and makes a 1053 // Activate data reduction proxy. This creates a request context and makes a
1049 // URL request to check if the data reduction proxy server is reachable. 1054 // URL request to check if the data reduction proxy server is reachable.
1050 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile)-> 1055 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile)->
1051 MaybeActivateDataReductionProxy(true); 1056 MaybeActivateDataReductionProxy(true);
1052 1057
1053 AccountTrackerServiceFactory::GetForProfile(profile)->EnableNetworkFetches(); 1058 AccountTrackerServiceFactory::GetForProfile(profile)->EnableNetworkFetches();
1054 AccountReconcilorFactory::GetForProfile(profile); 1059 AccountReconcilorFactory::GetForProfile(profile);
1055 } 1060 }
1056 1061
1057 void ProfileManager::DoFinalInitLogging(Profile* profile) { 1062 void ProfileManager::DoFinalInitLogging(Profile* profile) {
1063 TRACE_EVENT0("browser", "ProfileManager::DoFinalInitLogging");
1058 // Count number of extensions in this profile. 1064 // Count number of extensions in this profile.
1059 int enabled_app_count = -1; 1065 int enabled_app_count = -1;
1060 #if defined(ENABLE_EXTENSIONS) 1066 #if defined(ENABLE_EXTENSIONS)
1061 enabled_app_count = GetEnabledAppCount(profile); 1067 enabled_app_count = GetEnabledAppCount(profile);
1062 #endif 1068 #endif
1063 1069
1064 // Log the profile size after a reasonable startup delay. 1070 // Log the profile size after a reasonable startup delay.
1065 BrowserThread::PostDelayedTask( 1071 BrowserThread::PostDelayedTask(
1066 BrowserThread::FILE, FROM_HERE, 1072 BrowserThread::FILE, FROM_HERE,
1067 base::Bind(&ProfileSizeTask, profile->GetPath(), enabled_app_count), 1073 base::Bind(&ProfileSizeTask, profile->GetPath(), enabled_app_count),
1068 base::TimeDelta::FromSeconds(112)); 1074 base::TimeDelta::FromSeconds(112));
1069 } 1075 }
1070 1076
1071 Profile* ProfileManager::CreateProfileHelper(const base::FilePath& path) { 1077 Profile* ProfileManager::CreateProfileHelper(const base::FilePath& path) {
1078 TRACE_EVENT0("browser", "ProfileManager::CreateProfileHelper");
1072 return Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); 1079 return Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS);
1073 } 1080 }
1074 1081
1075 Profile* ProfileManager::CreateProfileAsyncHelper(const base::FilePath& path, 1082 Profile* ProfileManager::CreateProfileAsyncHelper(const base::FilePath& path,
1076 Delegate* delegate) { 1083 Delegate* delegate) {
1077 return Profile::CreateProfile(path, 1084 return Profile::CreateProfile(path,
1078 delegate, 1085 delegate,
1079 Profile::CREATE_MODE_ASYNCHRONOUS); 1086 Profile::CREATE_MODE_ASYNCHRONOUS);
1080 } 1087 }
1081 1088
(...skipping 28 matching lines...) Expand all
1110 return profile->GetOffTheRecordProfile(); 1117 return profile->GetOffTheRecordProfile();
1111 return profile; 1118 return profile;
1112 #else 1119 #else
1113 base::FilePath default_profile_dir(user_data_dir); 1120 base::FilePath default_profile_dir(user_data_dir);
1114 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); 1121 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir());
1115 return GetProfile(default_profile_dir); 1122 return GetProfile(default_profile_dir);
1116 #endif 1123 #endif
1117 } 1124 }
1118 1125
1119 bool ProfileManager::AddProfile(Profile* profile) { 1126 bool ProfileManager::AddProfile(Profile* profile) {
1127 TRACE_EVENT0("browser", "ProfileManager::AddProfile");
1120 DCHECK(profile); 1128 DCHECK(profile);
1121 1129
1122 // Make sure that we're not loading a profile with the same ID as a profile 1130 // Make sure that we're not loading a profile with the same ID as a profile
1123 // that's already loaded. 1131 // that's already loaded.
1124 if (GetProfileByPath(profile->GetPath())) { 1132 if (GetProfileByPath(profile->GetPath())) {
1125 NOTREACHED() << "Attempted to add profile with the same path (" << 1133 NOTREACHED() << "Attempted to add profile with the same path (" <<
1126 profile->GetPath().value() << 1134 profile->GetPath().value() <<
1127 ") as an already-loaded profile."; 1135 ") as an already-loaded profile.";
1128 return false; 1136 return false;
1129 } 1137 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 } 1183 }
1176 1184
1177 QueueProfileDirectoryForDeletion(profile_dir); 1185 QueueProfileDirectoryForDeletion(profile_dir);
1178 cache.DeleteProfileFromCache(profile_dir); 1186 cache.DeleteProfileFromCache(profile_dir);
1179 ProfileMetrics::UpdateReportedProfilesStatistics(this); 1187 ProfileMetrics::UpdateReportedProfilesStatistics(this);
1180 } 1188 }
1181 1189
1182 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile( 1190 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile(
1183 Profile* profile, 1191 Profile* profile,
1184 bool created) { 1192 bool created) {
1193 TRACE_EVENT0("browser", "ProfileManager::RegisterProfile");
1185 ProfileInfo* info = new ProfileInfo(profile, created); 1194 ProfileInfo* info = new ProfileInfo(profile, created);
1186 profiles_info_.insert( 1195 profiles_info_.insert(
1187 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info))); 1196 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info)));
1188 return info; 1197 return info;
1189 } 1198 }
1190 1199
1191 ProfileManager::ProfileInfo* ProfileManager::GetProfileInfoByPath( 1200 ProfileManager::ProfileInfo* ProfileManager::GetProfileInfoByPath(
1192 const base::FilePath& path) const { 1201 const base::FilePath& path) const {
1193 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path); 1202 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path);
1194 return (iter == profiles_info_.end()) ? NULL : iter->second.get(); 1203 return (iter == profiles_info_.end()) ? NULL : iter->second.get();
1195 } 1204 }
1196 1205
1197 void ProfileManager::AddProfileToCache(Profile* profile) { 1206 void ProfileManager::AddProfileToCache(Profile* profile) {
1207 TRACE_EVENT0("browser", "ProfileManager::AddProfileToCache");
1198 if (profile->IsGuestSession() || profile->IsSystemProfile()) 1208 if (profile->IsGuestSession() || profile->IsSystemProfile())
1199 return; 1209 return;
1200 ProfileInfoCache& cache = GetProfileInfoCache(); 1210 ProfileInfoCache& cache = GetProfileInfoCache();
1201 if (profile->GetPath().DirName() != cache.GetUserDataDir()) 1211 if (profile->GetPath().DirName() != cache.GetUserDataDir())
1202 return; 1212 return;
1203 1213
1204 SigninManagerBase* signin_manager = 1214 SigninManagerBase* signin_manager =
1205 SigninManagerFactory::GetForProfile(profile); 1215 SigninManagerFactory::GetForProfile(profile);
1206 base::string16 username = base::UTF8ToUTF16( 1216 base::string16 username = base::UTF8ToUTF16(
1207 signin_manager->GetAuthenticatedUsername()); 1217 signin_manager->GetAuthenticatedUsername());
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 last_non_supervised_profile_path.BaseName().MaybeAsASCII()); 1378 last_non_supervised_profile_path.BaseName().MaybeAsASCII());
1369 FinishDeletingProfile(profile_to_delete_path); 1379 FinishDeletingProfile(profile_to_delete_path);
1370 } 1380 }
1371 } 1381 }
1372 } 1382 }
1373 #endif 1383 #endif
1374 1384
1375 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1385 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1376 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1386 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1377 } 1387 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/installed_loader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698