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

Unified Diff: chrome/browser/policy/user_policy_signin_service.cc

Issue 12461010: Delay loading the SigninManagerFactory until the first-run Import process has completed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: but don't regress the fix Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/user_policy_signin_service.cc
diff --git a/chrome/browser/policy/user_policy_signin_service.cc b/chrome/browser/policy/user_policy_signin_service.cc
index 81896754a34cbd30384da092aeddf6a650a657fb..b78e0ac76f1efe245795a5afab7d2bd03785334d 100644
--- a/chrome/browser/policy/user_policy_signin_service.cc
+++ b/chrome/browser/policy/user_policy_signin_service.cc
@@ -257,6 +257,12 @@ UserPolicySigninService::UserPolicySigninService(
registrar_.Add(this,
chrome::NOTIFICATION_PROFILE_ADDED,
content::Source<Profile>(profile));
+
+ // Register a listener for the import finished notification in a first run
+ // scenario, which indicates the profile is ready to be further initialized.
+ registrar_.Add(this,
+ chrome::NOTIFICATION_IMPORT_FINISHED,
+ content::Source<Profile>(profile));
}
UserPolicySigninService::~UserPolicySigninService() {}
@@ -351,6 +357,16 @@ void UserPolicySigninService::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
+ // If an import process is running, wait for NOTIFICATION_IMPORT_FINISHED
+ // before potentially creating the SigninManager. Its dependencies can access
+ // databases that the import process is also accessing, causing conflicts.
+ // Note that the profile manager is NULL in unit tests.
+ if (g_browser_process->profile_manager() &&
+ g_browser_process->profile_manager()->will_import()) {
+ DCHECK_EQ(chrome::NOTIFICATION_PROFILE_ADDED, type);
Bernhard Bauer 2013/03/26 12:29:32 Wait, doesn't this DCHECK fail when we get *any* o
Joao da Silva 2013/03/26 12:52:00 will_import() signals that the first run import wi
Bernhard Bauer 2013/03/26 14:18:22 Well, I ran into this with a local build that trie
Joao da Silva 2013/03/26 14:35:27 IIUC, that would only be a problem if you do that
+ return;
+ }
+
// If using a TestingProfile with no SigninManager or UserCloudPolicyManager,
// skip initialization.
if (!GetManager() || !SigninManagerFactory::GetForProfile(profile_)) {
@@ -362,6 +378,7 @@ void UserPolicySigninService::Observe(
case chrome::NOTIFICATION_GOOGLE_SIGNED_OUT:
ShutdownUserCloudPolicyManager();
break;
+ case chrome::NOTIFICATION_IMPORT_FINISHED:
case chrome::NOTIFICATION_PROFILE_ADDED: {
// A new profile has been loaded - if it's signed in, then initialize the
// UCPM, otherwise shut down the UCPM (which deletes any cached policy
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698