Bug 1261307: Convert |StreamSocketConsumer::ReceiveSocketData| to |UniquePtr|, r=nfroyd
authorThomas Zimmermann <tdz@users.sourceforge.net>
Tue, 05 Apr 2016 13:40:11 +0200
changeset 291631 e7d1dab0ba6ff0e4be3aa1688a355ccbd16ecda3
parent 291630 37b60f2ed39c01ee7e108ee5a8ccdd1aa3a173f8
child 291632 6d72a998142a67abdf81082e0b4803d2fa52a503
push id74645
push usertdz@users.sourceforge.net
push dateTue, 05 Apr 2016 11:42:01 +0000
treeherdermozilla-inbound@7e2855721acc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd
bugs1261307
milestone48.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 1261307: Convert |StreamSocketConsumer::ReceiveSocketData| to |UniquePtr|, r=nfroyd |ReceiveSocketData| is a public interface of |StreamSocketConsumer| that is overloaded by inherited classes. Therefore we convert it separately.
dom/nfc/gonk/NfcService.cpp
ipc/keystore/KeyStore.cpp
ipc/keystore/KeyStore.h
ipc/unixsocket/StreamSocket.cpp
ipc/unixsocket/StreamSocket.h
ipc/unixsocket/StreamSocketConsumer.h
--- a/dom/nfc/gonk/NfcService.cpp
+++ b/dom/nfc/gonk/NfcService.cpp
@@ -59,17 +59,17 @@ public:
 
   nsresult Send(const CommandOptions& aCommandOptions);
   nsresult Receive(UnixSocketBuffer* aBuffer);
 
   // Methods for |StreamSocketConsumer| and |ListenSocketConsumer|
   //
 
   void ReceiveSocketData(
-    int aIndex, nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aBuffer) override;
+    int aIndex, UniquePtr<mozilla::ipc::UnixSocketBuffer>& aBuffer) override;
 
   void OnConnectSuccess(int aIndex) override;
   void OnConnectError(int aIndex) override;
   void OnDisconnect(int aIndex) override;
 
 private:
   class DispatchNfcEventRunnable;
   class ShutdownServiceRunnable;
