diff --git a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp index 39f9cf4fd49f..9e544bec33d1 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp @@ -1204,25 +1204,6 @@ nsUrlClassifierDBService::Init() CONFIRM_AGE_DEFAULT_SEC); ReadTablesFromPrefs(); - // Do we *really* need to be able to change all of these at runtime? - Preferences::AddStrongObserver(this, CHECK_MALWARE_PREF); - Preferences::AddStrongObserver(this, CHECK_PHISHING_PREF); - Preferences::AddStrongObserver(this, CHECK_TRACKING_PREF); - Preferences::AddStrongObserver(this, CHECK_TRACKING_PB_PREF); - Preferences::AddStrongObserver(this, CHECK_FORBIDDEN_PREF); - Preferences::AddStrongObserver(this, CHECK_BLOCKED_PREF); - Preferences::AddStrongObserver(this, GETHASH_NOISE_PREF); - Preferences::AddStrongObserver(this, CONFIRM_AGE_PREF); - Preferences::AddStrongObserver(this, PHISH_TABLE_PREF); - Preferences::AddStrongObserver(this, MALWARE_TABLE_PREF); - Preferences::AddStrongObserver(this, TRACKING_TABLE_PREF); - Preferences::AddStrongObserver(this, TRACKING_WHITELIST_TABLE_PREF); - Preferences::AddStrongObserver(this, FORBIDDEN_TABLE_PREF); - Preferences::AddStrongObserver(this, BLOCKED_TABLE_PREF); - Preferences::AddStrongObserver(this, DOWNLOAD_BLOCK_TABLE_PREF); - Preferences::AddStrongObserver(this, DOWNLOAD_ALLOW_TABLE_PREF); - Preferences::AddStrongObserver(this, DISALLOW_COMPLETION_TABLE_PREF); - // Force PSM loading on main thread nsresult rv; nsCOMPtr dummy = do_CreateInstance(NS_CRYPTO_HASH_CONTRACTID, &rv); @@ -1271,6 +1252,28 @@ nsUrlClassifierDBService::Init() observerService->AddObserver(this, "profile-before-change", false); observerService->AddObserver(this, "xpcom-shutdown-threads", false); + // XXX: Do we *really* need to be able to change all of these at runtime? + // Note: These observers should only be added when everything else above has + // succeeded. Failing to do so can cause long shutdown times in certain + // situations. See Bug 1247798 and Bug 1244803. + Preferences::AddStrongObserver(this, CHECK_MALWARE_PREF); + Preferences::AddStrongObserver(this, CHECK_PHISHING_PREF); + Preferences::AddStrongObserver(this, CHECK_TRACKING_PREF); + Preferences::AddStrongObserver(this, CHECK_TRACKING_PB_PREF); + Preferences::AddStrongObserver(this, CHECK_FORBIDDEN_PREF); + Preferences::AddStrongObserver(this, CHECK_BLOCKED_PREF); + Preferences::AddStrongObserver(this, GETHASH_NOISE_PREF); + Preferences::AddStrongObserver(this, CONFIRM_AGE_PREF); + Preferences::AddStrongObserver(this, PHISH_TABLE_PREF); + Preferences::AddStrongObserver(this, MALWARE_TABLE_PREF); + Preferences::AddStrongObserver(this, TRACKING_TABLE_PREF); + Preferences::AddStrongObserver(this, TRACKING_WHITELIST_TABLE_PREF); + Preferences::AddStrongObserver(this, FORBIDDEN_TABLE_PREF); + Preferences::AddStrongObserver(this, BLOCKED_TABLE_PREF); + Preferences::AddStrongObserver(this, DOWNLOAD_BLOCK_TABLE_PREF); + Preferences::AddStrongObserver(this, DOWNLOAD_ALLOW_TABLE_PREF); + Preferences::AddStrongObserver(this, DISALLOW_COMPLETION_TABLE_PREF); + return NS_OK; }