Bug 1247798 - Make nsUrlClassifierDBService::Init() register pref observers only in the success case. r=gcp

These observers should only be added when everything else has succeeded.
Failing to do so can cause long shutdown hangs in certain situations such as during periodic HSTS update runs.

MozReview-Commit-ID: IoJ4PscS1u3

--HG--
extra : transplant_source : %28%A8%D6l%FF%BB%F7%B90%F8%AC%D0P%2A%14K%0B%16%18W
This commit is contained in:
Cykesiopka 2016-04-03 00:58:43 -07:00
Родитель 9c4398499b
Коммит d0633097bc
1 изменённых файлов: 22 добавлений и 19 удалений

Просмотреть файл

@ -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<nsICryptoHash> 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;
}