зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
b549c013c7
Коммит
b88c487681
|
@ -76,24 +76,9 @@ nsresult URLPreloader::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||||
return NS_OK;
|
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() {
|
URLPreloader& URLPreloader::GetSingleton() {
|
||||||
if (!sSingleton) {
|
if (!sSingleton) {
|
||||||
sSingleton = Create();
|
sSingleton = new URLPreloader();
|
||||||
sInitialized = !!sSingleton;
|
|
||||||
ClearOnShutdown(&sSingleton);
|
ClearOnShutdown(&sSingleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,10 +89,16 @@ bool URLPreloader::sInitialized = false;
|
||||||
|
|
||||||
StaticRefPtr<URLPreloader> URLPreloader::sSingleton;
|
StaticRefPtr<URLPreloader> URLPreloader::sSingleton;
|
||||||
|
|
||||||
|
URLPreloader::URLPreloader() {
|
||||||
|
if (InitInternal().isOk()) {
|
||||||
|
sInitialized = true;
|
||||||
|
RegisterWeakMemoryReporter(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
URLPreloader::~URLPreloader() {
|
URLPreloader::~URLPreloader() {
|
||||||
if (sInitialized) {
|
if (sInitialized) {
|
||||||
UnregisterWeakMemoryReporter(this);
|
UnregisterWeakMemoryReporter(this);
|
||||||
sInitialized = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,19 +127,23 @@ Result<Ok, nsresult> URLPreloader::InitInternal() {
|
||||||
return Err(NS_ERROR_UNEXPECTED);
|
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();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
URLPreloader& URLPreloader::ReInitialize() {
|
URLPreloader& URLPreloader::ReInitialize() {
|
||||||
MOZ_ASSERT(sSingleton);
|
sSingleton = new URLPreloader();
|
||||||
sSingleton = Create();
|
|
||||||
sInitialized = !!sSingleton;
|
|
||||||
return *sSingleton;
|
return *sSingleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class ScriptPreloader;
|
||||||
class URLPreloader final : public nsIObserver, public nsIMemoryReporter {
|
class URLPreloader final : public nsIObserver, public nsIMemoryReporter {
|
||||||
MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf)
|
MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf)
|
||||||
|
|
||||||
URLPreloader() = default;
|
URLPreloader();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NS_DECL_THREADSAFE_ISUPPORTS
|
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.
|
// Resolves the given URI to a CacheKey, if the URI is cacheable.
|
||||||
Result<CacheKey, nsresult> ResolveURI(nsIURI* uri);
|
Result<CacheKey, nsresult> ResolveURI(nsIURI* uri);
|
||||||
|
|
||||||
static already_AddRefed<URLPreloader> Create();
|
|
||||||
|
|
||||||
Result<Ok, nsresult> InitInternal();
|
Result<Ok, nsresult> InitInternal();
|
||||||
|
|
||||||
// Returns a file pointer to the (possibly nonexistent) cache file with the
|
// Returns a file pointer to the (possibly nonexistent) cache file with the
|
||||||
|
|
Загрузка…
Ссылка в новой задаче