Backed out 4 changesets (bug 1754031, bug 1759563, bug 1759572, bug 1759569) because they are linked to the backed out bug 1754004 CLOSED TREE
authorNorisz Fay <nfay@mozilla.com>
Thu, 05 May 2022 13:58:04 +0300
changeset 616284 c3e64dcb32faf8b65b90fc3bdcba4972dcfe6f7e
parent 616283 21c54d550dd1347801acb3d20e4493e5ebac4940
child 616285 5227fccc55706b143e7bca90870e5df78598ab3b
push id162275
push usernfay@mozilla.com
push dateThu, 05 May 2022 10:59:19 +0000
treeherderautoland@c3e64dcb32fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1754031, 1759563, 1759572, 1759569, 1754004
milestone102.0a1
backs outa15de342dab9958bdb94fb3b85c247574f5f0408
e731c9fa7444a39f1875228c98de86d66f5072ba
d70810d7b63a12b670343084a301796fa2b7482b
14a5f40fc11dc7fdf627338e33353c2a2c819609
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 1754031, bug 1759563, bug 1759572, bug 1759569) because they are linked to the backed out bug 1754004 CLOSED TREE Backed out changeset a15de342dab9 (bug 1759572) Backed out changeset e731c9fa7444 (bug 1759563) Backed out changeset d70810d7b63a (bug 1759569) Backed out changeset 14a5f40fc11d (bug 1754031)
dom/file/ipc/RemoteLazyInputStream.cpp
dom/file/uri/BlobURLInputStream.cpp
dom/quota/DecryptingInputStream.cpp
dom/quota/DecryptingInputStream.h
ipc/glue/DataPipe.cpp
ipc/glue/InputStreamUtils.cpp
ipc/glue/InputStreamUtils.h
ipc/glue/nsIIPCSerializableInputStream.h
netwerk/base/PartiallySeekableInputStream.cpp
netwerk/base/nsBufferedStreams.cpp
netwerk/base/nsFileStreams.cpp
netwerk/base/nsMIMEInputStream.cpp
netwerk/base/nsStreamTransportService.cpp
xpcom/io/InputStreamLengthWrapper.cpp
xpcom/io/NonBlockingAsyncInputStream.cpp
xpcom/io/SeekableStreamWrapper.cpp
xpcom/io/SlicedInputStream.cpp
xpcom/io/nsMultiplexInputStream.cpp
xpcom/io/nsStorageStream.cpp
xpcom/io/nsStreamUtils.cpp
xpcom/io/nsStringStream.cpp
xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp
--- a/dom/file/ipc/RemoteLazyInputStream.cpp
+++ b/dom/file/ipc/RemoteLazyInputStream.cpp
@@ -417,31 +417,29 @@ RemoteLazyInputStream::AsyncWait(nsIInpu
         mInputStreamCallbackEventTarget = aEventTarget;
         mState = ePending;
 
         mActor->StreamNeeded(this, aEventTarget);
         return NS_OK;
 
       // We are still waiting for the remote inputStream
       case ePending: {
-        if (NS_WARN_IF(mInputStreamCallback && aCallback &&
-                       mInputStreamCallback != aCallback)) {
+        if (mInputStreamCallback && aCallback) {
           return NS_ERROR_FAILURE;
         }
 
         mInputStreamCallback = aCallback;
         mInputStreamCallbackEventTarget = aEventTarget;
         return NS_OK;
       }
 
       // We have the remote inputStream, let's check if we can execute the
       // callback.
       case eRunning: {
-        if (NS_WARN_IF(mInputStreamCallback && aCallback &&
-                       mInputStreamCallback != aCallback)) {
+        if (mInputStreamCallback && aCallback) {
           return NS_ERROR_FAILURE;
         }
 
         nsresult rv = EnsureAsyncRemoteStream(lock);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
 
@@ -451,18 +449,17 @@ RemoteLazyInputStream::AsyncWait(nsIInpu
         asyncRemoteStream = mAsyncRemoteStream;
         break;
       }
 
       case eClosed:
         [[fallthrough]];
       default:
         MOZ_ASSERT(mState == eClosed);
-        if (NS_WARN_IF(mInputStreamCallback && aCallback &&
-                       mInputStreamCallback != aCallback)) {
+        if (mInputStreamCallback && aCallback) {
           return NS_ERROR_FAILURE;
         }
         break;
     }
   }
 
   if (asyncRemoteStream) {
     return asyncRemoteStream->AsyncWait(aCallback ? this : nullptr, 0, 0,
@@ -593,23 +590,16 @@ RemoteLazyInputStream::OnInputStreamRead
   // be synchronous.
   MOZ_ASSERT(callback);
   InputStreamCallbackRunnable::Execute(callback, callbackEventTarget, this);
   return NS_OK;
 }
 
 // nsIIPCSerializableInputStream
 
-void RemoteLazyInputStream::SerializedComplexity(uint32_t aMaxSize,
-                                                 uint32_t* aSizeUsed,
-                                                 uint32_t* aNewPipes,
-                                                 uint32_t* aTransferables) {
-  *aTransferables = 1;
-}
-
 void RemoteLazyInputStream::Serialize(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
     mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   MOZ_ASSERT(aSizeUsed);
   *aSizeUsed = 0;
 
--- a/dom/file/uri/BlobURLInputStream.cpp
+++ b/dom/file/uri/BlobURLInputStream.cpp
@@ -135,18 +135,17 @@ NS_IMETHODIMP BlobURLInputStream::AsyncW
   MutexAutoLock lock(mStateMachineMutex);
 
   if (mState == State::ERROR) {
     MOZ_ASSERT(NS_FAILED(mError));
     return NS_ERROR_FAILURE;
   }
 
   // Pre-empting a valid callback with another is not allowed.
-  if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
-                 mAsyncWaitCallback != aCallback)) {
+  if (NS_WARN_IF(mAsyncWaitCallback && aCallback)) {
     return NS_ERROR_FAILURE;
   }
 
   mAsyncWaitTarget = aEventTarget;
   mAsyncWaitRequestedCount = aRequestedCount;
   mAsyncWaitFlags = aFlags;
   mAsyncWaitCallback = aCallback;
 
--- a/dom/quota/DecryptingInputStream.cpp
+++ b/dom/quota/DecryptingInputStream.cpp
@@ -73,24 +73,16 @@ NS_IMETHODIMP DecryptingInputStreamBase:
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP DecryptingInputStreamBase::GetCloneable(bool* aCloneable) {
   *aCloneable = true;
   return NS_OK;
 }
 
-void DecryptingInputStreamBase::SerializedComplexity(uint32_t aMaxSize,
-                                                     uint32_t* aSizeUsed,
-                                                     uint32_t* aPipes,
-                                                     uint32_t* aTransferables) {
-  (*mBaseIPCSerializableInputStream)
-      ->SerializedComplexity(aMaxSize, aSizeUsed, aPipes, aTransferables);
-}
-
 void DecryptingInputStreamBase::Serialize(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
     mozilla::ipc::ChildToParentStreamActorManager* aManager) {
   MOZ_CRASH("Not implemented");
 }
 
--- a/dom/quota/DecryptingInputStream.h
+++ b/dom/quota/DecryptingInputStream.h
@@ -48,20 +48,16 @@ class DecryptingInputStreamBase : public
   NS_IMETHOD Read(char* aBuf, uint32_t aCount, uint32_t* _retval) final;
   NS_IMETHOD IsNonBlocking(bool* _retval) final;
 
   NS_IMETHOD SetEOF() final;
 
   using nsICloneableInputStream::GetCloneable;
   NS_IMETHOD GetCloneable(bool* aCloneable) final;
 
-  void SerializedComplexity(uint32_t aMaxSize, uint32_t* aSizeUsed,
-                            uint32_t* aPipes,
-                            uint32_t* aTransferables) override;
-
   using nsIIPCSerializableInputStream::Serialize;
   void Serialize(mozilla::ipc::InputStreamParams& aParams,
                  FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
                  uint32_t aMaxSize, uint32_t* aSizeUsed,
                  mozilla::ipc::ChildToParentStreamActorManager* aManager) final;
 
  protected:
   DecryptingInputStreamBase(MovingNotNull<nsCOMPtr<nsIInputStream>> aBaseStream,
--- a/ipc/glue/DataPipe.cpp
+++ b/ipc/glue/DataPipe.cpp
@@ -648,26 +648,16 @@ NS_IMETHODIMP DataPipeReceiver::AsyncWai
                           callback->OnInputStreamReady(self);
                         }),
                     do_AddRef(aTarget), aFlags & WAIT_CLOSURE_ONLY);
   return NS_OK;
 }
 
 // nsIIPCSerializableInputStream
 
-void DataPipeReceiver::SerializedComplexity(uint32_t aMaxSize,
-                                            uint32_t* aSizeUsed,
-                                            uint32_t* aPipes,
-                                            uint32_t* aTransferables) {
-  // We report DataPipeReceiver as taking one transferrable to serialize, rather
-  // than one pipe, as we aren't starting a new pipe for this purpose, and are
-  // instead transferring an existing pipe.
-  *aTransferables = 1;
-}
-
 void DataPipeReceiver::Serialize(InputStreamParams& aParams,
                                  FileDescriptorArray& aFileDescriptors,
                                  bool aDelayedStart, uint32_t aMaxSize,
                                  uint32_t* aSizeUsed,
                                  ParentToChildStreamActorManager* aManager) {
   *aSizeUsed = 0;
   aParams = DataPipeReceiverStreamParams(this);
 }
--- a/ipc/glue/InputStreamUtils.cpp
+++ b/ipc/glue/InputStreamUtils.cpp
@@ -119,33 +119,16 @@ void SerializeInputStreamAsPipeInternal(
     return;
   }
 
   aParams = IPCRemoteStreamParams(aDelayedStart, streamSource, length);
 }
 
 }  // namespace
 
