Backed out 4 changesets (bug 497003) for intermittent OSX crashes.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 17 Jun 2013 15:44:07 -0400
changeset 147705 d78e02224026cc1e8a32d359c01a3b4e503a506a
parent 147704 99761867d59cb25727daaa2ecf9ed6121f96ad9c
child 147706 dccd693173c9b122c95e9333b6265f8f88144776
push id368
push userbbajaj@mozilla.com
push dateMon, 09 Sep 2013 22:57:58 +0000
treeherdermozilla-release@5a4f47ae1217 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs497003
milestone24.0a1
backs out43223a927976550fe5ea0395fe5b57b25f9249a2
26c1d80edf1f27a23a60da8bb6f3709e19b48a44
841ed173ba2b5ef36e68850f5c60a3943e5dac7c
f70770fc6dcea68dc75bf2c652e0dbbbdccd42ca
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 4 changesets (bug 497003) for intermittent OSX crashes. Backed out changeset 43223a927976 (bug 497003) Backed out changeset 26c1d80edf1f (bug 497003) Backed out changeset 841ed173ba2b (bug 497003) Backed out changeset f70770fc6dce (bug 497003)
netwerk/base/public/moz.build
netwerk/base/public/nsIInputStreamPump.idl
netwerk/base/public/nsIThreadRetargetableRequest.idl
netwerk/base/public/nsIThreadRetargetableStreamListener.idl
netwerk/base/public/nsStreamListenerWrapper.h
netwerk/base/src/nsInputStreamPump.cpp
netwerk/base/src/nsInputStreamPump.h
netwerk/base/src/nsStreamListenerTee.cpp
netwerk/base/src/nsStreamListenerTee.h
netwerk/base/src/nsStreamListenerWrapper.cpp
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsHttpChannel.h
netwerk/test/mochitests/Makefile.in
netwerk/test/mochitests/moz.build
netwerk/test/mochitests/partial_content.sjs
netwerk/test/mochitests/test_partially_cached_content.html
netwerk/test/moz.build
parser/html/nsHtml5StreamParser.cpp
parser/html/nsHtml5StreamParser.h
parser/html/nsHtml5TreeOpExecutor.h
uriloader/base/nsURILoader.cpp
xpcom/glue/nsProxyRelease.h
--- a/netwerk/base/public/moz.build
+++ b/netwerk/base/public/moz.build
@@ -90,18 +90,16 @@ XPIDL_SOURCES += [
     'nsIStandardURL.idl',
     'nsIStreamListener.idl',
     'nsIStreamListenerTee.idl',
     'nsIStreamLoader.idl',
     'nsIStreamTransportService.idl',
     'nsIStrictTransportSecurityService.idl',
     'nsISyncStreamListener.idl',
     'nsISystemProxySettings.idl',
-    'nsIThreadRetargetableRequest.idl',
-    'nsIThreadRetargetableStreamListener.idl',
     'nsITimedChannel.idl',
     'nsITraceableChannel.idl',
     'nsITransport.idl',
     'nsIUDPServerSocket.idl',
     'nsIURI.idl',
     'nsIURIChecker.idl',
     'nsIURIClassifier.idl',
     'nsIURIWithPrincipal.idl',
--- a/netwerk/base/public/nsIInputStreamPump.idl
+++ b/netwerk/base/public/nsIInputStreamPump.idl
@@ -6,21 +6,20 @@
 
 interface nsIInputStream;
 interface nsIStreamListener;
 
 /**
  * nsIInputStreamPump
  *
  * This interface provides a means to configure and use a input stream pump
- * instance.  The input stream pump will asynchronously read from an input
- * stream, and push data to an nsIStreamListener instance.  It utilizes the
+ * instance.  The input stream pump will asynchronously read from a input
+ * stream, and push data to a nsIStreamListener instance.  It utilizes the
  * current thread's nsIEventTarget in order to make reading from the stream
- * asynchronous. A different thread can be used if the pump also implements
- * nsIThreadRetargetableRequest.
+ * asynchronous.
  *
  * If the given stream supports nsIAsyncInputStream, then the stream pump will
  * call the stream's AsyncWait method to drive the stream listener.  Otherwise,
  * the stream will be read on a background thread utilizing the stream
  * transport service.  More details are provided below.
  */
 [scriptable, uuid(400F5468-97E7-4d2b-9C65-A82AECC7AE82)]
 interface nsIInputStreamPump : nsIRequest
deleted file mode 100644
--- a/netwerk/base/public/nsIThreadRetargetableRequest.idl
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsISupports.idl"
-#include "nsIEventTarget.idl"
-
-/**
- * nsIThreadRetargetableRequest
- *
- * Should be implemented by requests that support retargeting delivery of
- * OnDataAvailable and OnStopRequest off the main thread.
- */
-[uuid(27b84c48-5a73-4ba4-a8a4-8b5e649a145e)]
-interface nsIThreadRetargetableRequest : nsISupports
-{
-  /**
-   * Called to retarget delivery of OnDataAvailable and OnStopRequest to
-   * another thread. Should only be called within the context of OnStartRequest
-   * on the main thread.
-   *
-   * @param aNewTarget New event target, e.g. thread or threadpool.
-   *
-   * Note: no return value is given. If the retargeting cannot be handled,
-   * normal delivery to the main thread will continue. As such, listeners
-   * should be ready to deal with OnDataAvailable and OnStopRequest on
-   * either the main thread or the new target thread.
-   */
-  void retargetDeliveryTo(in nsIEventTarget aNewTarget);
-};
-
-
deleted file mode 100644
--- a/netwerk/base/public/nsIThreadRetargetableStreamListener.idl
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsISupports.idl"
-
-/**
- * nsIThreadRetargetableListener
- *
- * To be used by classes which implement nsIStreamListener and whose
- * OnDataAvailable and OnStopRequest may be retargeted for delivery off the
- * main thread.
- */
-[uuid(fb2304b8-f82f-4433-af68-d874a2ebbdc1)]
-interface nsIThreadRetargetableStreamListener : nsISupports
-{
-  /**
-   * Checks this listener and any next listeners it may have to verify that
-   * they can receive OnDataAvailable and OnStopRequest off the main thread.
-   * It is the responsibility of the implementing class to decide on the
-   * criteria to determine if retargeted delivery of these methods is
-   * possible, but it must check any and all nsIStreamListener objects that
-   * might be called in the listener chain.
-   *
-   * An exception should be thrown if a listener in the chain does not
-   * support retargeted delivery, i.e. if the next listener does not implement
-   * nsIThreadRetargetableStreamListener, or a call to its checkListenerChain()
-   * fails.
-   */
-  void checkListenerChain();
-};
-
--- a/netwerk/base/public/nsStreamListenerWrapper.h
+++ b/netwerk/base/public/nsStreamListenerWrapper.h
@@ -3,35 +3,32 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsStreamListenerWrapper_h__
 #define nsStreamListenerWrapper_h__
 
 #include "nsCOMPtr.h"
 #include "nsIStreamListener.h"
 #include "nsIRequestObserver.h"
-#include "nsIThreadRetargetableStreamListener.h"
 #include "mozilla/Attributes.h"
 
 // Wrapper class to make replacement of nsHttpChannel's listener
 // from JavaScript possible. It is workaround for bug 433711 and 682305.
 class nsStreamListenerWrapper MOZ_FINAL : public nsIStreamListener
-                                        , public nsIThreadRetargetableStreamListener
 {
 public:
   nsStreamListenerWrapper(nsIStreamListener *listener)
     : mListener(listener)
   {
     NS_ASSERTION(mListener, "no stream listener specified");
   }
 
   NS_DECL_ISUPPORTS
   NS_FORWARD_NSIREQUESTOBSERVER(mListener->)
   NS_FORWARD_NSISTREAMLISTENER(mListener->)
-  NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
 
 private:
   ~nsStreamListenerWrapper() {}
   nsCOMPtr<nsIStreamListener> mListener;
 };
 
 #endif // nsStreamListenerWrapper_h__
 
--- a/netwerk/base/src/nsInputStreamPump.cpp
+++ b/netwerk/base/src/nsInputStreamPump.cpp
@@ -6,23 +6,20 @@
 
 #include "nsIOService.h"
 #include "nsInputStreamPump.h"
 #include "nsIServiceManager.h"
 #include "nsIStreamTransportService.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsISeekableStream.h"
 #include "nsITransport.h"
-#include "nsIThreadRetargetableStreamListener.h"
-#include "nsStreamUtils.h"
 #include "nsNetUtil.h"
 #include "nsThreadUtils.h"
 #include "nsCOMPtr.h"
 #include "prlog.h"
-#include "nsPrintfCString.h"
 #include "GeckoProfiler.h"
 #include <algorithm>
 
 static NS_DEFINE_CID(kStreamTransportServiceCID, NS_STREAMTRANSPORTSERVICE_CID);
 
 #if defined(PR_LOGGING)
 //
 // NSPR_LOG_MODULES=nsStreamPump:5
@@ -39,17 +36,16 @@ nsInputStreamPump::nsInputStreamPump()
     : mState(STATE_IDLE)
     , mStreamOffset(0)
     , mStreamLength(UINT64_MAX)
     , mStatus(NS_OK)
     , mSuspendCount(0)
     , mLoadFlags(LOAD_NORMAL)
     , mWaiting(false)
     , mCloseWhenDone(false)
-    , mRetargeting(false)
 {
 #if defined(PR_LOGGING)
     if (!gStreamPumpLog)
         gStreamPumpLog = PR_NewLogModule("nsStreamPump");
 #endif
 }
 
 nsInputStreamPump::~nsInputStreamPump()
@@ -118,43 +114,38 @@ nsInputStreamPump::PeekStream(PeekSegmen
                                     nsIOService::gDefaultSegmentSize,
                                     &dummy);
 }
 
 nsresult
 nsInputStreamPump::EnsureWaiting()
 {
     // no need to worry about multiple threads... an input stream pump lives
-    // on only one thread at a time.
-    MOZ_ASSERT(mAsyncStream);
+    // on only one thread.
+
     if (!mWaiting) {
-        MOZ_ASSERT(mTargetThread);
         nsresult rv = mAsyncStream->AsyncWait(this, 0, 0, mTargetThread);
         if (NS_FAILED(rv)) {
             NS_ERROR("AsyncWait failed");
             return rv;
         }
-        // Any retargeting during STATE_START or START_TRANSFER is complete
-        // after the call to AsyncWait; next callback wil be on mTargetThread.
-        mRetargeting = false;
         mWaiting = true;
     }
     return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // nsInputStreamPump::nsISupports
 //-----------------------------------------------------------------------------
 
 // although this class can only be accessed from one thread at a time, we do
 // allow its ownership to move from thread to thread, assuming the consumer
 // understands the limitations of this.
-NS_IMPL_THREADSAFE_ISUPPORTS4(nsInputStreamPump,
+NS_IMPL_THREADSAFE_ISUPPORTS3(nsInputStreamPump,
                               nsIRequest,
-                              nsIThreadRetargetableRequest,
                               nsIInputStreamCallback,
                               nsIInputStreamPump)
 
 //-----------------------------------------------------------------------------
 // nsInputStreamPump::nsIRequest
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
@@ -384,40 +375,25 @@ nsInputStreamPump::OnInputStreamReady(ns
             nextState = OnStateStop();
             break;
         default:
             nextState = 0;
             NS_NOTREACHED("Unknown enum value.");
             return NS_ERROR_UNEXPECTED;
         }
 
-        bool stillTransferring = (mState == STATE_TRANSFER &&
-                                  nextState == STATE_TRANSFER);
-        if (stillTransferring) {
-            NS_ASSERTION(NS_SUCCEEDED(mStatus),
-                         "Should not have failed status for ongoing transfer");
-        } else {
-            NS_ASSERTION(mState != nextState,
-                         "Only OnStateTransfer can be called more than once.");
-        }
-        if (mRetargeting) {
-            NS_ASSERTION(mState != STATE_STOP,
-                         "Retargeting should not happen during OnStateStop.");
-        }
+        if (mState == nextState && !mSuspendCount) {
+            NS_ASSERTION(mState == STATE_TRANSFER, "unexpected state");
+            NS_ASSERTION(NS_SUCCEEDED(mStatus), "unexpected status");
 
-        // Wait asynchronously if there is still data to transfer, or if
-        // delivery of data has been requested on another thread.
-        if (!mSuspendCount && (stillTransferring || mRetargeting)) {
-            mState = nextState;
             mWaiting = false;
             mStatus = EnsureWaiting();
             if (NS_SUCCEEDED(mStatus))
                 break;
             
-            // Failure to start asynchronous wait: stop transfer.
             nextState = STATE_STOP;
         }
 
         mState = nextState;
     }
     return NS_OK;
 }
 
@@ -570,53 +546,18 @@ nsInputStreamPump::OnStateStop()
     if (NS_FAILED(mStatus))
         mAsyncStream->CloseWithStatus(mStatus);
     else if (mCloseWhenDone)
         mAsyncStream->Close();
 
     mAsyncStream = 0;
     mTargetThread = 0;
     mIsPending = false;
-    mRetargeting = false;
 
     mListener->OnStopRequest(this, mListenerContext, mStatus);
     mListener = 0;
     mListenerContext = 0;
 
     if (mLoadGroup)
         mLoadGroup->RemoveRequest(this, nullptr, mStatus);
 
     return STATE_IDLE;
 }
