Bug 1657231, part 4 - Don't allow using the URL preloader in the child. r=kmag

It never gets initialized there anyways, so assert and clean up
a bit of dead code.

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

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

@ -78,6 +78,11 @@ nsresult URLPreloader::CollectReports(nsIHandleReportCallback* aHandleReport,
// static
already_AddRefed<URLPreloader> URLPreloader::Create() {
// The static APIs like URLPreloader::Read work in the child process because
// they fall back to a synchronous read. The actual preloader must be
// explicitly initialized, and this should only be done in the parent.
MOZ_RELEASE_ASSERT(XRE_IsParentProcess());
RefPtr<URLPreloader> preloader = new URLPreloader();
if (preloader->InitInternal().isOk()) {
RegisterWeakMemoryReporter(preloader);
@ -131,16 +136,11 @@ Result<Ok, nsresult> URLPreloader::InitInternal() {
return Err(NS_ERROR_UNEXPECTED);
}
if (XRE_IsParentProcess()) {
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
MOZ_TRY(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 {
mStartupFinished = true;
mReaderInitialized = true;
}
MOZ_TRY(NS_GetSpecialDirectory("ProfLDS", getter_AddRefs(mProfD)));
return Ok();
}