-void InputStreamHelper::SerializedComplexity(nsIInputStream* aInputStream,
-                                             uint32_t aMaxSize,
-                                             uint32_t* aSizeUsed,
-                                             uint32_t* aPipes,
-                                             uint32_t* aTransferables) {
-  MOZ_ASSERT(aInputStream);
-
-  nsCOMPtr<nsIIPCSerializableInputStream> serializable =
-      do_QueryInterface(aInputStream);
-  if (!serializable) {
-    MOZ_CRASH("Input stream is not serializable!");
-  }
-
-  serializable->SerializedComplexity(aMaxSize, aSizeUsed, aPipes,
-                                     aTransferables);
-}
-
 void InputStreamHelper::SerializeInputStream(
     nsIInputStream* aInputStream, InputStreamParams& aParams,
     nsTArray<FileDescriptor>& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
     ParentToChildStreamActorManager* aManager) {
   SerializeInputStreamInternal(aInputStream, aParams, aFileDescriptors,
                                aDelayedStart, aMaxSize, aSizeUsed, aManager);
 }
--- a/ipc/glue/InputStreamUtils.h
+++ b/ipc/glue/InputStreamUtils.h
@@ -37,20 +37,16 @@ class ChildToParentStreamActorManager {
       PChildToParentStreamChild* aActor) = 0;
   virtual PFileDescriptorSetChild* SendPFileDescriptorSetConstructor(
       const FileDescriptor& aFD) = 0;
 };
 
 // If you want to serialize an inputStream, please use AutoIPCStream.
 class InputStreamHelper {
  public:
-  static void SerializedComplexity(nsIInputStream* aInputStream,
-                                   uint32_t aMaxSize, uint32_t* aSizeUsed,
-                                   uint32_t* aPipes, uint32_t* aTransferables);
-
   // These 2 methods allow to serialize an inputStream into InputStreamParams.
   // The manager is needed in case a stream needs to serialize itself as
   // IPCRemoteStream.
   // The stream serializes itself fully only if the resulting IPC message will
   // be smaller than |aMaxSize|. Otherwise, the stream serializes itself as
   // IPCRemoteStream, and, its content will be sent to the other side of the IPC
   // pipe in chunks. This sending can start immediatelly or at the first read
   // based on the value of |aDelayedStart|. The IPC message size is returned
--- a/ipc/glue/nsIIPCSerializableInputStream.h
+++ b/ipc/glue/nsIIPCSerializableInputStream.h
@@ -32,49 +32,16 @@ class ParentToChildStreamActorManager;
   }
 
 class NS_NO_VTABLE nsIIPCSerializableInputStream : public nsISupports {
  public:
   typedef nsTArray<mozilla::ipc::FileDescriptor> FileDescriptorArray;
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IIPCSERIALIZABLEINPUTSTREAM_IID)
 
