Bug 1528493 - Part 2: Move OptionalIPCStream to use new maybe types, r=baku
authorNika Layzell <nika@thelayzells.com>
Fri, 22 Feb 2019 18:46:14 +0000
changeset 460639 0dacb4dc82e565e4ea8bfc206c0b1c1bf9de6e70
parent 460638 55d65fdac5ec324e821c68a79931f5743e019519
child 460640 77eb18940eb116616c0a8b5e252823879a4b3655
push id35596
push userrmaries@mozilla.com
push dateSat, 23 Feb 2019 04:13:22 +0000
treeherdermozilla-central@fdd04819e350 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1528493
milestone67.0a1
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
Bug 1528493 - Part 2: Move OptionalIPCStream to use new maybe types, r=baku Depends on D20067 Differential Revision: https://phabricator.services.mozilla.com/D20068
dom/cache/CacheTypes.ipdlh
dom/cache/ReadStream.cpp
dom/file/ipc/IPCBlobInputStreamChild.cpp
dom/file/ipc/IPCBlobInputStreamChild.h
dom/file/ipc/IPCBlobInputStreamParent.cpp
dom/file/ipc/PIPCBlobInputStream.ipdl
dom/network/UDPSocketChild.cpp
dom/webbrowserpersist/PWebBrowserPersistDocument.ipdl
dom/webbrowserpersist/WebBrowserPersistDocumentParent.cpp
dom/webbrowserpersist/WebBrowserPersistDocumentParent.h
ipc/glue/IPCStream.ipdlh
ipc/glue/IPCStreamUtils.cpp
ipc/glue/IPCStreamUtils.h
netwerk/ipc/NeckoChannelParams.ipdlh
netwerk/protocol/ftp/FTPChannelParent.cpp
netwerk/protocol/ftp/FTPChannelParent.h
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/HttpChannelChild.h
netwerk/protocol/http/HttpChannelParent.cpp
netwerk/protocol/http/HttpChannelParent.h
netwerk/protocol/http/PHttpChannel.ipdl
netwerk/protocol/res/ExtensionProtocolHandler.cpp
--- a/dom/cache/CacheTypes.ipdlh
+++ b/dom/cache/CacheTypes.ipdlh
@@ -33,17 +33,17 @@ struct CacheQueryParams
   bool cacheNameSet;
   nsString cacheName;
 };
 
 struct CacheReadStream
 {
   nsID id;
   nullable PCacheStreamControl control;
-  OptionalIPCStream stream;
+  IPCStream? stream;
 };
 
 union CacheReadStreamOrVoid
 {
   void_t;
   CacheReadStream;
 };
 