-
-//-----------------------------------------------------------------------------
-// nsIThreadRetargetableRequest
-//-----------------------------------------------------------------------------
-
-NS_IMETHODIMP
-nsInputStreamPump::RetargetDeliveryTo(nsIEventTarget* aNewTarget)
-{
-    NS_ENSURE_ARG(aNewTarget);
-    if (aNewTarget == mTargetThread) {
-        NS_WARNING("Retargeting delivery to same thread");
-        return NS_OK;
-    }
-    NS_ENSURE_TRUE(mState == STATE_START || mState == STATE_TRANSFER,
-                   NS_ERROR_UNEXPECTED);
-
-    // Ensure that |mListener| and any subsequent listeners can be retargeted
-    // to another thread.
-    nsresult rv = NS_OK;
-    nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
-        do_QueryInterface(mListener, &rv);
-    if (NS_SUCCEEDED(rv) && retargetableListener) {
-        rv = retargetableListener->CheckListenerChain();
-        if (NS_SUCCEEDED(rv)) {
-            mTargetThread = aNewTarget;
-            mRetargeting = true;
-        }
-    }
-    LOG(("nsInputStreamPump::RetargetDeliveryTo [this=%x aNewTarget=%p] "
-         "%s listener [%p] rv[%x]",
-         this, aNewTarget, (mTargetThread == aNewTarget ? "success" : "failure"),
-         (nsIStreamListener*)mListener, rv));
-    return rv;
-}
--- a/netwerk/base/src/nsInputStreamPump.h
+++ b/netwerk/base/src/nsInputStreamPump.h
@@ -10,30 +10,27 @@
 #include "nsIInputStream.h"
 #include "nsIURI.h"
 #include "nsILoadGroup.h"
 #include "nsIStreamListener.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIProgressEventSink.h"
 #include "nsIAsyncInputStream.h"
 #include "nsIThread.h"
-#include "nsIThreadRetargetableRequest.h"
 #include "nsCOMPtr.h"
 #include "mozilla/Attributes.h"
 
 class nsInputStreamPump MOZ_FINAL : public nsIInputStreamPump
                                   , public nsIInputStreamCallback
-                                  , public nsIThreadRetargetableRequest
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIREQUEST
     NS_DECL_NSIINPUTSTREAMPUMP
     NS_DECL_NSIINPUTSTREAMCALLBACK
-    NS_DECL_NSITHREADRETARGETABLEREQUEST
 
     nsInputStreamPump(); 
     ~nsInputStreamPump();
 
     static NS_HIDDEN_(nsresult)
                       Create(nsInputStreamPump  **result,
                              nsIInputStream      *stream,
                              int64_t              streamPos = -1,
@@ -69,25 +66,24 @@ protected:
     uint32_t OnStateStart();
     uint32_t OnStateTransfer();
     uint32_t OnStateStop();
 
     uint32_t                      mState;
     nsCOMPtr<nsILoadGroup>        mLoadGroup;
     nsCOMPtr<nsIStreamListener>   mListener;
     nsCOMPtr<nsISupports>         mListenerContext;
-    nsCOMPtr<nsIEventTarget>      mTargetThread;
+    nsCOMPtr<nsIThread>           mTargetThread;
     nsCOMPtr<nsIInputStream>      mStream;
     nsCOMPtr<nsIAsyncInputStream> mAsyncStream;
     uint64_t                      mStreamOffset;
     uint64_t                      mStreamLength;
     uint32_t                      mSegSize;
     uint32_t                      mSegCount;
     nsresult                      mStatus;
     uint32_t                      mSuspendCount;
     uint32_t                      mLoadFlags;
     bool                          mIsPending;
     bool                          mWaiting; // true if waiting on async source
     bool                          mCloseWhenDone;
-    bool                          mRetargeting;
 };
 
 #endif // !nsInputStreamChannel_h__
--- a/netwerk/base/src/nsStreamListenerTee.cpp
+++ b/netwerk/base/src/nsStreamListenerTee.cpp
@@ -1,20 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsStreamListenerTee.h"
 #include "nsProxyRelease.h"
 
