Backed out changeset 85d3ad4be91a (bug 1456626) for causing leaks. CLOSED TREE

This commit is contained in:
Cosmin Sabou 2020-05-11 20:00:07 +03:00
Родитель 11ab196725
Коммит c7662689a3
2 изменённых файлов: 31 добавлений и 25 удалений

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

@ -200,6 +200,11 @@ nsresult nsJARChannel::Init(nsIURI* uri) {
LOG(("nsJARChannel::Init [this=%p]\n", this));
nsresult rv;
mWorker = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
return rv;
}
mJarURI = do_QueryInterface(uri, &rv);
if (NS_FAILED(rv)) return rv;
@ -365,6 +370,7 @@ nsresult nsJARChannel::OpenLocalFile() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mWorker);
MOZ_ASSERT(mIsPending);
MOZ_ASSERT(mJarFile);
@ -403,34 +409,31 @@ nsresult nsJARChannel::OpenLocalFile() {
nsAutoCString innerJarEntry(mInnerJarEntry);
RefPtr<nsJARChannel> self = this;
return NS_DispatchBackgroundTask(
NS_NewRunnableFunction(
"nsJARChannel::OpenLocalFile",
[self, jarCache, clonedFile, localJARURI, jarEntry,
innerJarEntry]() mutable {
RefPtr<nsJARInputThunk> input;
nsresult rv = CreateLocalJarInput(jarCache, clonedFile,
innerJarEntry, localJARURI,
jarEntry, getter_AddRefs(input));
return mWorker->Dispatch(NS_NewRunnableFunction(
"nsJARChannel::OpenLocalFile", [self, jarCache, clonedFile, localJARURI,
jarEntry, innerJarEntry]() mutable {
RefPtr<nsJARInputThunk> input;
nsresult rv =
CreateLocalJarInput(jarCache, clonedFile, innerJarEntry,
localJARURI, jarEntry, getter_AddRefs(input));
nsCOMPtr<nsIRunnable> target;
if (NS_SUCCEEDED(rv)) {
target = NewRunnableMethod<RefPtr<nsJARInputThunk>, bool>(
"nsJARChannel::ContinueOpenLocalFile", self,
&nsJARChannel::ContinueOpenLocalFile, input, false);
} else {
target = NewRunnableMethod<nsresult, bool>(
"nsJARChannel::OnOpenLocalFileComplete", self,
&nsJARChannel::OnOpenLocalFileComplete, rv, false);
}
nsCOMPtr<nsIRunnable> target;
if (NS_SUCCEEDED(rv)) {
target = NewRunnableMethod<RefPtr<nsJARInputThunk>, bool>(
"nsJARChannel::ContinueOpenLocalFile", self,
&nsJARChannel::ContinueOpenLocalFile, input, false);
} else {
target = NewRunnableMethod<nsresult, bool>(
"nsJARChannel::OnOpenLocalFileComplete", self,
&nsJARChannel::OnOpenLocalFileComplete, rv, false);
}
// nsJARChannel must be release on main thread, and sometimes
// this still hold nsJARChannel after dispatched.
self = nullptr;
// nsJARChannel must be release on main thread, and sometimes
// this still hold nsJARChannel after dispatched.
self = nullptr;
NS_DispatchToMainThread(target.forget());
}),
NS_DISPATCH_EVENT_MAY_BLOCK);
NS_DispatchToMainThread(target.forget());
}));
}
nsresult nsJARChannel::ContinueOpenLocalFile(nsJARInputThunk* aInput,

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

@ -104,6 +104,9 @@ class nsJARChannel final : public nsIJARChannel,
nsCOMPtr<nsIURI> mJarBaseURI;
nsCString mJarEntry;
nsCString mInnerJarEntry;
// use StreamTransportService as background thread
nsCOMPtr<nsIEventTarget> mWorker;
};
#endif // nsJARChannel_h__