--- a/dom/cache/ReadStream.cpp
+++ b/dom/cache/ReadStream.cpp
@@ -18,17 +18,16 @@
 
 namespace mozilla {
 namespace dom {
 namespace cache {
 
 using mozilla::Unused;
 using mozilla::ipc::AutoIPCStream;
 using mozilla::ipc::IPCStream;
-using mozilla::ipc::OptionalIPCStream;
 
 // ----------------------------------------------------------------------------
 
 // The inner stream class.  This is where all of the real work is done.  As
 // an invariant Inner::Close() must be called before ~Inner().  This is
 // guaranteed by our outer ReadStream class.
 class ReadStream::Inner final : public ReadStream::Controllable {
  public:
@@ -219,20 +218,20 @@ void ReadStream::Inner::Serialize(
   mControl->SerializeControl(aReadStreamOut);
 
   {
     MutexAutoLock lock(mMutex);
     mControl->SerializeStream(aReadStreamOut, mStream, aStreamCleanupList);
   }
 
   MOZ_DIAGNOSTIC_ASSERT(
-      aReadStreamOut->stream().type() == OptionalIPCStream::Tvoid_t ||
-      (aReadStreamOut->stream().get_IPCStream().stream().type() !=
+      aReadStreamOut->stream().isNothing() ||
+      (aReadStreamOut->stream().ref().stream().type() !=
            mozilla::ipc::InputStreamParams::TIPCRemoteStreamParams &&
-       aReadStreamOut->stream().get_IPCStream().stream().type() !=
+       aReadStreamOut->stream().ref().stream().type() !=
            mozilla::ipc::InputStreamParams::T__None));
 
   // We're passing ownership across the IPC barrier with the control, so
   // do not signal that the stream is closed here.
   Forget();
 }
 
 void ReadStream::Inner::CloseStream() {
@@ -517,20 +516,20 @@ already_AddRefed<ReadStream> ReadStream:
   // The parameter may or may not be for a Cache created stream.  The way we
   // tell is by looking at the stream control actor.  If the actor exists,
   // then we know the Cache created it.
   if (!aReadStream.controlChild() && !aReadStream.controlParent()) {
     return nullptr;
   }
 
   MOZ_DIAGNOSTIC_ASSERT(
-      aReadStream.stream().type() == OptionalIPCStream::Tvoid_t ||
-      (aReadStream.stream().get_IPCStream().stream().type() !=
+      aReadStream.stream().isNothing() ||
+      (aReadStream.stream().ref().stream().type() !=
            mozilla::ipc::InputStreamParams::TIPCRemoteStreamParams &&
-       aReadStream.stream().get_IPCStream().stream().type() !=
+       aReadStream.stream().ref().stream().type() !=
            mozilla::ipc::InputStreamParams::T__None));
 
   // Control is guaranteed to survive this method as ActorDestroy() cannot
   // run on this thread until we complete.
   StreamControl* control;
   if (aReadStream.controlChild()) {
     auto actor =
         static_cast<CacheStreamControlChild*>(aReadStream.controlChild());
--- a/dom/file/ipc/IPCBlobInputStreamChild.cpp
+++ b/dom/file/ipc/IPCBlobInputStreamChild.cpp
@@ -279,17 +279,17 @@ void IPCBlobInputStreamChild::StreamNeed
     return;
   }
 
   RefPtr<StreamNeededRunnable> runnable = new StreamNeededRunnable(this);
   mOwningEventTarget->Dispatch(runnable.forget(), NS_DISPATCH_NORMAL);
 }
 
 mozilla::ipc::IPCResult IPCBlobInputStreamChild::RecvStreamReady(
-    const OptionalIPCStream& aStream) {
+    const Maybe<IPCStream>& aStream) {
   nsCOMPtr<nsIInputStream> stream = mozilla::ipc::DeserializeIPCStream(aStream);
 
   RefPtr<IPCBlobInputStream> pendingStream;
   nsCOMPtr<nsIEventTarget> eventTarget;
 
   {
     MutexAutoLock lock(mMutex);
 
--- a/dom/file/ipc/IPCBlobInputStreamChild.h
+++ b/dom/file/ipc/IPCBlobInputStreamChild.h
@@ -51,17 +51,17 @@ class IPCBlobInputStreamChild final
   void ForgetStream(IPCBlobInputStream* aStream);
 
   const nsID& ID() const { return mID; }
 
   uint64_t Size() const { return mSize; }
 
   void StreamNeeded(IPCBlobInputStream* aStream, nsIEventTarget* aEventTarget);
 
-  mozilla::ipc::IPCResult RecvStreamReady(const OptionalIPCStream& aStream);
+  mozilla::ipc::IPCResult RecvStreamReady(const Maybe<IPCStream>& aStream);
 
   void LengthNeeded(IPCBlobInputStream* aStream, nsIEventTarget* aEventTarget);
 
   mozilla::ipc::IPCResult RecvLengthReady(const int64_t& aLength);
 
   void Shutdown();
 
   void Migrated();
--- a/dom/file/ipc/IPCBlobInputStreamParent.cpp
+++ b/dom/file/ipc/IPCBlobInputStreamParent.cpp
@@ -103,17 +103,17 @@ void IPCBlobInputStreamParent::SetCallba
 
 mozilla::ipc::IPCResult IPCBlobInputStreamParent::RecvStreamNeeded() {
   MOZ_ASSERT(mContentManager || mPBackgroundManager);
 
   nsCOMPtr<nsIInputStream> stream;
   IPCBlobInputStreamStorage::Get()->GetStream(mID, 0, mSize,
                                               getter_AddRefs(stream));
   if (!stream) {
-    if (!SendStreamReady(void_t())) {
+    if (!SendStreamReady(Nothing())) {
       return IPC_FAIL(this, "SendStreamReady failed");
     }
 
     return IPC_OK();
   }
 
   mozilla::ipc::AutoIPCStream ipcStream;
   bool ok = false;
@@ -125,17 +125,17 @@ mozilla::ipc::IPCResult IPCBlobInputStre
     MOZ_ASSERT(mPBackgroundManager);
     ok = ipcStream.Serialize(stream, mPBackgroundManager);
   }
 
   if (NS_WARN_IF(!ok)) {
     return IPC_FAIL(this, "SendStreamReady failed");
   }
 
-  if (!SendStreamReady(ipcStream.TakeValue())) {
+  if (!SendStreamReady(Some(ipcStream.TakeValue()))) {
     return IPC_FAIL(this, "SendStreamReady failed");
   }
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult IPCBlobInputStreamParent::RecvLengthNeeded() {
   MOZ_ASSERT(mContentManager || mPBackgroundManager);
--- a/dom/file/ipc/PIPCBlobInputStream.ipdl
+++ b/dom/file/ipc/PIPCBlobInputStream.ipdl
@@ -23,17 +23,17 @@ parent:
 
   async LengthNeeded();
 
   // When this is called, the parent releases the inputStream and sends a
   // __delete__.
   async Close();
 
 child:
-  async StreamReady(OptionalIPCStream aStream);
+  async StreamReady(IPCStream? aStream);
 
   async LengthReady(int64_t aLength);
 
 both:
   // __delete__ can be called by parent and by child for 2 reasons:
   // - parent->child: This happens after a Close(). The child wants to inform
   //                  the parent that no other messages will be dispatched and
   //                  that the channel can be interrupted.
--- a/dom/network/UDPSocketChild.cpp
+++ b/dom/network/UDPSocketChild.cpp
@@ -176,17 +176,17 @@ UDPSocketChild::SendBinaryStream(const n
   NS_ENSURE_ARG(aStream);
 
   mozilla::ipc::AutoIPCStream autoStream;
   autoStream.Serialize(aStream, static_cast<mozilla::dom::ContentChild*>(
                                     gNeckoChild->Manager()));
 
   UDPSOCKET_LOG(
       ("%s: %s:%u", __FUNCTION__, PromiseFlatCString(aHost).get(), aPort));
-  SendOutgoingData(UDPData(autoStream.TakeOptionalValue()),
+  SendOutgoingData(UDPData(autoStream.TakeValue()),
                    UDPSocketAddr(UDPAddressInfo(nsCString(aHost), aPort)));
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 UDPSocketChild::JoinMulticast(const nsACString& aMulticastAddress,
                               const nsACString& aInterface) {
--- a/dom/webbrowserpersist/PWebBrowserPersistDocument.ipdl
+++ b/dom/webbrowserpersist/PWebBrowserPersistDocument.ipdl
@@ -60,17 +60,17 @@ protocol PWebBrowserPersistDocument {
   manages PWebBrowserPersistSerialize;
 
 parent:
   // The actor isn't exposed to XPCOM until after it gets one of these
   // two messages; see also the state transition rules.  The message
   // is either a response to the constructor (if it was parent->child)
   // or sent after it (if it was child->parent).
   async Attributes(WebBrowserPersistDocumentAttrs aAttrs,
-                   OptionalIPCStream stream);
+                   IPCStream? stream);
   async InitFailure(nsresult aStatus);
 
 child:
   async SetPersistFlags(uint32_t aNewFlags);
   async PWebBrowserPersistResources();
   async PWebBrowserPersistSerialize(WebBrowserPersistURIMap aMap,
                                     nsCString aRequestedContentType,
                                     uint32_t aEncoderFlags,
--- a/dom/webbrowserpersist/WebBrowserPersistDocumentParent.cpp
+++ b/dom/webbrowserpersist/WebBrowserPersistDocumentParent.cpp
@@ -48,17 +48,17 @@ void WebBrowserPersistDocumentParent::Ac
 }
 
 WebBrowserPersistDocumentParent::~WebBrowserPersistDocumentParent() {
   MOZ_RELEASE_ASSERT(!mReflection);
   MOZ_ASSERT(!mOnReady);
 }
 
 mozilla::ipc::IPCResult WebBrowserPersistDocumentParent::RecvAttributes(
-    const Attrs& aAttrs, const OptionalIPCStream& aPostStream) {
+    const Attrs& aAttrs, const Maybe<IPCStream>& aPostStream) {
   // Deserialize the postData unconditionally so that fds aren't leaked.
   nsCOMPtr<nsIInputStream> postData =
       mozilla::ipc::DeserializeIPCStream(aPostStream);
   if (!mOnReady || mReflection) {
     return IPC_FAIL_NO_REASON(this);
   }
   mReflection = new WebBrowserPersistRemoteDocument(this, aAttrs, postData);
   RefPtr<WebBrowserPersistRemoteDocument> reflection = mReflection;
--- a/dom/webbrowserpersist/WebBrowserPersistDocumentParent.h
+++ b/dom/webbrowserpersist/WebBrowserPersistDocumentParent.h
@@ -40,17 +40,17 @@ class WebBrowserPersistDocumentParent fi
   // state.  This method must be called exactly once while the actor
   // is still in the START state (or is unconstructed).
   void SetOnReady(nsIWebBrowserPersistDocumentReceiver* aOnReady);
 
   using Attrs = WebBrowserPersistDocumentAttrs;
 
   // IPDL methods:
   mozilla::ipc::IPCResult RecvAttributes(const Attrs& aAttrs,
-                                         const OptionalIPCStream& aPostStream);
+                                         const Maybe<IPCStream>& aPostStream);
   mozilla::ipc::IPCResult RecvInitFailure(const nsresult& aFailure);
 
   PWebBrowserPersistResourcesParent* AllocPWebBrowserPersistResourcesParent();
   bool DeallocPWebBrowserPersistResourcesParent(
       PWebBrowserPersistResourcesParent* aActor);
 
   PWebBrowserPersistSerializeParent* AllocPWebBrowserPersistSerializeParent(
       const WebBrowserPersistURIMap& aMap,
--- a/ipc/glue/IPCStream.ipdlh
+++ b/ipc/glue/IPCStream.ipdlh
@@ -7,25 +7,18 @@ include protocol PParentToChildStream;
 
 include BlobTypes;
 include InputStreamParams;
 include ProtocolTypes;
 
 namespace mozilla {
 namespace ipc {
 
-// Use IPCStream or OptionalIPCStream in your ipdl to represent serialized
-// nsIInputStreams.  Then use AutoIPCStream from IPCStreamUtils.h to perform
-// the serialization.
+// Use IPCStream in your ipdl to represent serialized nsIInputStreams. Then use
+// AutoIPCStream from IPCStreamUtils.h to perform the serialization.
 struct IPCStream
 {
   InputStreamParams stream;
   OptionalFileDescriptorSet optionalFds;
 };
 
-union OptionalIPCStream
-{
-  IPCStream;
-  void_t;
-};
-
 } // namespace ipc
 } // namespace mozilla
--- a/ipc/glue/IPCStreamUtils.cpp
+++ b/ipc/glue/IPCStreamUtils.cpp
@@ -124,70 +124,70 @@ bool SerializeInputStream(nsIInputStream
   aValue.optionalFds() = void_t();
 
   return true;
 }
 
 template <typename M>
 bool SerializeInputStreamChild(nsIInputStream* aStream, M* aManager,
                                IPCStream* aValue,
-                               OptionalIPCStream* aOptionalValue,
+                               Maybe<IPCStream>* aOptionalValue,
                                bool aDelayedStart) {
   MOZ_ASSERT(aStream);
   MOZ_ASSERT(aManager);
   MOZ_ASSERT(aValue || aOptionalValue);
 
   nsCOMPtr<nsIIPCSerializableInputStream> serializable =
       do_QueryInterface(aStream);
 
   if (serializable) {
     if (aValue) {
       return SerializeInputStreamWithFdsChild(serializable, *aValue,
                                               aDelayedStart, aManager);
     }
 
-    return SerializeInputStreamWithFdsChild(serializable, *aOptionalValue,
+    return SerializeInputStreamWithFdsChild(serializable, aOptionalValue->ref(),
                                             aDelayedStart, aManager);
   }
 
   if (aValue) {
     return SerializeInputStream(aStream, *aValue, aManager, aDelayedStart);
   }
 
-  return SerializeInputStream(aStream, *aOptionalValue, aManager,
+  return SerializeInputStream(aStream, aOptionalValue->ref(), aManager,
                               aDelayedStart);
 }
 
 template <typename M>
 bool SerializeInputStreamParent(nsIInputStream* aStream, M* aManager,
                                 IPCStream* aValue,
-                                OptionalIPCStream* aOptionalValue,
+                                Maybe<IPCStream>* aOptionalValue,
                                 bool aDelayedStart) {
   MOZ_ASSERT(aStream);
   MOZ_ASSERT(aManager);
   MOZ_ASSERT(aValue || aOptionalValue);
 
   nsCOMPtr<nsIIPCSerializableInputStream> serializable =
       do_QueryInterface(aStream);
 
   if (serializable) {
     if (aValue) {
       return SerializeInputStreamWithFdsParent(serializable, *aValue,
                                                aDelayedStart, aManager);
     }
 
-    return SerializeInputStreamWithFdsParent(serializable, *aOptionalValue,
-                                             aDelayedStart, aManager);
+    return SerializeInputStreamWithFdsParent(
+        serializable, aOptionalValue->ref(), aDelayedStart, aManager);
   }
 
   if (aValue) {
     return SerializeInputStream(aStream, *aValue, aManager, aDelayedStart);
   }
 
-  return SerializeInputStream(aStream, *aOptionalValue, aManager,
+  return SerializeInputStream(aStream, aOptionalValue->ref(), aManager,
                               aDelayedStart);
 }
 
 void ActivateAndCleanupIPCStream(IPCStream& aValue, bool aConsumedByIPC,
                                  bool aDelayedStart) {
   // Cleanup file descriptors if necessary
   if (aValue.optionalFds().type() ==
       OptionalFileDescriptorSet::TPFileDescriptorSetChild) {
@@ -224,41 +224,40 @@ void ActivateAndCleanupIPCStream(IPCStre
     }
   }
 
   // Activate IPCRemoteStreamParams.
   InputStreamHelper::PostSerializationActivation(aValue.stream(),
                                                  aConsumedByIPC, aDelayedStart);
 }
 
-void ActivateAndCleanupIPCStream(OptionalIPCStream& aValue, bool aConsumedByIPC,
+void ActivateAndCleanupIPCStream(Maybe<IPCStream>& aValue, bool aConsumedByIPC,
                                  bool aDelayedStart) {
-  if (aValue.type() == OptionalIPCStream::Tvoid_t) {
+  if (aValue.isNothing()) {
     return;
   }
 
-  ActivateAndCleanupIPCStream(aValue.get_IPCStream(), aConsumedByIPC,
-                              aDelayedStart);
+  ActivateAndCleanupIPCStream(aValue.ref(), aConsumedByIPC, aDelayedStart);
 }
 
 // Returns false if the serialization should not proceed. This means that the
 // inputStream is null.
 bool NormalizeOptionalValue(nsIInputStream* aStream, IPCStream* aValue,
-                            OptionalIPCStream* aOptionalValue) {
+                            Maybe<IPCStream>* aOptionalValue) {
   if (aValue) {
     // if aStream is null, we will crash when serializing.
     return true;
   }
 
   if (!aStream) {
-    *aOptionalValue = void_t();
+    aOptionalValue->reset();
     return false;
   }
 
-  *aOptionalValue = IPCStream();
+  aOptionalValue->emplace();
   return true;
 }
 
 }  // anonymous namespace
 
 already_AddRefed<nsIInputStream> DeserializeIPCStream(const IPCStream& aValue) {
   // Note, we explicitly do not support deserializing the PChildToParentStream
   // actor on the child side nor the PParentToChildStream actor on the parent
@@ -289,45 +288,42 @@ already_AddRefed<nsIInputStream> Deseria
 
     Unused << FileDescriptorSetChild::Send__delete__(fdSetActor);
   }
 
   return InputStreamHelper::DeserializeInputStream(aValue.stream(), fds);
 }
 
 already_AddRefed<nsIInputStream> DeserializeIPCStream(
-    const OptionalIPCStream& aValue) {
-  if (aValue.type() == OptionalIPCStream::Tvoid_t) {
+    const Maybe<IPCStream>& aValue) {
+  if (aValue.isNothing()) {
     return nullptr;
   }
 
-  return DeserializeIPCStream(aValue.get_IPCStream());
+  return DeserializeIPCStream(aValue.ref());
 }
 
 AutoIPCStream::AutoIPCStream(bool aDelayedStart)
-    : mInlineValue(void_t()),
-      mValue(nullptr),
+    : mValue(nullptr),
       mOptionalValue(&mInlineValue),
       mTaken(false),
       mDelayedStart(aDelayedStart) {}
 
 AutoIPCStream::AutoIPCStream(IPCStream& aTarget, bool aDelayedStart)
-    : mInlineValue(void_t()),
-      mValue(&aTarget),
+    : mValue(&aTarget),
       mOptionalValue(nullptr),
       mTaken(false),
       mDelayedStart(aDelayedStart) {}
 
-AutoIPCStream::AutoIPCStream(OptionalIPCStream& aTarget, bool aDelayedStart)
-    : mInlineValue(void_t()),
-      mValue(nullptr),
+AutoIPCStream::AutoIPCStream(Maybe<IPCStream>& aTarget, bool aDelayedStart)
+    : mValue(nullptr),
       mOptionalValue(&aTarget),
       mTaken(false),
       mDelayedStart(aDelayedStart) {
-  *mOptionalValue = void_t();
+  mOptionalValue->reset();
 }
 
 AutoIPCStream::~AutoIPCStream() {
   MOZ_ASSERT(mValue || mOptionalValue);
   if (mValue && IsSet()) {
     ActivateAndCleanupIPCStream(*mValue, mTaken, mDelayedStart);
   } else {
     ActivateAndCleanupIPCStream(*mOptionalValue, mTaken, mDelayedStart);
@@ -418,38 +414,37 @@ bool AutoIPCStream::Serialize(nsIInputSt
   return true;
 }
 
 bool AutoIPCStream::IsSet() const {
   MOZ_ASSERT(mValue || mOptionalValue);
   if (mValue) {
     return mValue->stream().type() != InputStreamParams::T__None;
   } else {
-    return mOptionalValue->type() != OptionalIPCStream::Tvoid_t &&
-           mOptionalValue->get_IPCStream().stream().type() !=
-               InputStreamParams::T__None;
+    return mOptionalValue->isSome() &&
+           mOptionalValue->ref().stream().type() != InputStreamParams::T__None;
   }
 }
 
 IPCStream& AutoIPCStream::TakeValue() {
   MOZ_ASSERT(mValue || mOptionalValue);
   MOZ_ASSERT(!mTaken);
   MOZ_ASSERT(IsSet());
 
   mTaken = true;
 
   if (mValue) {
     return *mValue;
   }
 
-  IPCStream& value = mOptionalValue->get_IPCStream();
+  IPCStream& value = mOptionalValue->ref();
   return value;
 }
 
-OptionalIPCStream& AutoIPCStream::TakeOptionalValue() {
+Maybe<IPCStream>& AutoIPCStream::TakeOptionalValue() {
   MOZ_ASSERT(!mTaken);
   MOZ_ASSERT(!mValue);
   MOZ_ASSERT(mOptionalValue);
   mTaken = true;
   return *mOptionalValue;
 }
 
 void IPDLParamTraits<nsIInputStream>::Write(IPC::Message* aMsg,
@@ -501,17 +496,17 @@ void IPDLParamTraits<nsIInputStream>::Wr
 
   WriteIPDLParam(aMsg, aActor, autoStream.TakeOptionalValue());
 }
 
 bool IPDLParamTraits<nsIInputStream>::Read(const IPC::Message* aMsg,
                                            PickleIterator* aIter,
                                            IProtocol* aActor,
                                            RefPtr<nsIInputStream>* aResult) {
-  mozilla::ipc::OptionalIPCStream ipcStream;
+  mozilla::Maybe<mozilla::ipc::IPCStream> ipcStream;
   if (!ReadIPDLParam(aMsg, aIter, aActor, &ipcStream)) {
     return false;
   }
 
   *aResult = mozilla::ipc::DeserializeIPCStream(ipcStream);
   return true;
 }
 
--- a/ipc/glue/IPCStreamUtils.h
+++ b/ipc/glue/IPCStreamUtils.h
@@ -23,17 +23,17 @@ namespace ipc {
 class PBackgroundChild;
 class PBackgroundParent;
 
 // Deserialize an IPCStream received from an actor call.  These methods
 // work in both the child and parent.
 already_AddRefed<nsIInputStream> DeserializeIPCStream(const IPCStream& aValue);
 
 already_AddRefed<nsIInputStream> DeserializeIPCStream(
-    const OptionalIPCStream& aValue);
+    const Maybe<IPCStream>& aValue);
 
 // RAII helper class that serializes an nsIInputStream into an IPCStream struct.
 // Any file descriptor or PChildToParentStream actors are automatically managed
 // correctly.
 //
 // Here is a simple example:
 //
 //  // in ipdl file
@@ -99,55 +99,54 @@ already_AddRefed<nsIInputStream> Deseria
 //  MyStuffParent::RecvDoStuff(const Stuff& aStuff) {
 //    nsCOMPtr<nsIInputStream> stream = DeserializeIPCStream(aStuff.stream());
 //    /* do something with the nsIInputStream */
 //  }
 //
 // Note: This example is about child-to-parent inputStream, but AutoIPCStream
 // works also parent-to-child.
 //
-// The AutoIPCStream class also supports OptionalIPCStream values.  As long as
+// The AutoIPCStream class also supports Maybe<IPCStream> values.  As long as
 // you did not initialize the object with a non-optional IPCStream, you can call
 // TakeOptionalValue() instead.
 //
 // The AutoIPCStream class can also be used to serialize nsIInputStream objects
 // on the parent side to send to the child.  Currently, however, this only
 // works for directly serializable stream types.  The PChildToParentStream actor
 // mechanism is not supported in this direction yet.
 //
 // Like SerializeInputStream(), the AutoIPCStream will crash if
 // serialization cannot be completed.
 //
 // NOTE: This is not a MOZ_STACK_CLASS so that it can be more easily integrated
 //       with complex ipdl structures.  For example, you may want to create an
 //       array of RAII AutoIPCStream objects or build your own wrapping
 //       RAII object to handle other actors that need to be cleaned up.
 class AutoIPCStream final {
-  OptionalIPCStream mInlineValue;
+  Maybe<IPCStream> mInlineValue;
   IPCStream* mValue;
-  OptionalIPCStream* mOptionalValue;
+  Maybe<IPCStream>* mOptionalValue;
   bool mTaken;
   bool mDelayedStart;
 
   bool IsSet() const;
 
  public:
-  // Implicitly create an OptionalIPCStream value.  Either
+  // Implicitly create an Maybe<IPCStream> value.  Either
   // TakeValue() or TakeOptionalValue() can be used.
   explicit AutoIPCStream(bool aDelayedStart = false);
 
   // Wrap an existing IPCStream.  Only TakeValue() may be
   // used.  If a nullptr nsIInputStream is passed to SerializeOrSend() then
   // a crash will be forced.
   explicit AutoIPCStream(IPCStream& aTarget, bool aDelayedStart = false);
 
-  // Wrap an existing OptionalIPCStream.  Either TakeValue()
+  // Wrap an existing Maybe<IPCStream>.  Either TakeValue()
   // or TakeOptionalValue can be used.
-  explicit AutoIPCStream(OptionalIPCStream& aTarget,
-                         bool aDelayedStart = false);
+  explicit AutoIPCStream(Maybe<IPCStream>& aTarget, bool aDelayedStart = false);
 
   ~AutoIPCStream();
 
   // Serialize the input stream or create a SendStream actor using the PContent
   // manager.  If neither of these succeed, then crash.  This should only be
   // used on the main thread.
   bool Serialize(nsIInputStream* aStream, dom::nsIContentChild* aManager);
 
@@ -165,20 +164,20 @@ class AutoIPCStream final {
                               PBackgroundParent* aManager);
 
   // Get the IPCStream as a non-optional value.  This will
   // assert if a stream has not been serialized or if it has already been taken.
   // This should only be called if the value is being, or has already been, sent
   // to the other side.
   IPCStream& TakeValue();
 
-  // Get the OptionalIPCStream value.  This will assert if
-  // the value has already been taken.  This should only be called if the value
-  // is being, or has already been, sent to the other side.
-  OptionalIPCStream& TakeOptionalValue();
+  // Get the Maybe<IPCStream> value. This will assert if the value has already
+  // been taken. This should only be called if the value is being, or has
+  // already been, sent to the other side.
+  Maybe<IPCStream>& TakeOptionalValue();
 
  private:
   AutoIPCStream(const AutoIPCStream& aOther) = delete;
   AutoIPCStream& operator=(const AutoIPCStream& aOther) = delete;
   AutoIPCStream& operator=(const AutoIPCStream&& aOther) = delete;
 };
 
 template <>
--- a/netwerk/ipc/NeckoChannelParams.ipdlh
+++ b/netwerk/ipc/NeckoChannelParams.ipdlh
@@ -223,17 +223,17 @@ struct HttpChannelOpenArgs
   OptionalURIParams           referrer;
   uint32_t                    referrerPolicy;
   OptionalURIParams           apiRedirectTo;
   OptionalURIParams           topWindowURI;
   nsIPrincipal                topWindowPrincipal;
   uint32_t                    loadFlags;
   RequestHeaderTuples         requestHeaders;
   nsCString                   requestMethod;
-  OptionalIPCStream           uploadStream;
+  IPCStream?                  uploadStream;
   bool                        uploadStreamHasHeaders;
   int16_t                     priority;
   uint32_t                    classOfService;
   uint8_t                     redirectionLimit;
   bool                        allowSTS;
   uint32_t                    thirdPartyFlags;
   bool                        resumeAt;
   uint64_t                    startPos;
@@ -288,17 +288,17 @@ union HttpChannelCreationArgs
 // FTP IPDL structs
 //-----------------------------------------------------------------------------
 
 struct FTPChannelOpenArgs
 {
   URIParams                 uri;
   uint64_t                  startPos;
   nsCString                 entityID;
-  OptionalIPCStream         uploadStream;
+  IPCStream?                uploadStream;
   OptionalLoadInfoArgs      loadInfo;
   uint32_t                  loadFlags;
 };
 
 struct FTPChannelConnectArgs
 {
   uint32_t channelId;
 };
--- a/netwerk/protocol/ftp/FTPChannelParent.cpp
+++ b/netwerk/protocol/ftp/FTPChannelParent.cpp
@@ -100,17 +100,17 @@ bool FTPChannelParent::Init(const FTPCha
       MOZ_ASSERT_UNREACHABLE("unknown open type");
       return false;
   }
 }
 
 bool FTPChannelParent::DoAsyncOpen(const URIParams& aURI,
                                    const uint64_t& aStartPos,
                                    const nsCString& aEntityID,
-                                   const OptionalIPCStream& aUploadStream,
+                                   const Maybe<IPCStream>& aUploadStream,
                                    const OptionalLoadInfoArgs& aLoadInfoArgs,
                                    const uint32_t& aLoadFlags) {
   nsresult rv;
 
   nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
   if (!uri) return false;
 
 #ifdef DEBUG
--- a/netwerk/protocol/ftp/FTPChannelParent.h
+++ b/netwerk/protocol/ftp/FTPChannelParent.h
@@ -72,17 +72,17 @@ class FTPChannelParent final : public PF
   // private, supporting function for ADivertableParentChannel.
   nsresult ResumeForDiversion();
 
   // Asynchronously calls NotifyDiversionFailed.
   void FailDiversion(nsresult aErrorCode, bool aSkipResume = true);
 
   bool DoAsyncOpen(const URIParams& aURI, const uint64_t& aStartPos,
                    const nsCString& aEntityID,
-                   const OptionalIPCStream& aUploadStream,
+                   const Maybe<IPCStream>& aUploadStream,
                    const OptionalLoadInfoArgs& aLoadInfoArgs,
                    const uint32_t& aLoadFlags);
 
   // used to connect redirected-to channel in parent with just created
   // ChildChannel.  Used during HTTP->FTP redirects.
   bool ConnectChannel(const uint32_t& channelId);
 
   void DivertOnDataAvailable(const nsCString& data, const uint64_t& offset,
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -3139,29 +3139,29 @@ HttpChannelChild::GetAltDataInputStream(
 
   mAltDataInputStreamReceiver = aReceiver;
   Unused << SendOpenAltDataCacheInputStream(nsCString(aType));
 
   return NS_OK;
 }
 
 mozilla::ipc::IPCResult HttpChannelChild::RecvOriginalCacheInputStreamAvailable(
-    const OptionalIPCStream& aStream) {
+    const Maybe<IPCStream>& aStream) {
   nsCOMPtr<nsIInputStream> stream = DeserializeIPCStream(aStream);
   nsCOMPtr<nsIInputStreamReceiver> receiver;
   receiver.swap(mOriginalInputStreamReceiver);
   if (receiver) {
     receiver->OnInputStreamReady(stream);
   }
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult HttpChannelChild::RecvAltDataCacheInputStreamAvailable(
-    const OptionalIPCStream& aStream) {
+    const Maybe<IPCStream>& aStream) {
   nsCOMPtr<nsIInputStream> stream = DeserializeIPCStream(aStream);
   nsCOMPtr<nsIInputStreamReceiver> receiver;
   receiver.swap(mAltDataInputStreamReceiver);
   if (receiver) {
     receiver->OnInputStreamReady(stream);
   }
 
   return IPC_OK();
--- a/netwerk/protocol/http/HttpChannelChild.h
+++ b/netwerk/protocol/http/HttpChannelChild.h
@@ -171,20 +171,20 @@ class HttpChannelChild final : public PH
   mozilla::ipc::IPCResult RecvAttachStreamFilter(
       Endpoint<extensions::PStreamFilterParent>&& aEndpoint) override;
 
   mozilla::ipc::IPCResult RecvCancelDiversion() override;
 
   mozilla::ipc::IPCResult RecvCancelRedirected() override;
 
   mozilla::ipc::IPCResult RecvOriginalCacheInputStreamAvailable(
-      const OptionalIPCStream& aStream) override;
+      const Maybe<IPCStream>& aStream) override;
 
   mozilla::ipc::IPCResult RecvAltDataCacheInputStreamAvailable(
-      const OptionalIPCStream& aStream) override;
+      const Maybe<IPCStream>& aStream) override;
 
   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
 
   virtual void DoNotifyListenerCleanup() override;
 
   virtual void DoAsyncAbort(nsresult aStatus) override;
 
   nsresult AsyncCall(
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -382,17 +382,17 @@ void HttpChannelParent::InvokeAsyncOpen(
 }
 
 bool HttpChannelParent::DoAsyncOpen(
     const URIParams& aURI, const OptionalURIParams& aOriginalURI,
     const OptionalURIParams& aDocURI, const OptionalURIParams& aReferrerURI,
     const uint32_t& aReferrerPolicy, const OptionalURIParams& aAPIRedirectToURI,
     const OptionalURIParams& aTopWindowURI, nsIPrincipal* aTopWindowPrincipal,
     const uint32_t& aLoadFlags, const RequestHeaderTuples& requestHeaders,
-    const nsCString& requestMethod, const OptionalIPCStream& uploadStream,
+    const nsCString& requestMethod, const Maybe<IPCStream>& uploadStream,
     const bool& uploadStreamHasHeaders, const int16_t& priority,
     const uint32_t& classOfService, const uint8_t& redirectionLimit,
     const bool& allowSTS, const uint32_t& thirdPartyFlags,
     const bool& doResumeAt, const uint64_t& startPos, const nsCString& entityID,
     const bool& chooseApplicationCache, const nsCString& appCacheClientID,
     const bool& allowSpdy, const bool& allowAltSvc, const bool& beConservative,
     const uint32_t& tlsFlags, const OptionalLoadInfoArgs& aLoadInfoArgs,
     const OptionalHttpResponseHead& aSynthesizedResponseHead,
--- a/netwerk/protocol/http/HttpChannelParent.h
+++ b/netwerk/protocol/http/HttpChannelParent.h
@@ -139,17 +139,17 @@ class HttpChannelParent final : public n
 
   MOZ_MUST_USE bool DoAsyncOpen(
       const URIParams& uri, const OptionalURIParams& originalUri,
       const OptionalURIParams& docUri, const OptionalURIParams& referrerUri,
       const uint32_t& referrerPolicy,
       const OptionalURIParams& internalRedirectUri,
       const OptionalURIParams& topWindowUri, nsIPrincipal* aTopWindowPrincipal,
       const uint32_t& loadFlags, const RequestHeaderTuples& requestHeaders,
-      const nsCString& requestMethod, const OptionalIPCStream& uploadStream,
+      const nsCString& requestMethod, const Maybe<IPCStream>& uploadStream,
       const bool& uploadStreamHasHeaders, const int16_t& priority,
       const uint32_t& classOfService, const uint8_t& redirectionLimit,
       const bool& allowSTS, const uint32_t& thirdPartyFlags,
       const bool& doResumeAt, const uint64_t& startPos,
       const nsCString& entityID, const bool& chooseApplicationCache,
       const nsCString& appCacheClientID, const bool& allowSpdy,
       const bool& allowAltSvc, const bool& beConservative,
       const uint32_t& tlsFlags, const OptionalLoadInfoArgs& aLoadInfoArgs,
--- a/netwerk/protocol/http/PHttpChannel.ipdl
+++ b/netwerk/protocol/http/PHttpChannel.ipdl
@@ -177,19 +177,19 @@ child:
                             nsString url,
                             nsString contentType);
 
   async AttachStreamFilter(Endpoint<PStreamFilterParent> aEndpoint);
 
   // See ADivertableParentChannel::CancelDiversion
   async CancelDiversion();
 
-  async OriginalCacheInputStreamAvailable(OptionalIPCStream stream);
+  async OriginalCacheInputStreamAvailable(IPCStream? stream);
 
-  async AltDataCacheInputStreamAvailable(OptionalIPCStream stream);
+  async AltDataCacheInputStreamAvailable(IPCStream? stream);
 
 both:
   // After receiving this message, the parent also calls
   // SendFinishInterceptedRedirect, and makes sure not to send any more messages
   // after that. When receiving this message, the child will call
   // Send__delete__() and complete the steps required to finish the redirect.
   async FinishInterceptedRedirect();
 
--- a/netwerk/protocol/res/ExtensionProtocolHandler.cpp
+++ b/netwerk/protocol/res/ExtensionProtocolHandler.cpp
@@ -45,17 +45,16 @@
 
 #if defined(XP_WIN)
 #  include "nsILocalFileWin.h"
 #  include "WinUtils.h"
 #endif
 
 #define EXTENSION_SCHEME "moz-extension"
 using mozilla::ipc::FileDescriptor;
-using OptionalIPCStream = mozilla::ipc::OptionalIPCStream;
 
 namespace mozilla {
 
 namespace net {
 
 using extensions::URLInfo;
 
 LazyLogModule gExtProtocolLog("ExtProtocol");