-  // Determine the serialized complexity of this input stream, initializing
-  // `*aSizeUsed`, `*aPipes` and `*aTransferables` to the number of inline
-  // bytes/pipes/transferable resources which would be used. This will be used
-  // by other `Serialize` implementations to potentially simplify the resulting
-  // stream, reducing the number of pipes or file descriptors required.
-  //
-  // Each outparameter corresponds to a type of resource which will be included
-  // in the serialized message, as follows:
-  //
-  // *aSizeUsed:
-  //    Raw bytes to be included inline in the message's payload, usually in the
-  //    form of a nsCString for a StringInputStreamParams. This must be less
-  //    than or equal to `aMaxSize`. Larger payloads should instead be
-  //    serialized using SerializeInputStreamAsPipe.
-  // *aPipes:
-  //    New pipes, created using SerializeInputStreamAsPipe, which will be used
-  //    to asynchronously transfer part of the pipe over IPC. Callers such as
-  //    nsMultiplexInputStream may choose to serialize themselves as a DataPipe
-  //    if they contain DataPipes themselves, so existing DataPipe instances
-  //    which are cheaply transferred should be counted as transferrables.
-  // *aTransferables:
-  //    Existing objects which can be more cheaply transferred over IPC than by
-  //    serializing them inline in a payload or transferring them through a new
-  //    DataPipe. This includes RemoteLazyInputStreams, FileDescriptors, and
-  //    existing DataPipeReceiver instances.
-  //
-  // Callers of this method must have initialized all of `*aSizeUsed`,
-  // `*aPipes`, and `*aTransferables` to 0, so implementations are not required
-  // to initialize all outparameters. The outparameters must not be null.
-  virtual void SerializedComplexity(uint32_t aMaxSize, uint32_t* aSizeUsed,
-                                    uint32_t* aPipes,
-                                    uint32_t* aTransferables) = 0;
-
   virtual void Serialize(
       mozilla::ipc::InputStreamParams& aParams,
       FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
       uint32_t aMaxSize, uint32_t* aSizeUsed,
       mozilla::ipc::ParentToChildStreamActorManager* aManager) = 0;
 
   virtual void Serialize(
       mozilla::ipc::InputStreamParams& aParams,
@@ -85,54 +52,74 @@ class NS_NO_VTABLE nsIIPCSerializableInp
   virtual bool Deserialize(const mozilla::ipc::InputStreamParams& aParams,
                            const FileDescriptorArray& aFileDescriptors) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIIPCSerializableInputStream,
                               NS_IIPCSERIALIZABLEINPUTSTREAM_IID)
 
 #define NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM                                 \
-  virtual void SerializedComplexity(uint32_t aMaxSize, uint32_t* aSizeUsed,   \
-                                    uint32_t* aPipes,                         \
-                                    uint32_t* aTransferrables) override;      \
   virtual void Serialize(                                                     \
       mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool, uint32_t, \
       uint32_t*, mozilla::ipc::ParentToChildStreamActorManager*) override;    \
                                                                               \
   virtual void Serialize(                                                     \
       mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool, uint32_t, \
       uint32_t*, mozilla::ipc::ChildToParentStreamActorManager*) override;    \
                                                                               \
   virtual bool Deserialize(const mozilla::ipc::InputStreamParams&,            \
                            const FileDescriptorArray&) override;
 
