Bug 1657231, part 3 - Fail if add observer fails. r=kmag

This can cause the URL preloader to think that initialization has succeeded
when it hasn't. This add observer call can fail if we're late in shutdown,
because the observer service still exists, but it isn't taking new
observers. I'm not sure how much it matters that we're failing to listen for
an observer that can't possibly fire at this stage, but a failure to check
for this seems to have contributed to the crash in bug 1656973, so we
might as well just fail.

Differential Revision: https://phabricator.services.mozilla.com/D86031
This commit is contained in:
Andrew McCreight 2020-08-06 22:35:12 +00:00
Родитель e6886b3c16
Коммит 36b266e999
1 изменённых файлов: 1 добавлений и 1 удалений

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

@ -134,7 +134,7 @@ Result<Ok, nsresult> URLPreloader::InitInternal() {
if (XRE_IsParentProcess()) {
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
obs->AddObserver(this, DELAYED_STARTUP_TOPIC, false);
MOZ_TRY(obs->AddObserver(this, DELAYED_STARTUP_TOPIC, false));
MOZ_TRY(NS_GetSpecialDirectory("ProfLDS", getter_AddRefs(mProfD)));
} else {