Bug 1328634 - part 1 - use UniquePtr in AutoEnterTransaction; r=billm
authorNathan Froyd <froydnj@mozilla.com>
Thu, 21 Sep 2017 14:52:37 -0500
changeset 420078 139e75b70bd5c12f7dcfed4958cd128edcc34103
parent 420077 90be30b5206c2b2724d61f4f6782197bfa768428
child 420079 e07b12686da37a95889db2a785b120ef3b41c8c2
push idunknown
push userunknown
push dateunknown
reviewersbillm
bugs1328634
milestone58.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 1328634 - part 1 - use UniquePtr in AutoEnterTransaction; r=billm One less use of nsAutoPtr!
ipc/glue/MessageChannel.cpp
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -12,16 +12,17 @@
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/ipc/ProtocolUtils.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Move.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TimeStamp.h"
 #include "nsAppRunner.h"
+#include "mozilla/UniquePtr.h"
 #include "nsAutoPtr.h"
 #include "nsDebug.h"
 #include "nsISupportsImpl.h"
 #include "nsContentUtils.h"
 #include <math.h>
 
 #ifdef MOZ_TASK_TRACER
 #include "GeckoTaskTracer.h"
@@ -411,17 +412,17 @@ public:
         return mTransaction;
     }
 
     void ReceivedReply(IPC::Message&& aMessage) {
         MOZ_RELEASE_ASSERT(aMessage.seqno() == mSeqno);
         MOZ_RELEASE_ASSERT(aMessage.transaction_id() == mTransaction);
         MOZ_RELEASE_ASSERT(!mReply);
         IPC_LOG("Reply received on worker thread: seqno=%d", mSeqno);
-        mReply = new IPC::Message(Move(aMessage));
+        mReply = MakeUnique<IPC::Message>(Move(aMessage));
         MOZ_RELEASE_ASSERT(IsComplete());
     }
 
     void HandleReply(IPC::Message&& aMessage) {
         AutoEnterTransaction *cur = mChan->mTransactionStack;
         MOZ_RELEASE_ASSERT(cur == this);
         while (cur) {
             MOZ_RELEASE_ASSERT(cur->mActive);
@@ -450,17 +451,17 @@ public:
         return !mNext;
     }
 
     bool IsError() {
         MOZ_RELEASE_ASSERT(mReply);
         return mReply->is_reply_error();
     }
 
-    nsAutoPtr<IPC::Message> GetReply() {
+    UniquePtr<IPC::Message> GetReply() {
         return Move(mReply);
     }
 
 private:
     MessageChannel *mChan;
 
     // Active is true if this transaction is on the mChan->mTransactionStack
     // stack. Generally we're not on the stack if the transaction was canceled
@@ -475,17 +476,17 @@ private:
     int mNestedLevel;
     int32_t mSeqno;
     int32_t mTransaction;
 
     // Next item in mChan->mTransactionStack.
     AutoEnterTransaction *mNext;
 
     // Pointer the a reply received for this message, if one was received.
-    nsAutoPtr<IPC::Message> mReply;
+    UniquePtr<IPC::Message> mReply;
 };
 
 class PromiseReporter final : public nsIMemoryReporter
 {
     ~PromiseReporter() {}
 public:
     NS_DECL_THREADSAFE_ISUPPORTS
 
@@ -1529,17 +1530,17 @@ MessageChannel::Send(Message* aMsg, Mess
         mLastSendError = SyncSendError::ReplyError;
         return false;
     }
 
     uint32_t latencyMs = round((TimeStamp::Now() - start).ToMilliseconds());
     IPC_LOG("Got reply: seqno=%d, xid=%d, msgName=%s, latency=%ums",
             seqno, transaction, msgName, latencyMs);
 
-    nsAutoPtr<Message> reply = transact.GetReply();
+    UniquePtr<Message> reply = transact.GetReply();
 
     MOZ_RELEASE_ASSERT(reply);
     MOZ_RELEASE_ASSERT(reply->is_reply(), "expected reply");
     MOZ_RELEASE_ASSERT(!reply->is_reply_error());
     MOZ_RELEASE_ASSERT(reply->seqno() == seqno);
     MOZ_RELEASE_ASSERT(reply->type() == replyType, "wrong reply type");
     MOZ_RELEASE_ASSERT(reply->is_sync());