-#define NS_FORWARD_NSIIPCSERIALIZABLEINPUTSTREAM(_to)                       \
-  virtual void SerializedComplexity(uint32_t aMaxSize, uint32_t* aSizeUsed, \
-                                    uint32_t* aPipes,                       \
-                                    uint32_t* aTransferables) override {    \
-    _to SerializedComplexity(aMaxSize, aSizeUsed, aPipes, aTransferables);  \
-  };                                                                        \
-                                                                            \
-  virtual void Serialize(                                                   \
-      mozilla::ipc::InputStreamParams& aParams,                             \
-      FileDescriptorArray& aFileDescriptors, bool aDelayedStart,            \
-      uint32_t aMaxSize, uint32_t* aSizeUsed,                               \
-      mozilla::ipc::ParentToChildStreamActorManager* aManager) override {   \
-    _to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,       \
-                  aSizeUsed, aManager);                                     \
-  }                                                                         \
-                                                                            \
-  virtual void Serialize(                                                   \
-      mozilla::ipc::InputStreamParams& aParams,                             \
-      FileDescriptorArray& aFileDescriptors, bool aDelayedStart,            \
-      uint32_t aMaxSize, uint32_t* aSizeUsed,                               \
-      mozilla::ipc::ChildToParentStreamActorManager* aManager) override {   \
-    _to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,       \
-                  aSizeUsed, aManager);                                     \
-  }                                                                         \
-                                                                            \
-  virtual bool Deserialize(const mozilla::ipc::InputStreamParams& aParams,  \
-                           const FileDescriptorArray& aFileDescriptors)     \
-      override {                                                            \
-    return _to Deserialize(aParams, aFileDescriptors);                      \
+#define NS_FORWARD_NSIIPCSERIALIZABLEINPUTSTREAM(_to)                      \
+  virtual void Serialize(                                                  \
+      mozilla::ipc::InputStreamParams& aParams,                            \
+      FileDescriptorArray& aFileDescriptors, bool aDelayedStart,           \
+      uint32_t aMaxSize, uint32_t* aSizeUsed,                              \
+      mozilla::ipc::ParentToChildStreamActorManager* aManager) override {  \
+    _to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,      \
+                  aSizeUsed, aManager);                                    \
+  }                                                                        \
+                                                                           \
+  virtual void Serialize(                                                  \
+      mozilla::ipc::InputStreamParams& aParams,                            \
+      FileDescriptorArray& aFileDescriptors, bool aDelayedStart,           \
+      uint32_t aMaxSize, uint32_t* aSizeUsed,                              \
+      mozilla::ipc::ChildToParentStreamActorManager* aManager) override {  \
+    _to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,      \
+                  aSizeUsed, aManager);                                    \
+  }                                                                        \
+                                                                           \
+  virtual bool Deserialize(const mozilla::ipc::InputStreamParams& aParams, \
+                           const FileDescriptorArray& aFileDescriptors)    \
+      override {                                                           \
+    return _to Deserialize(aParams, aFileDescriptors);                     \
+  }
+
+#define NS_FORWARD_SAFE_NSIIPCSERIALIZABLEINPUTSTREAM(_to)                 \
+  virtual void Serialize(                                                  \
+      mozilla::ipc::InputStreamParams& aParams,                            \
+      FileDescriptorArray& aFileDescriptors, bool aDelayedStart,           \
+      uint32_t aMaxSize, uint32_t* aSizeUsed,                              \
+      mozilla::ipc::ParentToChildStreamActorManager* aManager) override {  \
+    if (_to) {                                                             \
+      _to->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,   \
+                     aSizeUsed, aManager);                                 \
+    }                                                                      \
+  }                                                                        \
+                                                                           \
+  virtual void Serialize(                                                  \
+      mozilla::ipc::InputStreamParams& aParams,                            \
+      FileDescriptorArray& aFileDescriptors, bool aDelayedStart,           \
+      uint32_t aMaxSize, uint32_t* aSizeUsed,                              \
+      mozilla::ipc::ChildToParentStreamActorManager* aManager) override {  \
+    if (_to) {                                                             \
+      _to->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,   \
+                     aSizeUsed, aManager);                                 \
+    }                                                                      \
+  }                                                                        \
+                                                                           \
+  virtual bool Deserialize(const mozilla::ipc::InputStreamParams& aParams, \
+                           const FileDescriptorArray& aFileDescriptors)    \
+      override {                                                           \
+    return _to ? _to->Deserialize(aParams, aFileDescriptors) : false;      \
   }
 
 #endif  // mozilla_ipc_nsIIPCSerializableInputStream_h
--- a/netwerk/base/PartiallySeekableInputStream.cpp
+++ b/netwerk/base/PartiallySeekableInputStream.cpp
@@ -246,18 +246,17 @@ PartiallySeekableInputStream::AsyncWait(
       }
     }
 
     return NS_OK;
   }
 
   {
     MutexAutoLock lock(mMutex);
-    if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
-                   mAsyncWaitCallback != aCallback)) {
+    if (mAsyncWaitCallback && aCallback) {
       return NS_ERROR_FAILURE;
     }
 
     mAsyncWaitCallback = aCallback;
   }
 
   NS_ENSURE_STATE(mWeakAsyncInputStream);
   nsCOMPtr<nsIInputStreamCallback> callback = aCallback ? this : nullptr;
@@ -286,23 +285,16 @@ PartiallySeekableInputStream::OnInputStr
   }
 
   MOZ_ASSERT(callback);
   return callback->OnInputStreamReady(this);
 }
 
 // nsIIPCSerializableInputStream
 
-void PartiallySeekableInputStream::SerializedComplexity(
-    uint32_t aMaxSize, uint32_t* aSizeUsed, uint32_t* aPipes,
-    uint32_t* aTransferables) {
-  mozilla::ipc::InputStreamHelper::SerializedComplexity(
-      mInputStream, aMaxSize, aSizeUsed, aPipes, aTransferables);
-}
-
 void PartiallySeekableInputStream::Serialize(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
     mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
--- a/netwerk/base/nsBufferedStreams.cpp
+++ b/netwerk/base/nsBufferedStreams.cpp
@@ -572,29 +572,16 @@ nsBufferedInputStream::GetUnbufferedStre
   mBufferStartOffset += mCursor;
   mFillPoint = mCursor = 0;
 
   nsCOMPtr<nsISupports> stream = mStream;
   stream.forget(aStream);
   return NS_OK;
 }
 
-void nsBufferedInputStream::SerializedComplexity(uint32_t aMaxSize,
-                                                 uint32_t* aSizeUsed,
-                                                 uint32_t* aPipes,
-                                                 uint32_t* aTransferables) {
-  if (mStream) {
-    nsCOMPtr<nsIInputStream> stream = do_QueryInterface(mStream);
-    MOZ_ASSERT(stream);
-
-    InputStreamHelper::SerializedComplexity(stream, aMaxSize, aSizeUsed, aPipes,
-                                            aTransferables);
-  }
-}
-
 void nsBufferedInputStream::Serialize(
     InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
     bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
     mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
@@ -684,18 +671,17 @@ nsBufferedInputStream::AsyncWait(nsIInpu
     aCallback->OnInputStreamReady(this);
     return NS_OK;
   }
 
   nsCOMPtr<nsIInputStreamCallback> callback = aCallback ? this : nullptr;
   {
     MutexAutoLock lock(mMutex);
 
-    if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
-                   mAsyncWaitCallback != aCallback)) {
+    if (mAsyncWaitCallback && aCallback) {
       return NS_ERROR_FAILURE;
     }
 
     mAsyncWaitCallback = aCallback;
   }
 
   return stream->AsyncWait(callback, aFlags, aRequestedCount, aEventTarget);
 }
--- a/netwerk/base/nsFileStreams.cpp
+++ b/netwerk/base/nsFileStreams.cpp
@@ -535,23 +535,16 @@ nsFileInputStream::Tell(int64_t* aResult
   return nsFileStreamBase::Tell(aResult);
 }
 
 NS_IMETHODIMP
 nsFileInputStream::Available(uint64_t* aResult) {
   return nsFileStreamBase::Available(aResult);
 }
 