@@ -357,22 +357,22 @@ NfcConsumer::IsNfcServiceThread() const
 {
   return nsCOMPtr<nsIThread>(do_GetCurrentThread()) == mThread;
 }
 
 // |StreamSocketConsumer|, |ListenSocketConsumer|
 
 void
 NfcConsumer::ReceiveSocketData(
-  int aIndex, nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aBuffer)
+  int aIndex, UniquePtr<mozilla::ipc::UnixSocketBuffer>& aBuffer)
 {
   MOZ_ASSERT(IsNfcServiceThread());
   MOZ_ASSERT(aIndex == STREAM_SOCKET);
 
-  Receive(aBuffer);
+  Receive(aBuffer.get());
 }
 
 void
 NfcConsumer::OnConnectSuccess(int aIndex)
 {
   MOZ_ASSERT(IsNfcServiceThread());
 
   switch (aIndex) {
--- a/ipc/keystore/KeyStore.cpp
+++ b/ipc/keystore/KeyStore.cpp
@@ -877,33 +877,33 @@ KeyStore::SendData(const uint8_t *aData,
 
   UnixSocketRawData* data = new UnixSocketRawData((const void *)aData, aLength);
   mStreamSocket->SendSocketData(data);
 }
 
 // |StreamSocketConsumer|, |ListenSocketConsumer|
 
 void
-KeyStore::ReceiveSocketData(int aIndex, nsAutoPtr<UnixSocketBuffer>& aMessage)
+KeyStore::ReceiveSocketData(int aIndex, UniquePtr<UnixSocketBuffer>& aMessage)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // Handle request.
   ResponseCode result = SUCCESS;
   while (aMessage->GetSize() ||
          mHandlerInfo.state == STATE_PROCESSING) {
     switch (mHandlerInfo.state) {
       case STATE_IDLE:
-        result = ReadCommand(aMessage);
+        result = ReadCommand(aMessage.get());
         break;
       case STATE_READ_PARAM_LEN:
-        result = ReadLength(aMessage);
+        result = ReadLength(aMessage.get());
         break;
       case STATE_READ_PARAM_DATA:
-        result = ReadData(aMessage);
+        result = ReadData(aMessage.get());
         break;
       case STATE_PROCESSING:
         if (mHandlerInfo.command == 'g') {
           result = SYSTEM_ERROR;
 
           nsNSSShutDownPreventionLock locker;
           if (isAlreadyShutDown()) {
             break;
--- a/ipc/keystore/KeyStore.h
+++ b/ipc/keystore/KeyStore.h
@@ -119,17 +119,17 @@ private:
   ResponseCode ReadData(UnixSocketBuffer *aMessage);
   void SendResponse(ResponseCode response);
   void SendData(const uint8_t *data, int length);
 
   // Methods for |StreamSocketConsumer|
   //
 
   void ReceiveSocketData(int aIndex,
-                         nsAutoPtr<UnixSocketBuffer>& aMessage) override;
+                         UniquePtr<UnixSocketBuffer>& aMessage) override;
   void OnConnectSuccess(int aIndex) override;
   void OnConnectError(int aIndex) override;
   void OnDisconnect(int aIndex) override;
 
   bool mShutdown;
 
   RefPtr<ListenSocket> mListenSocket;
   RefPtr<StreamSocket> mStreamSocket;
--- a/ipc/unixsocket/StreamSocket.cpp
+++ b/ipc/unixsocket/StreamSocket.cpp
@@ -222,17 +222,17 @@ public:
 
     StreamSocket* streamSocket = io->GetStreamSocket();
     MOZ_ASSERT(streamSocket);
 
     streamSocket->ReceiveSocketData(mBuffer);
   }
 
 private:
-  nsAutoPtr<UnixSocketBuffer> mBuffer;
+  UniquePtr<UnixSocketBuffer> mBuffer;
 };
 
 void
 StreamSocketIO::ConsumeBuffer()
 {
   GetConsumerThread()->PostTask(FROM_HERE,
                                 new ReceiveTask(this, mBuffer.forget()));
 }
@@ -361,17 +361,17 @@ StreamSocket::StreamSocket(StreamSocketC
 StreamSocket::~StreamSocket()
 {
   MOZ_ASSERT(!mIO);
 
   MOZ_COUNT_DTOR_INHERITED(StreamSocket, ConnectionOrientedSocket);
 }
 
 void
-StreamSocket::ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer)
+StreamSocket::ReceiveSocketData(UniquePtr<UnixSocketBuffer>& aBuffer)
 {
   mConsumer->ReceiveSocketData(mIndex, aBuffer);
 }
 
 nsresult
 StreamSocket::Connect(UnixSocketConnector* aConnector, int aDelayMs,
                       MessageLoop* aConsumerLoop, MessageLoop* aIOLoop)
 {
--- a/ipc/unixsocket/StreamSocket.h
+++ b/ipc/unixsocket/StreamSocket.h
@@ -29,17 +29,17 @@ public:
    */
   StreamSocket(StreamSocketConsumer* aConsumer, int aIndex);
 
   /**
    * Method to be called whenever data is received. Consumer-thread only.
    *
    * @param aBuffer Data received from the socket.
    */
-  void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer);
+  void ReceiveSocketData(UniquePtr<UnixSocketBuffer>& aBuffer);
 
   /**
    * Starts a task on the socket that will try to connect to a socket in a
    * non-blocking manner.
    *
    * @param aConnector Connector object for socket type specific functions
    * @param aDelayMs Time delay in milliseconds.
    * @param aConsumerLoop The socket's consumer thread.
--- a/ipc/unixsocket/StreamSocketConsumer.h
+++ b/ipc/unixsocket/StreamSocketConsumer.h
@@ -2,17 +2,17 @@
 /* vim: set ts=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/. */
 
 #ifndef mozilla_ipc_streamsocketconsumer_h
 #define mozilla_ipc_streamsocketconsumer_h
 
-#include "nsAutoPtr.h"
+#include "mozilla/UniquePtr.h"
 
 namespace mozilla {
 namespace ipc {
 
 class UnixSocketBuffer;
 
 /**
  * |StreamSocketConsumer| handles socket events and received data.
@@ -22,17 +22,17 @@ class StreamSocketConsumer
 public:
   /**
    * Method to be called whenever data is received. Consumer-thread only.
    *
    * @param aIndex The index that has been given to the stream socket.
    * @param aBuffer Data received from the socket.
    */
   virtual void ReceiveSocketData(int aIndex,
-                                 nsAutoPtr<UnixSocketBuffer>& aBuffer) = 0;
+                                 UniquePtr<UnixSocketBuffer>& aBuffer) = 0;
 
   /**
    * Callback for socket success. Consumer-thread only.
    *
    * @param aIndex The index that has been given to the stream socket.
    */
   virtual void OnConnectSuccess(int aIndex) = 0;