Bug 1578919 - Cleanup AutoIPCStream r=asuth
authorPerry Jiang <perry@mozilla.com>
Fri, 11 Oct 2019 23:22:24 +0000
changeset 497332 15e4b16324a618ac62e7100995b5d4009c07392f
parent 497331 6f876f24a948c758146f87733a9895722b441c6a
child 497333 f62280bf339a179ad3a90348e1f6ff43eb8c6540
push id36682
push userncsoregi@mozilla.com
push dateSat, 12 Oct 2019 09:52:03 +0000
treeherdermozilla-central@06ea2371f897 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1578919
milestone71.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 1578919 - Cleanup AutoIPCStream r=asuth Differential Revision: https://phabricator.services.mozilla.com/D48934
ipc/glue/IPCStreamUtils.cpp
ipc/glue/IPCStreamUtils.h
--- a/ipc/glue/IPCStreamUtils.cpp
+++ b/ipc/glue/IPCStreamUtils.cpp
@@ -297,32 +297,23 @@ already_AddRefed<nsIInputStream> Deseria
   if (aValue.isNothing()) {
     return nullptr;
   }
 
   return DeserializeIPCStream(aValue.ref());
 }
 
 AutoIPCStream::AutoIPCStream(bool aDelayedStart)
-    : mValue(nullptr),
-      mOptionalValue(&mInlineValue),
-      mTaken(false),
-      mDelayedStart(aDelayedStart) {}
+    : mOptionalValue(&mInlineValue), mDelayedStart(aDelayedStart) {}
 
 AutoIPCStream::AutoIPCStream(IPCStream& aTarget, bool aDelayedStart)
-    : mValue(&aTarget),
-      mOptionalValue(nullptr),
-      mTaken(false),
-      mDelayedStart(aDelayedStart) {}
+    : mValue(&aTarget), mDelayedStart(aDelayedStart) {}
 
 AutoIPCStream::AutoIPCStream(Maybe<IPCStream>& aTarget, bool aDelayedStart)
-    : mValue(nullptr),
-      mOptionalValue(&aTarget),
-      mTaken(false),
-      mDelayedStart(aDelayedStart) {
+    : mOptionalValue(&aTarget), mDelayedStart(aDelayedStart) {
   mOptionalValue->reset();
 }
 
 AutoIPCStream::~AutoIPCStream() {
   MOZ_ASSERT(mValue || mOptionalValue);
   if (mValue && IsSet()) {
     ActivateAndCleanupIPCStream(*mValue, mTaken, mDelayedStart);
   } else {
--- a/ipc/glue/IPCStreamUtils.h
+++ b/ipc/glue/IPCStreamUtils.h
@@ -116,38 +116,36 @@ already_AddRefed<nsIInputStream> Deseria
 // 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 {
-  Maybe<IPCStream> mInlineValue;
-  IPCStream* mValue;
-  Maybe<IPCStream>* mOptionalValue;
-  bool mTaken;
-  bool mDelayedStart;
-
-  bool IsSet() const;
-
  public:
   // 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 Maybe<IPCStream>.  Either TakeValue()
   // or TakeOptionalValue can be used.
   explicit AutoIPCStream(Maybe<IPCStream>& aTarget, bool aDelayedStart = false);
 
+  AutoIPCStream(const AutoIPCStream&) = delete;
+  AutoIPCStream(AutoIPCStream&&) = delete;
+
+  AutoIPCStream& operator=(const AutoIPCStream&) = delete;
+  AutoIPCStream& operator=(AutoIPCStream&&) = delete;
+
   ~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::ContentChild* aManager);
 
   // Serialize the input stream or create a SendStream actor using the
@@ -170,19 +168,23 @@ class AutoIPCStream final {
   IPCStream& TakeValue();
 
   // 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;
+  bool IsSet() const;
+
+  Maybe<IPCStream> mInlineValue;
+  IPCStream* const mValue = nullptr;
+  Maybe<IPCStream>* const mOptionalValue = nullptr;
+  bool mTaken = false;
+  const bool mDelayedStart;
 };
 
 template <>
 struct IPDLParamTraits<nsIInputStream*> {
   static void Write(IPC::Message* aMsg, IProtocol* aActor,
                     nsIInputStream* aParam);
   static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
                    IProtocol* aActor, RefPtr<nsIInputStream>* aResult);