-void nsFileInputStream::SerializedComplexity(uint32_t aMaxSize,
-                                             uint32_t* aSizeUsed,
-                                             uint32_t* aPipes,
-                                             uint32_t* aTransferables) {
-  *aTransferables = 1;
-}
-
 void nsFileInputStream::Serialize(InputStreamParams& aParams,
                                   FileDescriptorArray& aFileDescriptors,
                                   bool aDelayedStart, uint32_t aMaxSize,
                                   uint32_t* aSizeUsed,
                                   ParentToChildStreamActorManager* aManager) {
   MOZ_ASSERT(aSizeUsed);
   *aSizeUsed = 0;
 
--- a/netwerk/base/nsMIMEInputStream.cpp
+++ b/netwerk/base/nsMIMEInputStream.cpp
@@ -265,18 +265,17 @@ nsMIMEInputStream::AsyncWait(nsIInputStr
   nsCOMPtr<nsIAsyncInputStream> asyncStream = do_QueryInterface(mStream);
   if (NS_WARN_IF(!asyncStream)) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIInputStreamCallback> callback = aCallback ? this : nullptr;
   {
     MutexAutoLock lock(mMutex);
-    if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
-                   mAsyncWaitCallback != aCallback)) {
+    if (mAsyncWaitCallback && aCallback) {
       return NS_ERROR_FAILURE;
     }
 
     mAsyncWaitCallback = aCallback;
   }
 
   return asyncStream->AsyncWait(callback, aFlags, aRequestedCount,
                                 aEventTarget);
@@ -328,29 +327,16 @@ nsresult nsMIMEInputStreamConstructor(ns
   if (outer) return NS_ERROR_NO_AGGREGATION;
 
   RefPtr<nsMIMEInputStream> inst = new nsMIMEInputStream();
   if (!inst) return NS_ERROR_OUT_OF_MEMORY;
 
   return inst->QueryInterface(iid, result);
 }
 
-void nsMIMEInputStream::SerializedComplexity(uint32_t aMaxSize,
-                                             uint32_t* aSizeUsed,
-                                             uint32_t* aPipes,
-                                             uint32_t* aTransferables) {
-  if (nsCOMPtr<nsIIPCSerializableInputStream> serializable =
-          do_QueryInterface(mStream)) {
-    InputStreamHelper::SerializedComplexity(mStream, aMaxSize, aSizeUsed,
-                                            aPipes, aTransferables);
-  } else {
-    *aPipes = 1;
-  }
-}
-
 void nsMIMEInputStream::Serialize(
     InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
     bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
     mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
--- a/netwerk/base/nsStreamTransportService.cpp
+++ b/netwerk/base/nsStreamTransportService.cpp
@@ -202,18 +202,17 @@ nsInputStreamTransport::AsyncWait(nsIInp
                                   nsIEventTarget* aEventTarget) {
   NS_ENSURE_STATE(!!mAsyncSource);
 
   nsCOMPtr<nsIInputStreamCallback> callback = aCallback ? this : nullptr;
 
   {
     MutexAutoLock lock(mMutex);
 
-    if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
-                   mAsyncWaitCallback != aCallback)) {
+    if (mAsyncWaitCallback && aCallback) {
       return NS_ERROR_FAILURE;
     }
 
     mAsyncWaitCallback = aCallback;
   }
 
   return mAsyncSource->AsyncWait(callback, aFlags, aRequestedCount,
                                  aEventTarget);
--- a/xpcom/io/InputStreamLengthWrapper.cpp
+++ b/xpcom/io/InputStreamLengthWrapper.cpp
@@ -200,26 +200,36 @@ InputStreamLengthWrapper::CloseWithStatu
 
 NS_IMETHODIMP
 InputStreamLengthWrapper::AsyncWait(nsIInputStreamCallback* aCallback,
                                     uint32_t aFlags, uint32_t aRequestedCount,
                                     nsIEventTarget* aEventTarget) {
   NS_ENSURE_STATE(mInputStream);
   NS_ENSURE_STATE(mWeakAsyncInputStream);
 
-  nsCOMPtr<nsIInputStreamCallback> callback = aCallback ? this : nullptr;
+  nsCOMPtr<nsIInputStreamCallback> callback = this;
   {
     MutexAutoLock lock(mMutex);
 
-    if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
-                   mAsyncWaitCallback != aCallback)) {
+    if (mAsyncWaitCallback && aCallback) {
       return NS_ERROR_FAILURE;
     }
 
+    bool hadCallback = !!mAsyncWaitCallback;
     mAsyncWaitCallback = aCallback;
+
+    if (!mAsyncWaitCallback) {
+      if (!hadCallback) {
+        // No pending operation.
+        return NS_OK;
+      }
+
+      // Abort current operation.
+      callback = nullptr;
+    }
   }
 
   return mWeakAsyncInputStream->AsyncWait(callback, aFlags, aRequestedCount,
                                           aEventTarget);
 }
 
 // nsIInputStreamCallback
 
@@ -241,24 +251,16 @@ InputStreamLengthWrapper::OnInputStreamR
   }
 
   MOZ_ASSERT(callback);
   return callback->OnInputStreamReady(this);
 }
 
 // nsIIPCSerializableInputStream
 
-void InputStreamLengthWrapper::SerializedComplexity(uint32_t aMaxSize,
-                                                    uint32_t* aSizeUsed,
-                                                    uint32_t* aPipes,
-                                                    uint32_t* aTransferables) {
-  InputStreamHelper::SerializedComplexity(mInputStream, aMaxSize, aSizeUsed,
-                                          aPipes, aTransferables);
-}
-
 void InputStreamLengthWrapper::Serialize(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
     mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
--- a/xpcom/io/NonBlockingAsyncInputStream.cpp
+++ b/xpcom/io/NonBlockingAsyncInputStream.cpp
@@ -317,23 +317,16 @@ NonBlockingAsyncInputStream::AsyncWait(n
     return aEventTarget->Dispatch(runnable.forget());
   }
 
   return runnable->Run();
 }
 
 // nsIIPCSerializableInputStream
 
