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

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

Issue 12952005: Delay bookmarks load while the profile is loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment. Created 7 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) 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"
11 #include "base/deferred_sequenced_task_runner.h"
11 #include "base/file_util.h" 12 #include "base/file_util.h"
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
13 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
14 #include "base/prefs/pref_registry_simple.h" 15 #include "base/prefs/pref_registry_simple.h"
15 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
16 #include "base/string_util.h" 17 #include "base/string_util.h"
17 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
18 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
19 #include "chrome/browser/bookmarks/bookmark_model.h" 20 #include "chrome/browser/bookmarks/bookmark_model.h"
20 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 21 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
21 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/content_settings/host_content_settings_map.h" 23 #include "chrome/browser/content_settings/host_content_settings_map.h"
23 #include "chrome/browser/prefs/scoped_user_pref_update.h" 24 #include "chrome/browser/prefs/scoped_user_pref_update.h"
24 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" 25 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h"
25 #include "chrome/browser/profiles/profile_destroyer.h" 26 #include "chrome/browser/profiles/profile_destroyer.h"
26 #include "chrome/browser/profiles/profile_info_cache.h" 27 #include "chrome/browser/profiles/profile_info_cache.h"
27 #include "chrome/browser/profiles/profile_metrics.h" 28 #include "chrome/browser/profiles/profile_metrics.h"
29 #include "chrome/browser/profiles/startup_task_runner_service.h"
30 #include "chrome/browser/profiles/startup_task_runner_service_factory.h"
28 #include "chrome/browser/sync/profile_sync_service.h" 31 #include "chrome/browser/sync/profile_sync_service.h"
29 #include "chrome/browser/sync/profile_sync_service_factory.h" 32 #include "chrome/browser/sync/profile_sync_service_factory.h"
30 #include "chrome/browser/ui/browser.h" 33 #include "chrome/browser/ui/browser.h"
31 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" 34 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
32 #include "chrome/common/chrome_constants.h" 35 #include "chrome/common/chrome_constants.h"
33 #include "chrome/common/chrome_notification_types.h" 36 #include "chrome/common/chrome_notification_types.h"
34 #include "chrome/common/chrome_paths_internal.h" 37 #include "chrome/common/chrome_paths_internal.h"
35 #include "chrome/common/chrome_switches.h" 38 #include "chrome/common/chrome_switches.h"
36 #include "chrome/common/logging_chrome.h" 39 #include "chrome/common/logging_chrome.h"
37 #include "chrome/common/pref_names.h" 40 #include "chrome/common/pref_names.h"
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 extensions::ExtensionSystem::Get(profile)->extension_service()); 843 extensions::ExtensionSystem::Get(profile)->extension_service());
841 } 844 }
842 } 845 }
843 #endif 846 #endif
844 #if defined(ENABLE_MANAGED_USERS) 847 #if defined(ENABLE_MANAGED_USERS)
845 // Initialization needs to happen after extension system initialization (for 848 // Initialization needs to happen after extension system initialization (for
846 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the 849 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the
847 // initializing the managed flag if necessary). 850 // initializing the managed flag if necessary).
848 ManagedUserServiceFactory::GetForProfile(profile)->Init(); 851 ManagedUserServiceFactory::GetForProfile(profile)->Init();
849 #endif 852 #endif
853 // Start the deferred task runners once the profile is loaded.
854 StartupTaskRunnerServiceFactory::GetForProfile(profile)->
855 StartDeferredTaskRunners();
850 } 856 }
851 857
852 void ProfileManager::DoFinalInitLogging(Profile* profile) { 858 void ProfileManager::DoFinalInitLogging(Profile* profile) {
853 // Count number of extensions in this profile. 859 // Count number of extensions in this profile.
854 int extension_count = -1; 860 int extension_count = -1;
855 #if defined(ENABLE_EXTENSIONS) 861 #if defined(ENABLE_EXTENSIONS)
856 ExtensionService* extension_service = profile->GetExtensionService(); 862 ExtensionService* extension_service = profile->GetExtensionService();
857 if (extension_service) 863 if (extension_service)
858 extension_count = extension_service->GetAppIds().size(); 864 extension_count = extension_service->GetAppIds().size();
859 #endif 865 #endif
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 GetProfile(cache.GetPathOfProfileAtIndex(p)); 1172 GetProfile(cache.GetPathOfProfileAtIndex(p));
1167 } 1173 }
1168 } 1174 }
1169 } 1175 }
1170 1176
1171 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1177 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1172 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1178 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1173 } 1179 }
1174 1180
1175 void ProfileManager::RegisterTestingProfile(Profile* profile, 1181 void ProfileManager::RegisterTestingProfile(Profile* profile,
1176 bool add_to_cache) { 1182 bool add_to_cache,
1183 bool start_deferred_task_runners) {
1177 RegisterProfile(profile, true); 1184 RegisterProfile(profile, true);
1178 if (add_to_cache) { 1185 if (add_to_cache) {
1179 InitProfileUserPrefs(profile); 1186 InitProfileUserPrefs(profile);
1180 AddProfileToCache(profile); 1187 AddProfileToCache(profile);
1181 } 1188 }
1189 if (start_deferred_task_runners) {
1190 StartupTaskRunnerServiceFactory::GetForProfile(profile)->
1191 StartDeferredTaskRunners();
1192 }
1182 } 1193 }
1183 1194
1184 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks, 1195 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks,
1185 Profile* profile, 1196 Profile* profile,
1186 Profile::CreateStatus status) { 1197 Profile::CreateStatus status) {
1187 for (size_t i = 0; i < callbacks.size(); ++i) 1198 for (size_t i = 0; i < callbacks.size(); ++i)
1188 callbacks[i].Run(profile, status); 1199 callbacks[i].Run(profile, status);
1189 } 1200 }
1190 1201
1191 ProfileManager::ProfileInfo::ProfileInfo( 1202 ProfileManager::ProfileInfo::ProfileInfo(
1192 Profile* profile, 1203 Profile* profile,
1193 bool created) 1204 bool created)
1194 : profile(profile), 1205 : profile(profile),
1195 created(created) { 1206 created(created) {
1196 } 1207 }
1197 1208
1198 ProfileManager::ProfileInfo::~ProfileInfo() { 1209 ProfileManager::ProfileInfo::~ProfileInfo() {
1199 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); 1210 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release());
1200 } 1211 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | chrome/browser/profiles/startup_task_runner_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698