diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index 4c84d4595d38..61f188a3c41d 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -200,11 +200,6 @@ 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; @@ -370,7 +365,6 @@ nsresult nsJARChannel::OpenLocalFile() { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(mWorker); MOZ_ASSERT(mIsPending); MOZ_ASSERT(mJarFile); @@ -409,31 +403,34 @@ nsresult nsJARChannel::OpenLocalFile() { nsAutoCString innerJarEntry(mInnerJarEntry); RefPtr self = this; - return mWorker->Dispatch(NS_NewRunnableFunction( - "nsJARChannel::OpenLocalFile", [self, jarCache, clonedFile, localJARURI, - jarEntry, innerJarEntry]() mutable { - RefPtr input; - nsresult rv = - CreateLocalJarInput(jarCache, clonedFile, innerJarEntry, - localJARURI, jarEntry, getter_AddRefs(input)); + return NS_DispatchBackgroundTask( + NS_NewRunnableFunction( + "nsJARChannel::OpenLocalFile", + [self, jarCache, clonedFile, localJARURI, jarEntry, + innerJarEntry]() mutable { + RefPtr input; + nsresult rv = CreateLocalJarInput(jarCache, clonedFile, + innerJarEntry, localJARURI, + jarEntry, getter_AddRefs(input)); - nsCOMPtr target; - if (NS_SUCCEEDED(rv)) { - target = NewRunnableMethod, bool>( - "nsJARChannel::ContinueOpenLocalFile", self, - &nsJARChannel::ContinueOpenLocalFile, input, false); - } else { - target = NewRunnableMethod( - "nsJARChannel::OnOpenLocalFileComplete", self, - &nsJARChannel::OnOpenLocalFileComplete, rv, false); - } + nsCOMPtr target; + if (NS_SUCCEEDED(rv)) { + target = NewRunnableMethod, bool>( + "nsJARChannel::ContinueOpenLocalFile", self, + &nsJARChannel::ContinueOpenLocalFile, input, false); + } else { + target = NewRunnableMethod( + "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_DispatchToMainThread(target.forget()); + }), + NS_DISPATCH_EVENT_MAY_BLOCK); } nsresult nsJARChannel::ContinueOpenLocalFile(nsJARInputThunk* aInput, diff --git a/modules/libjar/nsJARChannel.h b/modules/libjar/nsJARChannel.h index de8918800a43..8d0944531188 100644 --- a/modules/libjar/nsJARChannel.h +++ b/modules/libjar/nsJARChannel.h @@ -104,9 +104,6 @@ class nsJARChannel final : public nsIJARChannel, nsCOMPtr mJarBaseURI; nsCString mJarEntry; nsCString mInnerJarEntry; - - // use StreamTransportService as background thread - nsCOMPtr mWorker; }; #endif // nsJARChannel_h__