-void NonBlockingAsyncInputStream::SerializedComplexity(
-    uint32_t aMaxSize, uint32_t* aSizeUsed, uint32_t* aPipes,
-    uint32_t* aTransferables) {
-  InputStreamHelper::SerializedComplexity(mInputStream, aMaxSize, aSizeUsed,
-                                          aPipes, aTransferables);
-}
-
 void NonBlockingAsyncInputStream::Serialize(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
     mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
--- a/xpcom/io/SeekableStreamWrapper.cpp
+++ b/xpcom/io/SeekableStreamWrapper.cpp
@@ -382,26 +382,16 @@ SeekableStreamWrapper::AsyncLengthWait(n
   if (aCallback) {
     callback = new AsyncLengthCallback(aCallback, this);
   }
   return stream->AsyncLengthWait(callback, aEventTarget);
 }
 
 // nsIIPCSerializableInputStream
 
-void SeekableStreamWrapper::SerializedComplexity(uint32_t aMaxSize,
-                                                 uint32_t* aSizeUsed,
-                                                 uint32_t* aPipes,
-                                                 uint32_t* aTransferables) {
-  MOZ_ASSERT(IsIPCSerializableInputStream());
-  nsCOMPtr<nsIInputStream> original = do_QueryInterface(mOriginal);
-  mozilla::ipc::InputStreamHelper::SerializedComplexity(
-      original, aMaxSize, aSizeUsed, aPipes, aTransferables);
-}
-
 void SeekableStreamWrapper::Serialize(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
     mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
--- a/xpcom/io/SlicedInputStream.cpp
+++ b/xpcom/io/SlicedInputStream.cpp
@@ -302,18 +302,17 @@ SlicedInputStream::AsyncWait(nsIInputStr
   nsCOMPtr<nsIInputStreamCallback> callback = aCallback ? this : nullptr;
 
   uint32_t flags = aFlags;
   uint32_t requestedCount = aRequestedCount;
 
   {
     MutexAutoLock lock(mMutex);
 
-    if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
-                   mAsyncWaitCallback != aCallback)) {
+    if (mAsyncWaitCallback && aCallback) {
       return NS_ERROR_FAILURE;
     }
 
     mAsyncWaitCallback = aCallback;
 
     // If we haven't started retrieving data, let's see if we can seek.
     // If we cannot seek, we will do consecutive reads.
     if (mCurPos < mStart && mWeakSeekableInputStream) {
@@ -418,34 +417,16 @@ SlicedInputStream::OnInputStreamReady(ns
   }
 
   return mWeakAsyncInputStream->AsyncWait(
       this, asyncWaitFlags, asyncWaitRequestedCount, asyncWaitEventTarget);
 }
 
 // nsIIPCSerializableInputStream
 
-void SlicedInputStream::SerializedComplexity(uint32_t aMaxSize,
-                                             uint32_t* aSizeUsed,
-                                             uint32_t* aPipes,
-                                             uint32_t* aTransferables) {
-  InputStreamHelper::SerializedComplexity(mInputStream, aMaxSize, aSizeUsed,
-                                          aPipes, aTransferables);
-
-  // If we're going to be serializing a pipe to transfer the sliced data, and we
-  // are getting no efficiency improvements from transferables, stream this
-  // sliced input stream directly as a pipe to avoid streaming data which will
-  // be sliced off anyway.
-  if (*aPipes > 0 && *aTransferables == 0) {
-    *aSizeUsed = 0;
-    *aPipes = 1;
-    *aTransferables = 0;
-  }
-}
-
 void SlicedInputStream::Serialize(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
     mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
@@ -462,24 +443,16 @@ void SlicedInputStream::Serialize(
 template <typename M>
 void SlicedInputStream::SerializeInternal(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed, M* aManager) {
   MOZ_ASSERT(mInputStream);
   MOZ_ASSERT(mWeakIPCSerializableInputStream);
 
-  uint32_t sizeUsed = 0, pipes = 0, transferables = 0;
-  SerializedComplexity(aMaxSize, &sizeUsed, &pipes, &transferables);
-  if (pipes > 0 && transferables == 0) {
-    InputStreamHelper::SerializeInputStreamAsPipe(mInputStream, aParams,
-                                                  aDelayedStart, aManager);
-    return;
-  }
-
   SlicedInputStreamParams params;
   InputStreamHelper::SerializeInputStream(mInputStream, params.stream(),
                                           aFileDescriptors, aDelayedStart,
                                           aMaxSize, aSizeUsed, aManager);
   params.start() = mStart;
   params.length() = mLength;
   params.curPos() = mCurPos;
   params.closed() = mClosed;
--- a/xpcom/io/nsMultiplexInputStream.cpp
+++ b/xpcom/io/nsMultiplexInputStream.cpp
@@ -30,16 +30,19 @@
 #include "nsIInputStreamLength.h"
 #include "nsNetUtil.h"
 #include "nsStreamUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::ipc;
 
 using mozilla::DeprecatedAbs;
+using mozilla::Maybe;
+using mozilla::Nothing;
+using mozilla::Some;
 
 class nsMultiplexInputStream final : public nsIMultiplexInputStream,
                                      public nsISeekableStream,
                                      public nsIIPCSerializableInputStream,
                                      public nsICloneableInputStream,
                                      public nsIAsyncInputStream,
                                      public nsIInputStreamCallback,
                                      public nsIInputStreamLength,
@@ -115,20 +118,16 @@ class nsMultiplexInputStream final : pub
   struct MOZ_STACK_CLASS ReadSegmentsState {
     nsCOMPtr<nsIInputStream> mThisStream;
     uint32_t mOffset;
     nsWriteSegmentFun mWriter;
     void* mClosure;
     bool mDone;
   };
 
-  void SerializedComplexityInternal(uint32_t aMaxSize, uint32_t* aSizeUsed,
-                                    uint32_t* aPipes, uint32_t* aTransferables,
-                                    bool* aSerializeAsPipe);
-
   template <typename M>
   void SerializeInternal(InputStreamParams& aParams,
                          FileDescriptorArray& aFileDescriptors,
                          bool aDelayedStart, uint32_t aMaxSize,
                          uint32_t* aSizeUsed, M* aManager);
 
   static nsresult ReadSegCb(nsIInputStream* aIn, void* aClosure,
                             const char* aFromRawSegment, uint32_t aToOffset,
@@ -816,18 +815,17 @@ nsMultiplexInputStream::AsyncWait(nsIInp
   {
     MutexAutoLock lock(mLock);
 
     // We must execute the callback also when the stream is closed.
     if (NS_FAILED(mStatus) && mStatus != NS_BASE_STREAM_CLOSED) {
       return mStatus;
     }
 
-    if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
-                   mAsyncWaitCallback != aCallback)) {
+    if (mAsyncWaitCallback && aCallback) {
       return NS_ERROR_FAILURE;
     }
 
     mAsyncWaitCallback = aCallback;
     mAsyncWaitFlags = aFlags;
     mAsyncWaitRequestedCount = aRequestedCount;
     mAsyncWaitEventTarget = aEventTarget;
 
@@ -952,92 +950,16 @@ nsresult nsMultiplexInputStreamConstruct
     return NS_ERROR_NO_AGGREGATION;
   }
 
   RefPtr<nsMultiplexInputStream> inst = new nsMultiplexInputStream();
 
   return inst->QueryInterface(aIID, aResult);
 }
 
-void nsMultiplexInputStream::SerializedComplexity(uint32_t aMaxSize,
-                                                  uint32_t* aSizeUsed,
-                                                  uint32_t* aPipes,
-                                                  uint32_t* aTransferables) {
-  MutexAutoLock lock(mLock);
-  bool serializeAsPipe = false;
-  SerializedComplexityInternal(aMaxSize, aSizeUsed, aPipes, aTransferables,
-                               &serializeAsPipe);
-}
-
-void nsMultiplexInputStream::SerializedComplexityInternal(
-    uint32_t aMaxSize, uint32_t* aSizeUsed, uint32_t* aPipes,
-    uint32_t* aTransferables, bool* aSerializeAsPipe) {
-  mLock.AssertCurrentThreadOwns();
-  CheckedUint32 totalSizeUsed = 0;
-  CheckedUint32 totalPipes = 0;
-  CheckedUint32 totalTransferables = 0;
-  CheckedUint32 maxSize = aMaxSize;
-
-  uint32_t streamCount = mStreams.Length();
-
-  for (uint32_t index = 0; index < streamCount; index++) {
-    uint32_t sizeUsed = 0;
-    uint32_t pipes = 0;
-    uint32_t transferables = 0;
-    InputStreamHelper::SerializedComplexity(mStreams[index].mOriginalStream,
-                                            maxSize.value(), &sizeUsed, &pipes,
-                                            &transferables);
-
-    MOZ_ASSERT(maxSize.value() >= sizeUsed);
-
-    maxSize -= sizeUsed;
-    MOZ_DIAGNOSTIC_ASSERT(maxSize.isValid());
-    totalSizeUsed += sizeUsed;
-    MOZ_DIAGNOSTIC_ASSERT(totalSizeUsed.isValid());
-    totalPipes += pipes;
-    MOZ_DIAGNOSTIC_ASSERT(totalPipes.isValid());
-    totalTransferables += transferables;
-    MOZ_DIAGNOSTIC_ASSERT(totalTransferables.isValid());
-  }
-
-  // If the combination of all streams when serialized independently is
-  // sufficiently complex, we may choose to serialize it as a pipe to limit the
-  // complexity of the payload.
-  if (totalTransferables.value() == 0) {
-    // If there are no transferables within our serialization, and it would
-    // contain at least one pipe, serialize the entire payload as a pipe for
-    // simplicity.
-    *aSerializeAsPipe = totalSizeUsed.value() > 0 && totalPipes.value() > 0;
-  } else {
-    // Otherwise, we may want to still serialize in segments to take advantage
-    // of the efficiency of serializing transferables. We'll only serialize as a
-    // pipe if the total attachment count exceeds kMaxAttachmentThreshold.
-    static constexpr uint32_t kMaxAttachmentThreshold = 8;
-    CheckedUint32 totalAttachments = totalPipes + totalTransferables;
-    *aSerializeAsPipe = !totalAttachments.isValid() ||
-                        totalAttachments.value() > kMaxAttachmentThreshold;
-  }
-
-  if (*aSerializeAsPipe) {
-    NS_WARNING(
-        nsPrintfCString("Choosing to serialize multiplex stream as a pipe "
-                        "(would be %u bytes, %u pipes, %u transferables)",
-                        totalSizeUsed.value(), totalPipes.value(),
-                        totalTransferables.value())
-            .get());
-    *aSizeUsed = 0;
-    *aPipes = 1;
-    *aTransferables = 0;
-  } else {
-    *aSizeUsed = totalSizeUsed.value();
-    *aPipes = totalPipes.value();
-    *aTransferables = totalTransferables.value();
-  }
-}
-
 void nsMultiplexInputStream::Serialize(
     InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
     bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
     mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
@@ -1050,29 +972,16 @@ void nsMultiplexInputStream::Serialize(
 }
 
 template <typename M>
 void nsMultiplexInputStream::SerializeInternal(
     InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
     bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed, M* aManager) {
   MutexAutoLock lock(mLock);
 
-  // Check if we should serialize this stream as a pipe to reduce complexity.
-  uint32_t dummySizeUsed = 0, dummyPipes = 0, dummyTransferables = 0;
-  bool serializeAsPipe = false;
-  SerializedComplexityInternal(aMaxSize, &dummySizeUsed, &dummyPipes,
-                               &dummyTransferables, &serializeAsPipe);
-  if (serializeAsPipe) {
-    *aSizeUsed = 0;
-    MutexAutoUnlock unlock(mLock);
-    InputStreamHelper::SerializeInputStreamAsPipe(this, aParams, aDelayedStart,
-                                                  aManager);
-    return;
-  }
-
   MultiplexInputStreamParams params;
 
   CheckedUint32 totalSizeUsed = 0;
   CheckedUint32 maxSize = aMaxSize;
 
   uint32_t streamCount = mStreams.Length();
   if (streamCount) {
     nsTArray<InputStreamParams>& streams = params.streams();
@@ -1271,19 +1180,21 @@ nsMultiplexInputStream::Length(int64_t* 
     }
   }
 
   *aLength = length.value();
   return retval;
 }
 
 class nsMultiplexInputStream::AsyncWaitLengthHelper final
-    : public nsIInputStreamLengthCallback {
+    : public nsIInputStreamLengthCallback
+
+{
  public:
-  NS_DECL_THREADSAFE_ISUPPORTS
+  NS_DECL_ISUPPORTS
 
   AsyncWaitLengthHelper()
       : mStreamNotified(false), mLength(0), mNegativeSize(false) {}
 
   bool AddStream(nsIAsyncInputStreamLength* aStream) {
     return mPendingStreams.AppendElement(aStream, fallible);
   }
 
--- a/xpcom/io/nsStorageStream.cpp
+++ b/xpcom/io/nsStorageStream.cpp
@@ -569,31 +569,16 @@ nsresult nsStorageInputStream::Seek(uint
   mSegmentNum = SegNum(aPosition);
   mReadCursor = SegOffset(aPosition);
   uint32_t available = length - aPosition;
   mSegmentEnd = mReadCursor + XPCOM_MIN(mSegmentSize - mReadCursor, available);
   mLogicalCursor = aPosition;
   return NS_OK;
 }
 
-void nsStorageInputStream::SerializedComplexity(uint32_t aMaxSize,
-                                                uint32_t* aSizeUsed,
-                                                uint32_t* aPipes,
-                                                uint32_t* aTransferables) {
-  uint64_t remaining = 0;
-  mozilla::DebugOnly<nsresult> rv = Available(&remaining);
-  MOZ_ASSERT(NS_SUCCEEDED(rv));
-
-  if (remaining >= aMaxSize) {
-    *aPipes = 1;
-  } else {
-    *aSizeUsed = remaining;
-  }
-}
-
 void nsStorageInputStream::Serialize(
     InputStreamParams& aParams, FileDescriptorArray&, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
     mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
 }
 
 void nsStorageInputStream::Serialize(
--- a/xpcom/io/nsStreamUtils.cpp
+++ b/xpcom/io/nsStreamUtils.cpp
@@ -1,18 +1,16 @@
 /* -*- 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 "mozilla/Mutex.h"
 #include "mozilla/Attributes.h"
-#include "mozilla/InputStreamLengthWrapper.h"
-#include "nsIInputStreamLength.h"
 #include "nsStreamUtils.h"
 #include "nsCOMPtr.h"
 #include "nsICloneableInputStream.h"
 #include "nsIEventTarget.h"
 #include "nsICancelableRunnable.h"
 #include "nsISafeOutputStream.h"
 #include "nsString.h"
 #include "nsIAsyncInputStream.h"
@@ -867,26 +865,16 @@ nsresult NS_CloneInputStream(nsIInputStr
 
   nsresult rv = NS_NewPipe(getter_AddRefs(reader), getter_AddRefs(writer), 0,
                            0,            // default segment size and max size
                            true, true);  // non-blocking
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  // Propagate length information provided by nsIInputStreamLength. We don't use
-  // InputStreamLengthHelper::GetSyncLength to avoid the risk of blocking when
-  // called off-main-thread.
-  int64_t length = -1;
-  if (nsCOMPtr<nsIInputStreamLength> streamLength = do_QueryInterface(aSource);
-      streamLength && NS_SUCCEEDED(streamLength->Length(&length)) &&
-      length != -1) {
-    reader = new mozilla::InputStreamLengthWrapper(reader.forget(), length);
-  }
-
   cloneable = do_QueryInterface(reader);
   MOZ_ASSERT(cloneable && cloneable->GetCloneable());
 
   rv = cloneable->Clone(getter_AddRefs(readerClone));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
--- a/xpcom/io/nsStringStream.cpp
+++ b/xpcom/io/nsStringStream.cpp
@@ -445,29 +445,16 @@ nsStringInputStream::Tell(int64_t* aOutW
   *aOutWhere = (int64_t)mOffset;
   return NS_OK;
 }
 
 /////////
 // nsIIPCSerializableInputStream implementation
 /////////
 
-void nsStringInputStream::SerializedComplexity(uint32_t aMaxSize,
-                                               uint32_t* aSizeUsed,
-                                               uint32_t* aPipes,
-                                               uint32_t* aTransferables) {
-  ReentrantMonitorAutoEnter lock(mMon);
-
-  if (Length() >= aMaxSize) {
-    *aPipes = 1;
-  } else {
-    *aSizeUsed = Length();
-  }
-}
-
 void nsStringInputStream::Serialize(
     InputStreamParams& aParams, FileDescriptorArray& /* aFDs */,
     bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
     mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
 }
 
 void nsStringInputStream::Serialize(
--- a/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp
+++ b/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp
@@ -277,18 +277,16 @@ class QIInputStream final : public nsIIn
 
   // nsICloneableInputStream
   NS_IMETHOD GetCloneable(bool*) override { return NS_ERROR_NOT_IMPLEMENTED; }
   NS_IMETHOD Clone(nsIInputStream**) override {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
   // nsIIPCSerializableInputStream
-  void SerializedComplexity(uint32_t, uint32_t*, uint32_t*,
-                            uint32_t*) override {}
   void Serialize(mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool,
                  uint32_t, uint32_t*,
                  mozilla::ipc::ParentToChildStreamActorManager*) override {}
   void Serialize(mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool,
                  uint32_t, uint32_t*,
                  mozilla::ipc::ChildToParentStreamActorManager*) override {}
   bool Deserialize(const mozilla::ipc::InputStreamParams&,
                    const FileDescriptorArray&) override {