-NS_IMPL_THREADSAFE_ISUPPORTS4(nsStreamListenerTee,
-                              nsIStreamListener,
-                              nsIRequestObserver,
-                              nsIStreamListenerTee,
-                              nsIThreadRetargetableStreamListener)
+NS_IMPL_ISUPPORTS3(nsStreamListenerTee,
+                   nsIStreamListener,
+                   nsIRequestObserver,
+                   nsIStreamListenerTee)
 
 NS_IMETHODIMP
 nsStreamListenerTee::OnStartRequest(nsIRequest *request,
                                     nsISupports *context)
 {
     NS_ENSURE_TRUE(mListener, NS_ERROR_NOT_INITIALIZED);
     nsresult rv1 = mListener->OnStartRequest(request, context);
     nsresult rv2 = NS_OK;
@@ -89,39 +88,16 @@ nsStreamListenerTee::OnDataAvailable(nsI
         tee = do_QueryInterface(mInputTee, &rv);
         if (NS_FAILED(rv)) return rv;
     }
 
     return mListener->OnDataAvailable(request, context, tee, offset, count);
 }
 
 NS_IMETHODIMP
-nsStreamListenerTee::CheckListenerChain()
-{
-    NS_ASSERTION(NS_IsMainThread(), "Should be on main thread!");
-    nsresult rv = NS_OK;
-    nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
-        do_QueryInterface(mListener, &rv);
-    if (retargetableListener) {
-        rv = retargetableListener->CheckListenerChain();
-    }
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    if (!mObserver) {
-      return rv;
-    }
-    retargetableListener = do_QueryInterface(mObserver, &rv);
-    if (retargetableListener) {
-        rv = retargetableListener->CheckListenerChain();
-    }
-    return rv;
-}
-
-NS_IMETHODIMP
 nsStreamListenerTee::Init(nsIStreamListener *listener,
                           nsIOutputStream *sink,
                           nsIRequestObserver *requestObserver)
 {
     NS_ENSURE_ARG_POINTER(listener);
     NS_ENSURE_ARG_POINTER(sink);
     mListener = listener;
     mSink = sink;
--- a/netwerk/base/src/nsStreamListenerTee.h
+++ b/netwerk/base/src/nsStreamListenerTee.h
@@ -1,30 +1,27 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsStreamListenerTee_h__
 #define nsStreamListenerTee_h__
 
 #include "nsIStreamListenerTee.h"
-#include "nsIThreadRetargetableStreamListener.h"
 #include "nsIInputStreamTee.h"
 #include "nsIOutputStream.h"
 #include "nsCOMPtr.h"
 #include "nsIEventTarget.h"
 
 class nsStreamListenerTee : public nsIStreamListenerTee
-                          , public nsIThreadRetargetableStreamListener
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIREQUESTOBSERVER
     NS_DECL_NSISTREAMLISTENER
-    NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
     NS_DECL_NSISTREAMLISTENERTEE
 
     nsStreamListenerTee() { }
     virtual ~nsStreamListenerTee() { }
 
 private:
     nsCOMPtr<nsIInputStreamTee>  mInputTee;
     nsCOMPtr<nsIOutputStream>    mSink;
--- a/netwerk/base/src/nsStreamListenerWrapper.cpp
+++ b/netwerk/base/src/nsStreamListenerWrapper.cpp
@@ -1,24 +1,10 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsStreamListenerWrapper.h"
-#include "nsThreadUtils.h"
-
-NS_IMPL_ISUPPORTS3(nsStreamListenerWrapper,
-                   nsIStreamListener,
-                   nsIRequestObserver,
-                   nsIThreadRetargetableStreamListener)
 
-NS_IMETHODIMP
-nsStreamListenerWrapper::CheckListenerChain()
-{
-    NS_ASSERTION(NS_IsMainThread(), "Should be on main thread!");
-    nsresult rv = NS_OK;
-    nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
-        do_QueryInterface(mListener, &rv);
-    if (retargetableListener) {
-        rv = retargetableListener->CheckListenerChain();
-    }
-    return rv;
-}
+NS_IMPL_ISUPPORTS2(nsStreamListenerWrapper,
+                   nsIStreamListener,
+                   nsIRequestObserver)
+
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -24,17 +24,16 @@
 #include "nsStreamUtils.h"
 #include "nsIOService.h"
 #include "nsICacheService.h"
 #include "nsDNSPrefetch.h"
 #include "nsChannelClassifier.h"
 #include "nsIRedirectResultListener.h"
 #include "mozilla/TimeStamp.h"
 #include "nsError.h"
-#include "nsPrintfCString.h"
 #include "nsAlgorithm.h"
 #include "GeckoProfiler.h"
 #include "nsIConsoleService.h"
 #include "base/compiler_specific.h"
 #include "NullHttpTransaction.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/VisualEventTracer.h"
 
@@ -4248,18 +4247,16 @@ NS_INTERFACE_MAP_BEGIN(nsHttpChannel)
     NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
     NS_INTERFACE_MAP_ENTRY(nsIProtocolProxyCallback)
     NS_INTERFACE_MAP_ENTRY(nsIProxiedChannel)
     NS_INTERFACE_MAP_ENTRY(nsIHttpAuthenticableChannel)
     NS_INTERFACE_MAP_ENTRY(nsIApplicationCacheContainer)
     NS_INTERFACE_MAP_ENTRY(nsIApplicationCacheChannel)
     NS_INTERFACE_MAP_ENTRY(nsIAsyncVerifyRedirectCallback)
     NS_INTERFACE_MAP_ENTRY(nsITimedChannel)
-    NS_INTERFACE_MAP_ENTRY(nsIThreadRetargetableRequest)
-    NS_INTERFACE_MAP_ENTRY(nsIThreadRetargetableStreamListener)
 NS_INTERFACE_MAP_END_INHERITING(HttpBaseChannel)
 
 //-----------------------------------------------------------------------------
 // nsHttpChannel::nsIRequest
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsHttpChannel::Cancel(nsresult status)
@@ -4941,52 +4938,16 @@ nsresult
 nsHttpChannel::ContinueOnStartRequest3(nsresult result)
 {
     if (mFallingBack)
         return NS_OK;
 
     return CallOnStartRequest();
 }
 
-class OnStopRequestCleanupEvent : public nsRunnable
-{
-public:
-    OnStopRequestCleanupEvent(nsHttpChannel *aHttpChannel,
-                              nsresult aStatus)
-    : mHttpChannel(aHttpChannel)
-    , mStatus(aStatus)
-    {
-        MOZ_ASSERT(!NS_IsMainThread(), "Shouldn't be created on main thread");
-        NS_ASSERTION(aHttpChannel, "aHttpChannel should not be null");
-    }
-
-    NS_IMETHOD Run()
-    {
-        MOZ_ASSERT(NS_IsMainThread(), "Should run on main thread");
-        if (mHttpChannel) {
-            mHttpChannel->OnStopRequestCleanup(mStatus);
-        }
-        return NS_OK;
-    }
-private:
-    nsRefPtr<nsHttpChannel> mHttpChannel;
-    nsresult mStatus;
-};
-
-nsresult
-nsHttpChannel::OnStopRequestCleanup(nsresult aStatus)
-{
-    NS_ASSERTION(NS_IsMainThread(), "Should be on main thread");
-    if (mLoadGroup) {
-        mLoadGroup->RemoveRequest(this, nullptr, aStatus);
-    }
-    ReleaseListeners();
-    return NS_OK;
-}
-
 NS_IMETHODIMP
 nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status)
 {
     PROFILER_LABEL("network", "nsHttpChannel::OnStopRequest");
     LOG(("nsHttpChannel::OnStopRequest [this=%p request=%p status=%x]\n",
         this, request, status));
 
     if (mTimingEnabled && request == mCachePump) {
@@ -5106,65 +5067,31 @@ nsHttpChannel::OnStopRequest(nsIRequest 
 
     MOZ_EVENT_TRACER_DONE(this, "net::http::channel");
 
     CloseCacheEntry(!contentComplete);
 
     if (mOfflineCacheEntry)
         CloseOfflineCacheEntry();
 
-    if (NS_IsMainThread()) {
-        OnStopRequestCleanup(status);
-    } else {
-        nsresult rv = NS_DispatchToMainThread(
-            new OnStopRequestCleanupEvent(this, status));
-        NS_ENSURE_SUCCESS(rv, rv);
-    }
+    if (mLoadGroup)
+        mLoadGroup->RemoveRequest(this, nullptr, status);
 
     // We don't need this info anymore
     CleanRedirectCacheChainIfNecessary();
 
+    ReleaseListeners();
+
     return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // nsHttpChannel::nsIStreamListener
 //-----------------------------------------------------------------------------
 
-class OnTransportStatusAsyncEvent : public nsRunnable
-{
-public:
-    OnTransportStatusAsyncEvent(nsITransportEventSink* aEventSink,
-                                nsresult aTransportStatus,
-                                uint64_t aProgress,
-                                uint64_t aProgressMax)
-    : mEventSink(aEventSink)
-    , mTransportStatus(aTransportStatus)
-    , mProgress(aProgress)
-    , mProgressMax(aProgressMax)
-    {
-        MOZ_ASSERT(!NS_IsMainThread(), "Shouldn't be created on main thread");
-    }
-
-    NS_IMETHOD Run()
-    {
-        MOZ_ASSERT(NS_IsMainThread(), "Should run on main thread");
-        if (mEventSink) {
-            mEventSink->OnTransportStatus(nullptr, mTransportStatus,
-                                          mProgress, mProgressMax);
-        }
-        return NS_OK;
-    }
-private:
-    nsCOMPtr<nsITransportEventSink> mEventSink;
-    nsresult mTransportStatus;
-    uint64_t mProgress;
-    uint64_t mProgressMax;
-};
-
 NS_IMETHODIMP
 nsHttpChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
                                nsIInputStream *input,
                                uint64_t offset, uint32_t count)
 {
     PROFILER_LABEL("network", "nsHttpChannel::OnDataAvailable");
     LOG(("nsHttpChannel::OnDataAvailable [this=%p request=%p offset=%llu count=%u]\n",
         this, request, offset, count));
@@ -5199,24 +5126,17 @@ nsHttpChannel::OnDataAvailable(nsIReques
         // holds our best estimate of the total content length.  Even in the case
         // of a byte range request, the content length stored in the cached
         // response headers is what we want to use here.
 
         uint64_t progressMax(uint64_t(mResponseHead->ContentLength()));
         uint64_t progress = mLogicalOffset + uint64_t(count);
         MOZ_ASSERT(progress <= progressMax, "unexpected progress values");
 
-        if (NS_IsMainThread()) {
-            OnTransportStatus(nullptr, transportStatus, progress, progressMax);
-        } else {
-            nsresult rv = NS_DispatchToMainThread(
-                new OnTransportStatusAsyncEvent(this, transportStatus,
-                                                progress, progressMax));
-            NS_ENSURE_SUCCESS(rv, rv);
-        }
+        OnTransportStatus(nullptr, transportStatus, progress, progressMax);
 
         //
         // we have to manually keep the logical offset of the stream up-to-date.
         // we cannot depend solely on the offset provided, since we may have
         // already streamed some data from another source (see, for example,
         // OnDoneReadingPartialCacheEntry).
         //
         if (!mLogicalOffset)
@@ -5231,77 +5151,16 @@ nsHttpChannel::OnDataAvailable(nsIReques
             mLogicalOffset = progress;
         return rv;
     }
 
     return NS_ERROR_ABORT;
 }
 
 //-----------------------------------------------------------------------------
-// nsHttpChannel::nsIThreadRetargetableRequest
-//-----------------------------------------------------------------------------
-
-NS_IMETHODIMP
-nsHttpChannel::RetargetDeliveryTo(nsIEventTarget* aNewTarget)
-{
-    MOZ_ASSERT(NS_IsMainThread(), "Should be called on main thread only");
-
-    NS_ENSURE_ARG(aNewTarget);
-    if (aNewTarget == NS_GetCurrentThread()) {
-        NS_WARNING("Retargeting delivery to same thread");
-        return NS_OK;
-    }
-    NS_ENSURE_TRUE(mTransactionPump || mCachePump, NS_ERROR_NOT_AVAILABLE);
-
-    nsresult rv = NS_OK;
-    // If both cache pump and transaction pump exist, we're probably dealing
-    // with partially cached content. So, we must be able to retarget both.
-    nsCOMPtr<nsIThreadRetargetableRequest> retargetableCachePump;
-    nsCOMPtr<nsIThreadRetargetableRequest> retargetableTransactionPump;
-    if (mCachePump) {
-        retargetableCachePump = do_QueryObject(mCachePump);
-        // nsInputStreamPump should implement this interface.
-        MOZ_ASSERT(retargetableCachePump);
-        rv = retargetableCachePump->RetargetDeliveryTo(aNewTarget);
-    }
-    if (NS_SUCCEEDED(rv) && mTransactionPump) {
-        retargetableTransactionPump = do_QueryObject(mTransactionPump);
-        // nsInputStreamPump should implement this interface.
-        MOZ_ASSERT(retargetableTransactionPump);
-        rv = retargetableTransactionPump->RetargetDeliveryTo(aNewTarget);
-
-        // If retarget fails for transaction pump, we must restore mCachePump.
-        if (NS_FAILED(rv) && retargetableCachePump) {
-            nsCOMPtr<nsIThread> mainThread;
-            rv = NS_GetMainThread(getter_AddRefs(mainThread));
-            NS_ENSURE_SUCCESS(rv, rv);
-            rv = retargetableCachePump->RetargetDeliveryTo(mainThread);
-        }
-    }
-    return rv;
-}
-
-//-----------------------------------------------------------------------------
-// nsHttpChannel::nsThreadRetargetableStreamListener
-//-----------------------------------------------------------------------------
-
-NS_IMETHODIMP
-nsHttpChannel::CheckListenerChain()
-{
-    NS_ASSERTION(NS_IsMainThread(), "Should be on main thread!");
-    nsresult rv = NS_OK;
-    nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
-        do_QueryInterface(mListener, &rv);
-    if (retargetableListener) {
-        rv = retargetableListener->CheckListenerChain();
-    }
-    return rv;
-}
-
-//-----------------------------------------------------------------------------
 // nsHttpChannel::nsITransportEventSink
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsHttpChannel::OnTransportStatus(nsITransport *trans, nsresult status,
                                  uint64_t progress, uint64_t progressMax)
 {
     // cache the progress sink so we don't have to query for it each time.
--- a/netwerk/protocol/http/nsHttpChannel.h
+++ b/netwerk/protocol/http/nsHttpChannel.h
@@ -23,18 +23,16 @@
 #include "nsIResumableChannel.h"
 #include "nsIProtocolProxyCallback.h"
 #include "nsICancelable.h"
 #include "nsIHttpAuthenticableChannel.h"
 #include "nsIHttpChannelAuthProvider.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsITimedChannel.h"
 #include "nsIFile.h"
-#include "nsIThreadRetargetableRequest.h"
-#include "nsIThreadRetargetableStreamListener.h"
 #include "nsDNSPrefetch.h"
 #include "TimingStruct.h"
 #include "AutoClose.h"
 #include "mozilla/Telemetry.h"
 
 class nsAHttpConnection;
 
 namespace mozilla { namespace net {
@@ -51,35 +49,31 @@ class nsHttpChannel : public HttpBaseCha
                     , public nsICachingChannel
                     , public nsICacheListener
                     , public nsITransportEventSink
                     , public nsIProtocolProxyCallback
                     , public nsIHttpAuthenticableChannel
                     , public nsIApplicationCacheChannel
                     , public nsIAsyncVerifyRedirectCallback
                     , public nsITimedChannel
-                    , public nsIThreadRetargetableRequest
-                    , public nsIThreadRetargetableStreamListener
 {
 public:
     NS_DECL_ISUPPORTS_INHERITED
     NS_DECL_NSIREQUESTOBSERVER
     NS_DECL_NSISTREAMLISTENER
-    NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
     NS_DECL_NSICACHEINFOCHANNEL
     NS_DECL_NSICACHINGCHANNEL
     NS_DECL_NSICACHELISTENER
     NS_DECL_NSITRANSPORTEVENTSINK
     NS_DECL_NSIPROTOCOLPROXYCALLBACK
     NS_DECL_NSIPROXIEDCHANNEL
     NS_DECL_NSIAPPLICATIONCACHECONTAINER
     NS_DECL_NSIAPPLICATIONCACHECHANNEL
     NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
     NS_DECL_NSITIMEDCHANNEL
-    NS_DECL_NSITHREADRETARGETABLEREQUEST
 
     // nsIHttpAuthenticableChannel. We can't use
     // NS_DECL_NSIHTTPAUTHENTICABLECHANNEL because it duplicates cancel() and
     // others.
     NS_IMETHOD GetIsSSL(bool *aIsSSL);
     NS_IMETHOD GetProxyMethodIsConnect(bool *aProxyMethodIsConnect);
     NS_IMETHOD GetServerResponseHeader(nsACString & aServerResponseHeader);
     NS_IMETHOD GetProxyChallenges(nsACString & aChallenges);
@@ -151,18 +145,16 @@ public: /* internal necko use only */
              , mCacheKey(key)
         {}
 
         nsresult MarkAsForeign();
     };
 
     OfflineCacheEntryAsForeignMarker* GetOfflineCacheEntryAsForeignMarker();
 
-    nsresult OnStopRequestCleanup(nsresult aStatus);
-
 private:
     typedef nsresult (nsHttpChannel::*nsContinueRedirectionFunc)(nsresult result);
 
     bool     RequestIsConditional();
     nsresult BeginConnect();
     nsresult Connect();
     nsresult ContinueConnect();
     void     SpeculativeConnect();
deleted file mode 100644
--- a/netwerk/test/mochitests/Makefile.in
+++ /dev/null
@@ -1,21 +0,0 @@
-# -*- Mode: Makefile; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-# vim: set ts=8 sts=2 et sw=2 tw=80:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-DEPTH		= @DEPTH@
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-relativesrcdir	= @relativesrcdir@
-FAIL_ON_WARNINGS := 1
-
-include $(DEPTH)/config/autoconf.mk
-
-MOCHITEST_FILES = \
-  partial_content.sjs \
-  test_partially_cached_content.html \
-  $(NULL)
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/netwerk/test/mochitests/moz.build
+++ /dev/null
@@ -1,7 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-MODULE = 'test_necko'
deleted file mode 100644
--- a/netwerk/test/mochitests/partial_content.sjs
+++ /dev/null
@@ -1,154 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* Debug and Error wrapper functions for dump().
- */
-function ERR(response, responseCode, responseCodeStr, msg)
-{
-  // Reset state var.
-  setState("expectedRequestType", "");
-  // Dump to console log and send to client in response.
-  dump("SERVER ERROR: " + msg + "\n");
-  response.write("HTTP/1.1" + responseCode + responseCodeStr + "\r\n");
-  response.write("Content-Type: text/html; charset=UTF-8\r\n");
-  response.write("Content-Length: " + msg.length + "\r\n");
-  response.write("\r\n");
-  response.write(msg);
-}
-
-function DBG(msg)
-{
-  // enable when you want to debug
-  if (0) {
-    // Dump to console only.
-    dump("SERVER DEBUG: " + msg + "\n");
-  }
-}
-
-/* Delivers content in parts to test partially cached content: requires two
- * requests for the same resource.
- *
- * First call will respond with partial content, but a 200 header and
- * Content-Length equal to the full content length. No Range or If-Range
- * headers are allowed in the request.
- *
- * Second call will require Range and If-Range in the request headers, and
- * will respond with the range requested.
- */
-function handleRequest(request, response)
-{
-  DBG("Trying to seize power");
-  response.seizePower();
-
-  DBG("About to check state vars");
-  // Get state var to determine if this is the first or second request.
-  var expectedRequestType;
-  var lastModified;
-  if (getState("expectedRequestType") === "") {
-    DBG("First call: Should be requesting full content.");
-    expectedRequestType = "fullRequest";
-    // Set state var for second request.
-    setState("expectedRequestType", "partialRequest");
-    // Create lastModified variable for responses.
-    lastModified = (new Date()).toUTCString();
-    setState("lastModified", lastModified);
-  } else if (getState("expectedRequestType") === "partialRequest") {
-    DBG("Second call: Should be requesting undelivered content.");
-    expectedRequestType = "partialRequest";
-    // Reset state var for first request.
-    setState("expectedRequestType", "");
-    // Get last modified date and reset state var.
-    lastModified = getState("lastModified");
-  } else {
-    ERR(response, 500, "Internal Server Error",
-        "Invalid expectedRequestType \"" + expectedRequestType + "\"in " +
-        "server state db.");
-    return;
-  }
-
-  // Look for Range and If-Range
-  var range = request.hasHeader("Range") ? request.getHeader("Range") : "";
-  var ifRange = request.hasHeader("If-Range") ? request.getHeader("If-Range") : "";
-
-  if (expectedRequestType === "fullRequest") {
-    // Should not have Range or If-Range in first request.
-    if (range && range.length > 0) {
-      ERR(response, 400, "Bad Request",
-          "Should not receive \"Range: " + range + "\" for first, full request.");
-      return;
-    }
-    if (ifRange && ifRange.length > 0) {
-      ERR(response, 400, "Bad Request",
-          "Should not receive \"Range: " + range + "\" for first, full request.");
-      return;
-    }
-  } else if (expectedRequestType === "partialRequest") {
-    // Range AND If-Range should both be present in second request.
-    if (!range) {
-      ERR(response, 400, "Bad Request",
-          "Should receive \"Range: \" for second, partial request.");
-      return;
-    }
-    if (!ifRange) {
-      ERR(response, 400, "Bad Request",
-          "Should receive \"If-Range: \" for second, partial request.");
-      return;
-    }
-  } else {
-    // Somewhat redundant, but a check for errors in this test code.
-    ERR(response, 500, "Internal Server Error",
-        "expectedRequestType not set correctly: \"" + expectedRequestType + "\"");
-    return;
-  }
-
-  // Prepare content in two parts for responses.
-  var partialContent = "<html><head></head><body><p id=\"firstResponse\">" +
-                       "First response</p>";
-  var remainderContent = "<p id=\"secondResponse\">Second response</p>" +
-                         "</body></html>";
-  var totalLength = partialContent.length + remainderContent.length;
-
-  DBG("totalLength: " + totalLength);
-
-  // Prepare common headers for the two responses.
-  date = new Date();
-  DBG("Date: " + date.toUTCString() + ", Last-Modified: " + lastModified);
-  var commonHeaders = "Date: " + date.toUTCString() + "\r\n" +
-                      "Last-Modified: " + lastModified + "\r\n" +
-                      "Content-Type: text/html; charset=UTF-8\r\n" +
-                      "ETag: abcd0123\r\n" +
-                      "Accept-Ranges: bytes\r\n";
-
-
-  // Prepare specific headers and content for first and second responses.
-  if (expectedRequestType === "fullRequest") {
-    DBG("First response: Sending partial content with a full header");
-    response.write("HTTP/1.1 200 OK\r\n");
-    response.write(commonHeaders);
-    // Set Content-Length to full length of resource.
-    response.write("Content-Length: " + totalLength + "\r\n");
-    response.write("\r\n");
-    response.write(partialContent);
-  } else if (expectedRequestType === "partialRequest") {
-    DBG("Second response: Sending remaining content with a range header");
-    response.write("HTTP/1.1 206 Partial Content\r\n");
-    response.write(commonHeaders);
-    // Set Content-Length to length of bytes transmitted.
-    response.write("Content-Length: " + remainderContent.length + "\r\n");
-    response.write("Content-Range: bytes " + partialContent.length + "-" +
-                   (totalLength - 1) + "/" + totalLength + "\r\n");
-    response.write("\r\n");
-    response.write(remainderContent);
-  } else {
-    // Somewhat redundant, but a check for errors in this test code.
-    ERR(response, 500, "Internal Server Error",
-       "Something very bad happened here: expectedRequestType is invalid " +
-       "towards the end of handleRequest! - \"" + expectedRequestType + "\"");
-    return;
-  }
-
-  response.finish();
-}
deleted file mode 100644
--- a/netwerk/test/mochitests/test_partially_cached_content.html
+++ /dev/null
@@ -1,90 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-  https://bugzilla.mozilla.org/show_bug.cgi?id=497003
-
-  This test verifies that partially cached content is read from the cache first
-  and then from the network. It is written in the mochitest framework to take
-  thread retargeting into consideration of nsIStreamListener callbacks (inc.
-  nsIRequestObserver). E.g. HTML5 Stream Parser requesting retargeting of
-  nsIStreamListener callbacks to the parser thread.
--->
-<head>
-  <meta charset="UTF-8">
-  <title>Test for Bug 497003: support sending OnDataAvailable() to other threads</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-  <p><a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=497003">Mozilla Bug 497003: support sending OnDataAvailable() to other threads</a></p>
-  <p><iframe id="contentFrame" src="partial_content.sjs"></iframe></p>
-
-<pre id="test">
-<script>
-
-
-
-/* Check that the iframe has initial content only after the first load.
- */
-function expectInitialContent(e) {
-  info("expectInitialContent",
-       "First response received: should have partial content");
-  var frameWindow = document.getElementById('contentFrame').contentWindow;
-
-  // Expect "First response" in received HTML.
-  var firstResponse = frameWindow.document.getElementById('firstResponse');
-  ok(firstResponse, "First response should exist");
-  if (firstResponse) {
-    is(firstResponse.innerHTML, "First response",
-       "First response should be correct");
-  }
-
-  // Expect NOT to get any second response element.
-  var secondResponse = frameWindow.document.getElementById('secondResponse');
-  ok(!secondResponse, "Should not get text for second response in first.");
-
-  // Set up listener for second load.
-  e.target.removeEventListener("load", expectInitialContent, false);
-  e.target.addEventListener("load", expectFullContent, false);
-
-  // Reload.
-  e.target.src="partial_content.sjs";
-}
-
-/* Check that the iframe has all the content after the second load.
- */
-function expectFullContent(e)
-{
-  info("expectFullContent",
-       "Second response received: should complete content from first load");
-  var frameWindow = document.getElementById('contentFrame').contentWindow;
-
-  // Expect "First response" to still be there
-  var firstResponse = frameWindow.document.getElementById('firstResponse');
-  ok(firstResponse, "First response should exist");
-  if (firstResponse) {
-    is(firstResponse.innerHTML, "First response",
-       "First response should be correct");
-  }
-
-  // Expect "Second response" to be there also.
-  var secondResponse = frameWindow.document.getElementById('secondResponse');
-  ok(secondResponse, "Second response should exist");
-  if (secondResponse) {
-    is(secondResponse.innerHTML, "Second response",
-       "Second response should be correct");
-  }
-
-  SimpleTest.finish();
-}
-
-// Set listener for first load to expect partial content.
-document.getElementById('contentFrame')
-  .addEventListener("load", expectInitialContent, false);
-
-SimpleTest.waitForExplicitFinish();
-
-</script>
-</pre>
-</body>
-</html>
--- a/netwerk/test/moz.build
+++ b/netwerk/test/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-TEST_DIRS += ['httpserver', 'browser', 'mochitests']
+TEST_DIRS += ['httpserver', 'browser']
 
 MODULE = 'test_necko'
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 # FIXME/bug 575918: out-of-process xpcshell is broken on OS X
 if CONFIG['OS_ARCH'] != 'Darwin':
     XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini']
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -21,18 +21,16 @@
 #include "nsIScriptError.h"
 #include "mozilla/Preferences.h"
 #include "nsHtml5Highlighter.h"
 #include "expat_config.h"
 #include "expat.h"
 #include "nsINestedURI.h"
 #include "nsCharsetSource.h"
 #include "nsIWyciwygChannel.h"
-#include "nsIThreadRetargetableRequest.h"
-#include "nsPrintfCString.h"
 
 #include "mozilla/dom/EncodingUtils.h"
 
 using namespace mozilla;
 using mozilla::dom::EncodingUtils;
 
 int32_t nsHtml5StreamParser::sTimerInitialDelay = 120;
 int32_t nsHtml5StreamParser::sTimerSubsequentDelay = 120;
@@ -70,20 +68,19 @@ nsHtml5StreamParser::InitializeStatics()
  * posted from the parser thread to main thread don't need to wrap any
  * runnable-specific data. (In the other direction, the runnables most notably
  * wrap the byte data of the stream.)
  */
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsHtml5StreamParser)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsHtml5StreamParser)
 
 NS_INTERFACE_TABLE_HEAD(nsHtml5StreamParser)
-  NS_INTERFACE_TABLE3(nsHtml5StreamParser,
+  NS_INTERFACE_TABLE2(nsHtml5StreamParser, 
                       nsIStreamListener, 
-                      nsICharsetDetectionObserver,
-                      nsIThreadRetargetableStreamListener)
+                      nsICharsetDetectionObserver)
   NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsHtml5StreamParser)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsHtml5StreamParser)
   tmp->DropTimer();
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mObserver)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mRequest)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner)
@@ -924,24 +921,16 @@ nsHtml5StreamParser::OnStartRequest(nsIR
     // XXX does Necko have a way to renavigate POST, etc. without hitting
     // the network?
     if (!method.EqualsLiteral("GET")) {
       // This is the old Gecko behavior but the HTML5 spec disagrees.
       // Don't reparse on POST.
       mReparseForbidden = true;
       mFeedChardet = false; // can't restart anyway
     }
-
-    // Attempt to retarget delivery of data (via OnDataAvailable) to the parser
-    // thread, rather than through the main thread.
-    nsCOMPtr<nsIThreadRetargetableRequest> threadRetargetableRequest =
-      do_QueryInterface(mRequest);
-    if (threadRetargetableRequest) {
-      threadRetargetableRequest->RetargetDeliveryTo(mThread);
-    }
   }
 
   if (mCharsetSource == kCharsetFromParentFrame) {
     // Remember this in case chardet overwrites mCharsetSource
     mInitialEncodingWasFromParentFrame = true;
   }
 
   if (mCharsetSource >= kCharsetFromAutoDetection) {
@@ -966,32 +955,16 @@ nsHtml5StreamParser::OnStartRequest(nsIR
   // if we failed to get a decoder, there will be fallback, so don't propagate
   //  the error.
   if (NS_FAILED(rv)) {
     mCharsetSource = kCharsetFromWeakDocTypeDefault;
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsHtml5StreamParser::CheckListenerChain()
-{
-  NS_ASSERTION(NS_IsMainThread(), "Should be on the main thread!");
-  if (!mObserver) {
-    return NS_OK;
-  }
-  nsresult rv;
-  nsCOMPtr<nsIThreadRetargetableStreamListener> retargetable =
-    do_QueryInterface(mObserver, &rv);
-  if (NS_SUCCEEDED(rv) && retargetable) {
-    rv = retargetable->CheckListenerChain();
-  }
-  return rv;
-}
-
 void
 nsHtml5StreamParser::DoStopRequest()
 {
   NS_ASSERTION(IsParserThread(), "Wrong thread!");
   NS_PRECONDITION(STREAM_BEING_READ == mStreamState,
                   "Stream ended without being open.");
   mTokenizerMutex.AssertCurrentThreadOwns();
 
@@ -1035,34 +1008,29 @@ class nsHtml5RequestStopper : public nsR
 };
 
 nsresult
 nsHtml5StreamParser::OnStopRequest(nsIRequest* aRequest,
                              nsISupports* aContext,
                              nsresult status)
 {
   NS_ASSERTION(mRequest == aRequest, "Got Stop on wrong stream.");
-  NS_ASSERTION(NS_IsMainThread() || IsParserThread(), "Wrong thread!");
+  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   if (mObserver) {
     mObserver->OnStopRequest(aRequest, aContext, status);
   }
-  if (NS_IsMainThread()) {
-    nsCOMPtr<nsIRunnable> stopper = new nsHtml5RequestStopper(this);
-    if (NS_FAILED(mThread->Dispatch(stopper, nsIThread::DISPATCH_NORMAL))) {
-      NS_WARNING("Dispatching StopRequest event failed.");
-    }
-  } else {
-    mozilla::MutexAutoLock autoLock(mTokenizerMutex);
-    DoStopRequest();
+  nsCOMPtr<nsIRunnable> stopper = new nsHtml5RequestStopper(this);
+  if (NS_FAILED(mThread->Dispatch(stopper, nsIThread::DISPATCH_NORMAL))) {
+    NS_WARNING("Dispatching StopRequest event failed.");
   }
   return NS_OK;
 }
 
 void
-nsHtml5StreamParser::DoDataAvailable(const uint8_t* aBuffer, uint32_t aLength)
+nsHtml5StreamParser::DoDataAvailable(uint8_t* aBuffer, uint32_t aLength)
 {
   NS_ASSERTION(IsParserThread(), "Wrong thread!");
   NS_PRECONDITION(STREAM_BEING_READ == mStreamState,
                   "DoDataAvailable called when stream not open.");
   mTokenizerMutex.AssertCurrentThreadOwns();
 
   if (IsTerminated()) {
     return;
@@ -1137,68 +1105,34 @@ nsHtml5StreamParser::OnDataAvailable(nsI
 {
   nsresult rv;
   if (NS_FAILED(rv = mExecutor->IsBroken())) {
     return rv;
   }
 
   NS_ASSERTION(mRequest == aRequest, "Got data on wrong stream.");
   uint32_t totalRead;
-  // Main thread to parser thread dispatch requires copying to buffer first.
-  if (NS_IsMainThread()) {
-    const mozilla::fallible_t fallible = mozilla::fallible_t();
-    nsAutoArrayPtr<uint8_t> data(new (fallible) uint8_t[aLength]);
-    if (!data) {
-      return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
-    }
-    rv = aInStream->Read(reinterpret_cast<char*>(data.get()),
-                         aLength, &totalRead);
-    NS_ENSURE_SUCCESS(rv, rv);
-    NS_ASSERTION(totalRead <= aLength, "Read more bytes than were available?");
-    
-    nsCOMPtr<nsIRunnable> dataAvailable = new nsHtml5DataAvailable(this,
-                                                                   data.forget(),
-                                                                   totalRead);
-    if (NS_FAILED(mThread->Dispatch(dataAvailable, nsIThread::DISPATCH_NORMAL))) {
-      NS_WARNING("Dispatching DataAvailable event failed.");
-    }
-    return rv;
-  } else {
-    NS_ASSERTION(IsParserThread(), "Wrong thread!");
-    mozilla::MutexAutoLock autoLock(mTokenizerMutex);
-
-    // Read directly from response buffer.
-    rv = aInStream->ReadSegments(CopySegmentsToParser, this, aLength,
-                                 &totalRead);
-    if (NS_FAILED(rv)) {
-      NS_WARNING("Failed reading response data to parser");
-      return rv;
-    }
-    return NS_OK;
+  const mozilla::fallible_t fallible = mozilla::fallible_t();
+  nsAutoArrayPtr<uint8_t> data(new (fallible) uint8_t[aLength]);
+  if (!data) {
+    return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
   }
+  rv = aInStream->Read(reinterpret_cast<char*>(data.get()),
+  aLength, &totalRead);
+  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ASSERTION(totalRead <= aLength, "Read more bytes than were available?");
+  nsCOMPtr<nsIRunnable> dataAvailable = new nsHtml5DataAvailable(this,
+                                                                 data.forget(),
+                                                                totalRead);
+  if (NS_FAILED(mThread->Dispatch(dataAvailable, nsIThread::DISPATCH_NORMAL))) {
+    NS_WARNING("Dispatching DataAvailable event failed.");
+  }
+  return rv;
 }
 
-/* static */
-NS_METHOD
-nsHtml5StreamParser::CopySegmentsToParser(nsIInputStream *aInStream,
-                                          void *aClosure,
-                                          const char *aFromSegment,
-                                          uint32_t aToOffset,
-                                          uint32_t aCount,
-                                          uint32_t *aWriteCount)
-{
-  nsHtml5StreamParser* parser = static_cast<nsHtml5StreamParser*>(aClosure);
-
-  parser->DoDataAvailable((const uint8_t*)aFromSegment, aCount);
-  // Assume DoDataAvailable consumed all available bytes.
-  *aWriteCount = aCount;
-  return NS_OK;
-}
-
-
 bool
 nsHtml5StreamParser::PreferredForInternalEncodingDecl(nsACString& aEncoding)
 {
   nsAutoCString newEncoding;
   if (!EncodingUtils::FindEncodingForLabel(aEncoding, newEncoding)) {
     // the encoding name is bogus
     mTreeBuilder->MaybeComplainAboutCharset("EncMetaUnsupported",
                                             true,
--- a/parser/html/nsHtml5StreamParser.h
+++ b/parser/html/nsHtml5StreamParser.h
@@ -15,17 +15,16 @@
 #include "nsHtml5TreeOpExecutor.h"
 #include "nsHtml5OwningUTF16Buffer.h"
 #include "nsIInputStream.h"
 #include "mozilla/Mutex.h"
 #include "nsHtml5AtomTable.h"
 #include "nsHtml5Speculation.h"
 #include "nsITimer.h"
 #include "nsICharsetDetector.h"
-#include "nsIThreadRetargetableStreamListener.h"
 
 class nsHtml5Parser;
 
 #define NS_HTML5_STREAM_PARSER_READ_BUFFER_SIZE 1024
 #define NS_HTML5_STREAM_PARSER_SNIFFING_BUFFER_SIZE 1024
 
 enum eParserMode {
   /**
@@ -97,17 +96,16 @@ enum eBomState {
 
 enum eHtml5StreamState {
   STREAM_NOT_STARTED = 0,
   STREAM_BEING_READ = 1,
   STREAM_ENDED = 2
 };
 
 class nsHtml5StreamParser : public nsIStreamListener,
-                            public nsIThreadRetargetableStreamListener,
                             public nsICharsetDetectionObserver {
 
   friend class nsHtml5RequestStopper;
   friend class nsHtml5DataAvailable;
   friend class nsHtml5StreamParserContinuation;
   friend class nsHtml5TimerKungFu;
 
   public:
@@ -122,18 +120,16 @@ class nsHtml5StreamParser : public nsISt
                         eParserMode aMode);
                         
     virtual ~nsHtml5StreamParser();
 
     // nsIRequestObserver methods:
     NS_DECL_NSIREQUESTOBSERVER
     // nsIStreamListener methods:
     NS_DECL_NSISTREAMLISTENER
-    // nsIThreadRetargetableStreamListener methods:
-    NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
     
     // nsICharsetDetectionObserver
     /**
      * Chardet calls this to report the detection result
      */
     NS_IMETHOD Notify(const char* aCharset, nsDetectionConfident aConf);
 
     // EncodingDeclarationHandler
@@ -238,24 +234,17 @@ class nsHtml5StreamParser : public nsISt
      * timer.
      */
     void FlushTreeOpsAndDisarmTimer();
 
     void ParseAvailableData();
     
     void DoStopRequest();
     
-    void DoDataAvailable(const uint8_t* aBuffer, uint32_t aLength);
-
-    static NS_METHOD CopySegmentsToParser(nsIInputStream *aInStream,
-                                          void *aClosure,
-                                          const char *aFromSegment,
-                                          uint32_t aToOffset,
-                                          uint32_t aCount,
-                                          uint32_t *aWriteCount);
+    void DoDataAvailable(uint8_t* aBuffer, uint32_t aLength);
 
     bool IsTerminatedOrInterrupted() {
       mozilla::MutexAutoLock autoLock(mTerminatedMutex);
       return mTerminated || mInterrupted;
     }
 
     bool IsTerminated() {
       mozilla::MutexAutoLock autoLock(mTerminatedMutex);
--- a/parser/html/nsHtml5TreeOpExecutor.h
+++ b/parser/html/nsHtml5TreeOpExecutor.h
@@ -223,16 +223,17 @@ class nsHtml5TreeOpExecutor : public nsC
      */
     nsresult MarkAsBroken(nsresult aReason);
 
     /**
      * Checks if this parser is broken. Returns a non-NS_OK (i.e. non-0)
      * value if broken.
      */
     inline nsresult IsBroken() {
+      NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
       return mBroken;
     }
 
     inline void BeginDocUpdate() {
       NS_PRECONDITION(mFlushState == eInFlush, "Tried to double-open update.");
       NS_PRECONDITION(mParser, "Started update without parser.");
       mFlushState = eInDocUpdate;
       mDocument->BeginUpdate(UPDATE_CONTENT_MODEL);
--- a/uriloader/base/nsURILoader.cpp
+++ b/uriloader/base/nsURILoader.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sts=2 sw=2 et cin: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsURILoader.h"
 #include "nsAutoPtr.h"
-#include "nsProxyRelease.h"
 #include "nsIURIContentListener.h"
 #include "nsIContentHandler.h"
 #include "nsILoadGroup.h"
 #include "nsIDocumentLoader.h"
 #include "nsIWebProgress.h"
 #include "nsIWebProgressListener.h"
 #include "nsIIOService.h"
 #include "nsIServiceManager.h"
@@ -26,22 +25,20 @@
 #include "nsWeakReference.h"
 #include "nsIHttpChannel.h"
 #include "nsIMultiPartChannel.h"
 #include "netCore.h"
 #include "nsCRT.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
-#include "nsIThreadRetargetableStreamListener.h"
 
 #include "nsXPIDLString.h"
 #include "nsString.h"
 #include "nsNetUtil.h"
-#include "nsThreadUtils.h"
 #include "nsReadableUtils.h"
 #include "nsError.h"
 
 #include "nsICategoryManager.h"
 #include "nsCExternalHandlerService.h" // contains contractids for the helper app service
 
 #include "nsIMIMEHeaderParam.h"
 #include "nsNetCID.h"
@@ -61,17 +58,16 @@ PRLogModuleInfo* nsURILoader::mLog = nul
 
 /**
  * The nsDocumentOpenInfo contains the state required when a single
  * document is being opened in order to discover the content type...
  * Each instance remains alive until its target URL has been loaded
  * (or aborted).
  */
 class nsDocumentOpenInfo MOZ_FINAL : public nsIStreamListener
-                                   , public nsIThreadRetargetableStreamListener
 {
 public:
   // Needed for nsCOMPtr to work right... Don't call this!
   nsDocumentOpenInfo();
 
   // Real constructor
   // aFlags is a combination of the flags on nsIURILoader
   nsDocumentOpenInfo(nsIInterfaceRequestor* aWindowContext,
@@ -109,33 +105,31 @@ public:
                             nsIChannel* aChannel);
 
   // nsIRequestObserver methods:
   NS_DECL_NSIREQUESTOBSERVER
 
   // nsIStreamListener methods:
   NS_DECL_NSISTREAMLISTENER
 
-  // nsIThreadRetargetableStreamListener
-  NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
 protected:
   ~nsDocumentOpenInfo();
 
 protected:
   /**
    * The first content listener to try dispatching data to.  Typically
    * the listener associated with the entity that originated the load.
    */
   nsCOMPtr<nsIURIContentListener> m_contentListener;
 
   /**
    * The stream listener to forward nsIStreamListener notifications
    * to.  This is set once the load is dispatched.
    */
-  nsMainThreadPtrHandle<nsIStreamListener> m_targetStreamListener;
+  nsCOMPtr<nsIStreamListener> m_targetStreamListener;
 
   /**
    * A pointer to the entity that originated the load. We depend on getting
    * things like nsIURIContentListeners, nsIDOMWindows, etc off of it.
    */
   nsCOMPtr<nsIInterfaceRequestor> m_originalContext;
 
   /**
@@ -160,17 +154,16 @@ protected:
 
 NS_IMPL_THREADSAFE_ADDREF(nsDocumentOpenInfo)
 NS_IMPL_THREADSAFE_RELEASE(nsDocumentOpenInfo)
 
 NS_INTERFACE_MAP_BEGIN(nsDocumentOpenInfo)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIRequestObserver)
   NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
   NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
-  NS_INTERFACE_MAP_ENTRY(nsIThreadRetargetableStreamListener)
 NS_INTERFACE_MAP_END_THREADSAFE
 
 nsDocumentOpenInfo::nsDocumentOpenInfo()
 {
   NS_NOTREACHED("This should never be called\n");
 }
 
 nsDocumentOpenInfo::nsDocumentOpenInfo(nsIInterfaceRequestor* aWindowContext,
@@ -269,32 +262,16 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnStar
     rv = m_targetStreamListener->OnStartRequest(request, aCtxt);
 
   LOG(("  OnStartRequest returning: 0x%08X", rv));
   
   return rv;
 }
 
 NS_IMETHODIMP
-nsDocumentOpenInfo::CheckListenerChain()
-{
-  NS_ASSERTION(NS_IsMainThread(), "Should be on the main thread!");
-  nsresult rv = NS_OK;
-  nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
-    do_QueryInterface(m_targetStreamListener, &rv);
-  if (retargetableListener) {
-    rv = retargetableListener->CheckListenerChain();
-  }
-  LOG(("[0x%p] nsDocumentOpenInfo::CheckListenerChain %s listener %p rv %x",
-       this, (NS_SUCCEEDED(rv) ? "success" : "failure"),
-       (nsIStreamListener*)m_targetStreamListener, rv));
-  return rv;
-}
-
-NS_IMETHODIMP
 nsDocumentOpenInfo::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt,
                                     nsIInputStream * inStr,
                                     uint64_t sourceOffset, uint32_t count)
 {
   // if we have retarged to the end stream listener, then forward the call....
   // otherwise, don't do anything
 
   nsresult rv = NS_OK;
@@ -306,17 +283,17 @@ nsDocumentOpenInfo::OnDataAvailable(nsIR
 
 NS_IMETHODIMP nsDocumentOpenInfo::OnStopRequest(nsIRequest *request, nsISupports *aCtxt, 
                                                 nsresult aStatus)
 {
   LOG(("[0x%p] nsDocumentOpenInfo::OnStopRequest", this));
   
   if ( m_targetStreamListener)
   {
-    nsMainThreadPtrHandle<nsIStreamListener> listener = m_targetStreamListener;
+    nsCOMPtr<nsIStreamListener> listener(m_targetStreamListener);
 
     // If this is a multipart stream, we could get another
     // OnStartRequest after this... reset state.
     m_targetStreamListener = 0;
     mContentType.Truncate();
     listener->OnStopRequest(request, aCtxt, aStatus);
   }
 
@@ -532,25 +509,21 @@ nsresult nsDocumentOpenInfo::DispatchCon
     request->SetLoadFlags(loadFlags | nsIChannel::LOAD_RETARGETED_DOCUMENT_URI
                                     | nsIChannel::LOAD_TARGETED);
 
     if (isGuessFromExt) {
       mContentType = APPLICATION_GUESS_FROM_EXT;
       aChannel->SetContentType(NS_LITERAL_CSTRING(APPLICATION_GUESS_FROM_EXT));
     }
 
-    nsCOMPtr<nsIStreamListener> listener;
     rv = helperAppService->DoContent(mContentType,
                                      request,
                                      m_originalContext,
                                      false,
-                                     getter_AddRefs(listener));
-    // Passing false here to allow off main thread use.
-    m_targetStreamListener
-      = new nsMainThreadPtrHolder<nsIStreamListener>(listener, false);
+                                     getter_AddRefs(m_targetStreamListener));
     if (NS_FAILED(rv)) {
       request->SetLoadFlags(loadFlags);
       m_targetStreamListener = nullptr;
     }
   }
       
   NS_ASSERTION(m_targetStreamListener || NS_FAILED(rv),
                "There is no way we should be successful at this point without a m_targetStreamListener");
@@ -580,17 +553,17 @@ nsDocumentOpenInfo::ConvertData(nsIReque
   // When applying stream decoders, it is necessary to "insert" an 
   // intermediate nsDocumentOpenInfo instance to handle the targeting of
   // the "final" stream or streams.
   //
   // For certain content types (ie. multi-part/x-mixed-replace) the input
   // stream is split up into multiple destination streams.  This
   // intermediate instance is used to target these "decoded" streams...
   //
-  nsRefPtr<nsDocumentOpenInfo> nextLink =
+  nsCOMPtr<nsDocumentOpenInfo> nextLink =
     new nsDocumentOpenInfo(m_originalContext, mFlags, mURILoader);
   if (!nextLink) return NS_ERROR_OUT_OF_MEMORY;
 
   LOG(("  Downstream DocumentOpenInfo would be: 0x%p", nextLink.get()));
   
   // Make sure nextLink starts with the contentListener that said it wanted the
   // results of this decode.
   nextLink->m_contentListener = aListener;
@@ -603,26 +576,21 @@ nsDocumentOpenInfo::ConvertData(nsIReque
   // */*, that's OK -- that will just indicate to nextLink that it should get
   // the type off the channel.
   nextLink->mContentType = aOutContentType;
 
   // The following call sets m_targetStreamListener to the input end of the
   // stream converter and sets the output end of the stream converter to
   // nextLink.  As we pump data into m_targetStreamListener the stream
   // converter will convert it and pass the converted data to nextLink.
-  nsCOMPtr<nsIStreamListener> listener;
-  rv = StreamConvService->AsyncConvertData(PromiseFlatCString(aSrcContentType).get(),
-                                           PromiseFlatCString(aOutContentType).get(),
-                                           nextLink,
-                                           request,
-                                           getter_AddRefs(listener));
-  // Passing false here to allow off main thread use.
-  m_targetStreamListener
-    = new nsMainThreadPtrHolder<nsIStreamListener>(listener, false);
-  return rv;
+  return StreamConvService->AsyncConvertData(PromiseFlatCString(aSrcContentType).get(), 
+                                             PromiseFlatCString(aOutContentType).get(), 
+                                             nextLink, 
+                                             request,
+                                             getter_AddRefs(m_targetStreamListener));
 }
 
 bool
 nsDocumentOpenInfo::TryContentListener(nsIURIContentListener* aListener,
                                        nsIChannel* aChannel)
 {
   LOG(("[0x%p] nsDocumentOpenInfo::TryContentListener; mFlags = 0x%x",
        this, mFlags));
@@ -657,17 +625,17 @@ nsDocumentOpenInfo::TryContentListener(n
       m_targetStreamListener = nullptr;
     }
 
     LOG(("  Found conversion: %s", m_targetStreamListener ? "yes" : "no"));
     
     // m_targetStreamListener is now the input end of the converter, and we can
     // just pump the data in there, if it exists.  If it does not, we need to
     // try other nsIURIContentListeners.
-    return m_targetStreamListener.get() != nullptr;
+    return m_targetStreamListener != nullptr;
   }
 
   // At this point, aListener wants data of type mContentType.  Let 'em have
   // it.  But first, if we are retargeting, set an appropriate flag on the
   // channel
   nsLoadFlags loadFlags = 0;
   aChannel->GetLoadFlags(&loadFlags);
 
@@ -679,25 +647,22 @@ nsDocumentOpenInfo::TryContentListener(n
     do_GetInterface(m_originalContext);
   if (originalListener != aListener) {
     newLoadFlags |= nsIChannel::LOAD_RETARGETED_DOCUMENT_URI;
   }
   aChannel->SetLoadFlags(loadFlags | newLoadFlags);
   
   bool abort = false;
   bool isPreferred = (mFlags & nsIURILoader::IS_CONTENT_PREFERRED) != 0;
-  nsCOMPtr<nsIStreamListener> listener;
   nsresult rv = aListener->DoContent(mContentType.get(),
                                      isPreferred,
                                      aChannel,
-                                     getter_AddRefs(listener),
+                                     getter_AddRefs(m_targetStreamListener),
                                      &abort);
-  // Passing false here to allow off main thread use.
-  m_targetStreamListener
-    = new nsMainThreadPtrHolder<nsIStreamListener>(listener, false);
+    
   if (NS_FAILED(rv)) {
     LOG_ERROR(("  DoContent failed"));
     
     // Unset the RETARGETED_DOCUMENT_URI flag if we set it...
     aChannel->SetLoadFlags(loadFlags);
     m_targetStreamListener = nullptr;
     return false;
   }
@@ -842,17 +807,17 @@ nsresult nsURILoader::OpenChannel(nsICha
         LOG(("  OnStartURIOpen aborted load"));
         return NS_ERROR_WONT_HANDLE_CONTENT;
       }
     }
   }
 
   // we need to create a DocumentOpenInfo object which will go ahead and open
   // the url and discover the content type....
-  nsRefPtr<nsDocumentOpenInfo> loader =
+  nsCOMPtr<nsDocumentOpenInfo> loader =
     new nsDocumentOpenInfo(aWindowContext, aFlags, this);
 
   if (!loader) return NS_ERROR_OUT_OF_MEMORY;
 
   // Set the correct loadgroup on the channel
   nsCOMPtr<nsILoadGroup> loadGroup(do_GetInterface(aWindowContext));
 
   if (!loadGroup) {
--- a/xpcom/glue/nsProxyRelease.h
+++ b/xpcom/glue/nsProxyRelease.h
@@ -198,18 +198,16 @@ class nsMainThreadPtrHandle
       return mPtr.get()->get();
     }
     return nullptr;
   }
 
   operator T*() { return get(); }
   T* operator->() { return get(); }
 
-  operator bool() { return get(); }
-
   // These are safe to call on other threads with appropriate external locking.
   bool operator==(const nsMainThreadPtrHandle<T>& aOther) const {
     if (!mPtr || !aOther.mPtr)
       return mPtr == aOther.mPtr;
     return *mPtr == *aOther.mPtr;
   }
   bool operator!() { return !mPtr; }
 };