Backed out changeset 7cdd5e64521e (bug 1456626) for build crash on nsJARChannel::OpenLocalFile CLOSED TREE
authorBogdan Tara <btara@mozilla.com>
Fri, 22 May 2020 05:06:32 +0300
changeset 531573 095d17ab204cf3c9bdffcf5f3fb7748ab08bd497
parent 531572 f395ce024843ace15398b05acde1d03fb425859b
child 531574 cdc1527ee98f11e9ff8c97b9c23efb6c1e95e1c7
push id37440
push userabutkovits@mozilla.com
push dateFri, 22 May 2020 09:43:16 +0000
treeherdermozilla-central@fbf71e4d2e21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1456626
milestone78.0a1
backs out7cdd5e64521e1f67aa626464142a80eaaa6a4f29
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 7cdd5e64521e (bug 1456626) for build crash on nsJARChannel::OpenLocalFile CLOSED TREE
modules/libjar/nsJARChannel.cpp
modules/libjar/nsJARChannel.h
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -195,16 +195,21 @@ NS_IMPL_ISUPPORTS_INHERITED(nsJARChannel
                             nsIChannel, nsIStreamListener, nsIRequestObserver,
                             nsIThreadRetargetableRequest,
                             nsIThreadRetargetableStreamListener, nsIJARChannel)
 
 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;
 
   mOriginalURI = mJarURI;
 
   // Prevent loading jar:javascript URIs (see bug 290982).
   nsCOMPtr<nsIURI> innerURI;
   rv = mJarURI->GetJARFile(getter_AddRefs(innerURI));
@@ -360,16 +365,17 @@ nsresult CreateLocalJarInput(nsIZipReade
   return NS_OK;
 }
 
 nsresult nsJARChannel::OpenLocalFile() {
   LOG(("nsJARChannel::OpenLocalFile [this=%p]\n", this));
 
   MOZ_ASSERT(NS_IsMainThread());
 
+  MOZ_ASSERT(mWorker);
   MOZ_ASSERT(mIsPending);
   MOZ_ASSERT(mJarFile);
 
   nsresult rv;
 
   // Set mLoadGroup and mOpened before AsyncOpen return, and set back if
   // if failed when callback.
   if (mLoadGroup) {
@@ -398,44 +404,41 @@ nsresult nsJARChannel::OpenLocalFile() {
   }
 
   nsCOMPtr<nsIJARURI> localJARURI = mJarURI;
 
   nsAutoCString jarEntry(mJarEntry);
   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,
                                              bool aIsSyncCall) {
   LOG(("nsJARChannel::ContinueOpenLocalFile [this=%p %p]\n", this, aInput));
 
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mIsPending);
--- a/modules/libjar/nsJARChannel.h
+++ b/modules/libjar/nsJARChannel.h
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsJARChannel_h__
 #define nsJARChannel_h__
 
 #include "mozilla/net/MemoryDownloader.h"
 #include "nsIJARChannel.h"
 #include "nsIJARURI.h"
+#include "nsIEventTarget.h"
 #include "nsIInputStreamPump.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIProgressEventSink.h"
 #include "nsIStreamListener.h"
 #include "nsIZipReader.h"
 #include "nsILoadGroup.h"
 #include "nsILoadInfo.h"
 #include "nsIThreadRetargetableRequest.h"
@@ -98,11 +99,14 @@ class nsJARChannel final : public nsIJAR
   // to the request if we get called back via RetargetDeliveryTo.
   nsCOMPtr<nsIRequest> mRequest;
   nsCOMPtr<nsIFile> mJarFile;
   nsCOMPtr<nsIFile> mJarFileOverride;
   nsCOMPtr<nsIZipReader> mPreCachedJarReader;
   nsCOMPtr<nsIURI> mJarBaseURI;
   nsCString mJarEntry;
   nsCString mInnerJarEntry;
+
+  // use StreamTransportService as background thread
+  nsCOMPtr<nsIEventTarget> mWorker;
 };
 
 #endif  // nsJARChannel_h__