Backed out 4 changesets (bug 1657231) for causing multiple xpcshell failures.

CLOSED TREE

Backed out changeset caa4f187b037 (bug 1657231)
Backed out changeset 73418f013a61 (bug 1657231)
Backed out changeset e196f9cc2bb2 (bug 1657231)
Backed out changeset 5f4aab0ad04a (bug 1657231)
This commit is contained in:
Mihai Alexandru Michis 2020-08-07 02:49:49 +03:00
Родитель b549c013c7
Коммит b88c487681
2 изменённых файлов: 19 добавлений и 26 удалений

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

@ -76,24 +76,9 @@ nsresult URLPreloader::CollectReports(nsIHandleReportCallback* aHandleReport,
return NS_OK;
}
// 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);
}
return preloader.forget();
}
URLPreloader& URLPreloader::GetSingleton() {
if (!sSingleton) {
sSingleton = Create();
sInitialized = !!sSingleton;
sSingleton = new URLPreloader();
ClearOnShutdown(&sSingleton);
}
@ -104,10 +89,16 @@ bool URLPreloader::sInitialized = false;
StaticRefPtr<URLPreloader> URLPreloader::sSingleton;
URLPreloader::URLPreloader() {
if (InitInternal().isOk()) {
sInitialized = true;
RegisterWeakMemoryReporter(this);
}
}
URLPreloader::~URLPreloader() {
if (sInitialized) {
UnregisterWeakMemoryReporter(this);
sInitialized = false;
}
}
@ -136,19 +127,23 @@ Result<Ok, nsresult> URLPreloader::InitInternal() {
return Err(NS_ERROR_UNEXPECTED);
}
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (XRE_IsParentProcess()) {
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
MOZ_TRY(obs->AddObserver(this, DELAYED_STARTUP_TOPIC, false));
obs->AddObserver(this, DELAYED_STARTUP_TOPIC, false);
MOZ_TRY(NS_GetSpecialDirectory("ProfLDS", getter_AddRefs(mProfD)));
MOZ_TRY(NS_GetSpecialDirectory("ProfLDS", getter_AddRefs(mProfD)));
} else {
mStartupFinished = true;
mReaderInitialized = true;
}
return Ok();
}
URLPreloader& URLPreloader::ReInitialize() {
MOZ_ASSERT(sSingleton);
sSingleton = Create();
sInitialized = !!sSingleton;
sSingleton = new URLPreloader();
return *sSingleton;
}

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

@ -45,7 +45,7 @@ class ScriptPreloader;
class URLPreloader final : public nsIObserver, public nsIMemoryReporter {
MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf)
URLPreloader() = default;
URLPreloader();
public:
NS_DECL_THREADSAFE_ISUPPORTS
@ -264,8 +264,6 @@ class URLPreloader final : public nsIObserver, public nsIMemoryReporter {
// Resolves the given URI to a CacheKey, if the URI is cacheable.
Result<CacheKey, nsresult> ResolveURI(nsIURI* uri);
static already_AddRefed<URLPreloader> Create();
Result<Ok, nsresult> InitInternal();
// Returns a file pointer to the (possibly nonexistent) cache file with the