Bug 1156352: Remove |UnixSocketRawData| from socket I/O interfaces, r=kmachulis
authorThomas Zimmermann <tdz@users.sourceforge.net>
Thu, 23 Apr 2015 13:48:48 +0200
changeset 240695 67822e71d7ceb5dfb3cba41880d0b9bf0e527c9e
parent 240694 271b9895de10289b848aaa39ad74ea80902f24db
child 240696 ab5f7d13e2296fb8b887f3c19802bacf253e2152
push idunknown
push userunknown
push dateunknown
reviewerskmachulis
bugs1156352
milestone40.0a1
Bug 1156352: Remove |UnixSocketRawData| from socket I/O interfaces, r=kmachulis
dom/bluetooth/bluedroid/BluetoothSocket.cpp
dom/bluetooth/bluedroid/BluetoothSocket.h
dom/bluetooth/bluez/BluetoothSocket.cpp
dom/bluetooth/bluez/BluetoothSocket.h
ipc/keystore/KeyStore.cpp
ipc/keystore/KeyStore.h
ipc/nfc/Nfc.cpp
ipc/nfc/Nfc.h
ipc/ril/Ril.cpp
ipc/ril/Ril.h
ipc/unixsocket/SocketBase.cpp
ipc/unixsocket/SocketBase.h
ipc/unixsocket/StreamSocket.cpp
ipc/unixsocket/StreamSocket.h
--- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp
@@ -81,19 +81,19 @@ public:
     , mConnectionStatus(SOCKET_IS_DISCONNECTED)
   { }
 
   ~DroidSocketImpl()
   {
     MOZ_ASSERT(NS_IsMainThread());
   }
 
-  void Send(UnixSocketRawData* aData)
+  void Send(UnixSocketIOBuffer* aBuffer)
   {
-    EnqueueData(aData);
+    EnqueueData(aBuffer);
     AddWatchers(WRITE_WATCHER, false);
   }
 
   bool IsShutdownOnMainThread()
   {
     MOZ_ASSERT(NS_IsMainThread());
     return mConsumer == nullptr;
   }
@@ -651,40 +651,35 @@ BluetoothSocket::CloseSocket()
   XRE_GetIOMessageLoop()->PostTask(
     FROM_HERE, new SocketIOShutdownTask<DroidSocketImpl>(mImpl));
 
   mImpl = nullptr;
 
   NotifyDisconnect();
 }
 
-bool
-BluetoothSocket::SendSocketData(UnixSocketRawData* aData)
+void
+BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  NS_ENSURE_TRUE(mImpl, false);
-
+  MOZ_ASSERT(mImpl);
   MOZ_ASSERT(!mImpl->IsShutdownOnMainThread());
 
   XRE_GetIOMessageLoop()->PostTask(
     FROM_HERE,
-    new SocketIOSendTask<DroidSocketImpl, UnixSocketRawData>(mImpl, aData));
-
-  return true;
+    new SocketIOSendTask<DroidSocketImpl, UnixSocketIOBuffer>(mImpl, aBuffer));
 }
 
 void
-BluetoothSocket::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
+BluetoothSocket::ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mObserver);
 
-  nsAutoPtr<mozilla::ipc::UnixSocketBuffer> buffer(aMessage.forget());
-
-  mObserver->ReceiveSocketData(this, buffer);
+  mObserver->ReceiveSocketData(this, aBuffer);
 }
 
 void
 BluetoothSocket::OnConnectSuccess()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mObserver);
 
--- a/dom/bluetooth/bluedroid/BluetoothSocket.h
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.h
@@ -27,25 +27,25 @@ public:
   bool ConnectSocket(const nsAString& aDeviceAddress,
                      const BluetoothUuid& aServiceUuid,
                      int aChannel);
 
   bool ListenSocket(const nsAString& aServiceName,
                     const BluetoothUuid& aServiceUuid,
                     int aChannel);
 
-  void CloseSocket();
+  void CloseSocket() override;
 
-  bool SendSocketData(mozilla::ipc::UnixSocketRawData* aData);
+  void SendSocketData(mozilla::ipc::UnixSocketIOBuffer* aBuffer) override;
 
   virtual void OnConnectSuccess() override;
   virtual void OnConnectError() override;
   virtual void OnDisconnect() override;
   virtual void ReceiveSocketData(
-    nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aMessage) override;
+    nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aBuffer) override;
 
   inline void GetAddress(nsAString& aDeviceAddress)
   {
     aDeviceAddress = mDeviceAddress;
   }
 
   inline void SetAddress(const nsAString& aDeviceAddress)
   {
--- a/dom/bluetooth/bluez/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluez/BluetoothSocket.cpp
@@ -62,17 +62,17 @@ public:
    */
   void Listen();
 
   /**
    * Connect to a socket
    */
   void Connect();
 
-  void Send(UnixSocketRawData* aData);
+  void Send(UnixSocketIOBuffer* aBuffer);
 
   // I/O callback methods
   //
 
   void OnAccepted(int aFd, const sockaddr_any* aAddr,
                   socklen_t aAddrLen) override;
   void OnConnected() override;
   void OnError(const char* aFunction, int aErrno) override;
@@ -296,19 +296,19 @@ BluetoothSocket::BluetoothSocketIO::Conn
 
   // calls OnConnected() on success, or OnError() otherwise
   nsresult rv = UnixSocketWatcher::Connect(
     reinterpret_cast<struct sockaddr*>(&mAddr), mAddrSize);
   NS_WARN_IF(NS_FAILED(rv));
 }
 
 void
-BluetoothSocket::BluetoothSocketIO::Send(UnixSocketRawData* aData)
+BluetoothSocket::BluetoothSocketIO::Send(UnixSocketIOBuffer* aBuffer)
 {
-  EnqueueData(aData);
+  EnqueueData(aBuffer);
   AddWatchers(WRITE_WATCHER, false);
 }
 
 void
 BluetoothSocket::BluetoothSocketIO::OnAccepted(
   int aFd, const sockaddr_any* aAddr, socklen_t aAddrLen)
 {
   MOZ_ASSERT(MessageLoopForIO::current() == GetIOLoop());
@@ -602,24 +602,22 @@ BluetoothSocket::Listen(const nsAString&
            __FUNCTION__, NS_ConvertUTF16toUTF8(addr).get());
     return false;
   }
 
   return true;
 }
 
 void
-BluetoothSocket::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
+BluetoothSocket::ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mObserver);
 
-  nsAutoPtr<UnixSocketBuffer> buffer(aMessage.forget());
-
-  mObserver->ReceiveSocketData(this, buffer);
+  mObserver->ReceiveSocketData(this, aBuffer);
 }
 
 void
 BluetoothSocket::OnConnectSuccess()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mObserver);
   mObserver->OnSocketConnectSuccess(this);
@@ -636,47 +634,36 @@ BluetoothSocket::OnConnectError()
 void
 BluetoothSocket::OnDisconnect()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mObserver);
   mObserver->OnSocketDisconnect(this);
 }
 
-bool
-BluetoothSocket::SendSocketData(UnixSocketRawData* aData)
+void
+BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  if (!mIO) {
-    return false;
-  }
+  MOZ_ASSERT(mIO);
+  MOZ_ASSERT(!mIO->IsShutdownOnMainThread());
 
-  MOZ_ASSERT(!mIO->IsShutdownOnMainThread());
   XRE_GetIOMessageLoop()->PostTask(
     FROM_HERE,
-    new SocketIOSendTask<BluetoothSocketIO, UnixSocketRawData>(mIO, aData));
-
-  return true;
+    new SocketIOSendTask<BluetoothSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
 }
 
 bool
 BluetoothSocket::SendSocketData(const nsACString& aStr)
 {
   if (aStr.Length() > MAX_READ_SIZE) {
     return false;
   }
 
-  nsAutoPtr<UnixSocketRawData> data(
-    new UnixSocketRawData(aStr.BeginReading(), aStr.Length()));
-
-  if (!SendSocketData(data)) {
-    return false;
-  }
-
-  unused << data.forget();
+  SendSocketData(new UnixSocketRawData(aStr.BeginReading(), aStr.Length()));
 
   return true;
 }
 
 void
 BluetoothSocket::CloseSocket()
 {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/bluetooth/bluez/BluetoothSocket.h
+++ b/dom/bluetooth/bluez/BluetoothSocket.h
@@ -40,32 +40,30 @@ public:
   {
     CloseSocket();
   }
 
   virtual void OnConnectSuccess() override;
   virtual void OnConnectError() override;
   virtual void OnDisconnect() override;
   virtual void ReceiveSocketData(
-    nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aMessage) override;
+    nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aBuffer) override;
 
   inline void GetAddress(nsAString& aDeviceAddress)
   {
     GetSocketAddr(aDeviceAddress);
   }
 
   /**
    * Queue data to be sent to the socket on the IO thread. Can only be called on
    * originating thread.
    *
-   * @param aMessage Data to be sent to socket
-   *
-   * @return true if data is queued, false otherwise (i.e. not connected)
+   * @param aBuffer Data to be sent to socket
    */
-  bool SendSocketData(mozilla::ipc::UnixSocketRawData* aMessage);
+  void SendSocketData(mozilla::ipc::UnixSocketIOBuffer* aBuffer) override;
 
   /**
    * Convenience function for sending strings to the socket (common in bluetooth
    * profile usage). Converts to a UnixSocketRawData struct. Can only be called
    * on originating thread.
    *
    * @param aMessage String to be sent to socket
    *
@@ -96,17 +94,17 @@ public:
    * @return true on listen started, false otherwise
    */
   bool ListenSocket(BluetoothUnixSocketConnector* aConnector);
 
   /**
    * Queues the internal representation of socket for deletion. Can be called
    * from main thread.
    */
-  void CloseSocket();
+  void CloseSocket() override;
 
   /**
    * Get the current sockaddr for the socket
    */
   void GetSocketAddr(nsAString& aAddrStr);
 
 private:
   class BluetoothSocketIO;
--- a/ipc/keystore/KeyStore.cpp
+++ b/ipc/keystore/KeyStore.cpp
@@ -805,22 +805,19 @@ KeyStore::StreamSocket::OnConnectError()
 
 void
 KeyStore::StreamSocket::OnDisconnect()
 {
   mKeyStore->OnDisconnect(STREAM_SOCKET);
 }
 
 void
-KeyStore::StreamSocket::ReceiveSocketData(
-  nsAutoPtr<UnixSocketRawData>& aMessage)
+KeyStore::StreamSocket::ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer)
 {
-  nsAutoPtr<UnixSocketBuffer> buffer(aMessage.forget());
-
-  mKeyStore->ReceiveSocketData(buffer);
+  mKeyStore->ReceiveSocketData(aBuffer);
 }
 
 ConnectionOrientedSocketIO*
 KeyStore::StreamSocket::GetIO()
 {
   return PrepareAccept(new KeyStoreConnector());
 }
 
--- a/ipc/keystore/KeyStore.h
+++ b/ipc/keystore/KeyStore.h
@@ -142,17 +142,17 @@ private:
 
     // SocketConsumerBase
     //
 
     void OnConnectSuccess() override;
     void OnConnectError() override;
     void OnDisconnect() override;
 
-    void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage) override;
+    void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer) override;
 
     // ConnectionOrientedSocket
     //
 
     ConnectionOrientedSocketIO* GetIO() override;
 
   private:
     KeyStore* mKeyStore;
--- a/ipc/nfc/Nfc.cpp
+++ b/ipc/nfc/Nfc.cpp
@@ -183,23 +183,22 @@ NfcConsumer::PostToNfcDaemon(const uint8
 
   UnixSocketRawData* raw = new UnixSocketRawData(aData, aSize);
   nsRefPtr<SendNfcSocketDataTask> task = new SendNfcSocketDataTask(this, raw);
   NS_DispatchToMainThread(task);
   return true;
 }
 
 void
-NfcConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aBuffer)
+NfcConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mListener) {
-    nsAutoPtr<mozilla::ipc::UnixSocketBuffer> buffer(aBuffer.forget());
-    mListener->ReceiveSocketData(buffer);
+    mListener->ReceiveSocketData(aBuffer);
   }
 }
 
 void
 NfcConsumer::OnConnectSuccess()
 {
   CHROMIUM_LOG("NFC: %s\n", __FUNCTION__);
 
--- a/ipc/nfc/Nfc.h
+++ b/ipc/nfc/Nfc.h
@@ -67,18 +67,17 @@ public:
   NfcConsumer(NfcSocketListener* aListener);
 
   void Shutdown();
   bool PostToNfcDaemon(const uint8_t* aData, size_t aSize);
 
   ConnectionOrientedSocketIO* GetIO() override;
 
 private:
-  void ReceiveSocketData(
-    nsAutoPtr<UnixSocketRawData>& aBuffer) override;
+  void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer) override;
 
   void OnConnectSuccess() override;
   void OnConnectError() override;
   void OnDisconnect() override;
 
 private:
   NfcSocketListener* mListener;
 };
--- a/ipc/ril/Ril.cpp
+++ b/ipc/ril/Ril.cpp
@@ -364,21 +364,21 @@ RilConsumer::Shutdown()
 
     instance->mShutdown = true;
     instance->Close();
     instance = nullptr;
   }
 }
 
 void
-RilConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
+RilConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  nsRefPtr<DispatchRILEvent> dre(new DispatchRILEvent(mClientId, aMessage.forget()));
+  nsRefPtr<DispatchRILEvent> dre(new DispatchRILEvent(mClientId, aBuffer.forget()));
   mDispatcher->PostTask(dre);
 }
 
 void
 RilConsumer::OnConnectSuccess()
 {
   // Nothing to do here.
   CHROMIUM_LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
--- a/ipc/ril/Ril.h
+++ b/ipc/ril/Ril.h
@@ -22,17 +22,17 @@ public:
   static void Shutdown();
 
   ConnectionOrientedSocketIO* GetIO() override;
 
 private:
   RilConsumer(unsigned long aClientId,
               mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
 
-  void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage) override;
+  void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer) override;
 
   void OnConnectSuccess() override;
   void OnConnectError() override;
   void OnDisconnect() override;
 
   nsRefPtr<mozilla::dom::workers::WorkerCrossThreadDispatcher> mDispatcher;
   unsigned long mClientId;
   nsCString mAddress;
--- a/ipc/unixsocket/SocketBase.cpp
+++ b/ipc/unixsocket/SocketBase.cpp
@@ -278,23 +278,23 @@ SocketConsumerBase::~SocketConsumerBase(
 //
 // SocketIOBase
 //
 
 SocketIOBase::~SocketIOBase()
 { }
 
 void
-SocketIOBase::EnqueueData(UnixSocketRawData* aData)
+SocketIOBase::EnqueueData(UnixSocketIOBuffer* aBuffer)
 {
-  if (!aData->GetSize()) {
-    delete aData; // delete empty data immediately
+  if (!aBuffer->GetSize()) {
+    delete aBuffer; // delete empty data immediately
     return;
   }
-  mOutgoingQ.AppendElement(aData);
+  mOutgoingQ.AppendElement(aBuffer);
 }
 
 bool
 SocketIOBase::HasPendingData() const
 {
   return !mOutgoingQ.IsEmpty();
 }
 
--- a/ipc/unixsocket/SocketBase.h
+++ b/ipc/unixsocket/SocketBase.h
@@ -318,29 +318,27 @@ class SocketConsumerBase : public Socket
 {
 public:
   virtual ~SocketConsumerBase();
 
   /**
    * Function to be called whenever data is received. This is only called on the
    * main thread.
    *
-   * @param aMessage Data received from the socket.
+   * @param aBuffer Data received from the socket.
    */
-  virtual void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage) = 0;
+  virtual void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer) = 0;
 
   /**
    * Queue data to be sent to the socket on the IO thread. Can only be called on
    * originating thread.
    *
-   * @param aMessage Data to be sent to socket
-   *
-   * @return true if data is queued, false otherwise (i.e. not connected)
+   * @param aBuffer Data to be sent to socket
    */
-  virtual bool SendSocketData(UnixSocketRawData* aMessage) = 0;
+  virtual void SendSocketData(UnixSocketIOBuffer* aBuffer) = 0;
 };
 
 //
 // Socket I/O runnables
 //
 
 /* |SocketIORunnable| is a runnable for sending a message from
  * the I/O thread to the main thread.
@@ -419,19 +417,19 @@ private:
 
 /* |SocketReceiveRunnable| transfers data received on the I/O thread
  * to the consumer on the main thread.
  */
 template <typename T>
 class SocketIOReceiveRunnable final : public SocketIORunnable<T>
 {
 public:
-  SocketIOReceiveRunnable(T* aIO, UnixSocketRawData* aData)
-  : SocketIORunnable<T>(aIO)
-  , mData(aData)
+  SocketIOReceiveRunnable(T* aIO, UnixSocketBuffer* aBuffer)
+    : SocketIORunnable<T>(aIO)
+    , mBuffer(aBuffer)
   { }
 
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     T* io = SocketIORunnable<T>::GetIO();
 
@@ -440,23 +438,23 @@ public:
       // Since we've already explicitly closed and the close happened before
       // this, this isn't really an error. Since we've warned, return OK.
       return NS_OK;
     }
 
     SocketConsumerBase* consumer = io->GetConsumer();
     MOZ_ASSERT(consumer);
 
-    consumer->ReceiveSocketData(mData);
+    consumer->ReceiveSocketData(mBuffer);
 
     return NS_OK;
   }
 
 private:
-  nsAutoPtr<UnixSocketRawData> mData;
+  nsAutoPtr<UnixSocketBuffer> mBuffer;
 };
 
 template <typename T>
 class SocketIORequestClosingRunnable final : public SocketIORunnable<T>
 {
 public:
   SocketIORequestClosingRunnable(T* aImpl)
   : SocketIORunnable<T>(aImpl)
@@ -513,17 +511,17 @@ private:
  * perform operations on the I/O thread. It provides methods
  * for the most common read and write scenarios.
  */
 class SocketIOBase
 {
 public:
   virtual ~SocketIOBase();
 
-  void EnqueueData(UnixSocketRawData* aData);
+  void EnqueueData(UnixSocketIOBuffer* aBuffer);
   bool HasPendingData() const;
 
   template <typename T>
   ssize_t ReceiveData(int aFd, T* aIO)
   {
     MOZ_ASSERT(aFd >= 0);
     MOZ_ASSERT(aIO);
 
@@ -558,17 +556,17 @@ public:
 
   template <typename T>
   nsresult SendPendingData(int aFd, T* aIO)
   {
     MOZ_ASSERT(aFd >= 0);
     MOZ_ASSERT(aIO);
 
     while (HasPendingData()) {
-      UnixSocketRawData* outgoing = mOutgoingQ.ElementAt(0);
+      UnixSocketIOBuffer* outgoing = mOutgoingQ.ElementAt(0);
 
       ssize_t res = outgoing->Send(aFd);
       if (res < 0) {
         /* an I/O error occured */
         nsRefPtr<nsRunnable> r = new SocketIORequestClosingRunnable<T>(aIO);
         NS_DispatchToMainThread(r);
         return NS_ERROR_FAILURE;
       } else if (!res && outgoing->GetSize()) {
@@ -588,17 +586,17 @@ protected:
   SocketIOBase(size_t aMaxReadSize);
 
 private:
   const size_t mMaxReadSize;
 
   /**
    * Raw data queue. Must be pushed/popped from I/O thread only.
    */
-  nsTArray<UnixSocketRawData*> mOutgoingQ;
+  nsTArray<UnixSocketIOBuffer*> mOutgoingQ;
 };
 
 //
 // Socket I/O tasks
 //
 
 /* |SocketIOTask| holds a reference to a Socket I/O object. It's
  * supposed to run on the I/O thread.
--- a/ipc/unixsocket/StreamSocket.cpp
+++ b/ipc/unixsocket/StreamSocket.cpp
@@ -2,17 +2,16 @@
 /* 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/. */
 
 #include "StreamSocket.h"
 #include <fcntl.h>
 #include "mozilla/RefPtr.h"
-#include "mozilla/unused.h"
 #include "nsXULAppAPI.h"
 #include "UnixSocketConnector.h"
 
 static const size_t MAX_READ_SIZE = 1 << 16;
 
 namespace mozilla {
 namespace ipc {
 
@@ -68,17 +67,17 @@ public:
   // Task callback methods
   //
 
   /**
    * Connect to a socket
    */
   void Connect();
 
-  void Send(UnixSocketRawData* aData);
+  void Send(UnixSocketIOBuffer* aBuffer);
 
   // I/O callback methods
   //
 
   void OnAccepted(int aFd, const sockaddr_any* aAddr,
                   socklen_t aAddrLen) override;
   void OnConnected() override;
   void OnError(const char* aFunction, int aErrno) override;
@@ -322,17 +321,17 @@ StreamSocketIO::Connect()
 
   // calls OnConnected() on success, or OnError() otherwise
   nsresult rv = UnixSocketWatcher::Connect(
     reinterpret_cast<struct sockaddr*>(&mAddr), mAddrSize);
   NS_WARN_IF(NS_FAILED(rv));
 }
 
 void
-StreamSocketIO::Send(UnixSocketRawData* aData)
+StreamSocketIO::Send(UnixSocketIOBuffer* aData)
 {
   EnqueueData(aData);
   AddWatchers(WRITE_WATCHER, false);
 }
 
 void
 StreamSocketIO::OnAccepted(int aFd,
                            const sockaddr_any* aAddr,
@@ -553,47 +552,36 @@ StreamSocket::StreamSocket()
 : mIO(nullptr)
 { }
 
 StreamSocket::~StreamSocket()
 {
   MOZ_ASSERT(!mIO);
 }
 
-bool
-StreamSocket::SendSocketData(UnixSocketRawData* aData)
+void
+StreamSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  if (!mIO) {
-    return false;
-  }
+  MOZ_ASSERT(mIO);
 
   MOZ_ASSERT(!mIO->IsShutdownOnMainThread());
   XRE_GetIOMessageLoop()->PostTask(
     FROM_HERE,
-    new SocketIOSendTask<StreamSocketIO, UnixSocketRawData>(mIO, aData));
-
-  return true;
+    new SocketIOSendTask<StreamSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
 }
 
 bool
 StreamSocket::SendSocketData(const nsACString& aStr)
 {
   if (aStr.Length() > MAX_READ_SIZE) {
     return false;
   }
 
-  nsAutoPtr<UnixSocketRawData> data(
-    new UnixSocketRawData(aStr.BeginReading(), aStr.Length()));
-
-  if (!SendSocketData(data)) {
-    return false;
-  }
-
-  unused << data.forget();
+  SendSocketData(new UnixSocketRawData(aStr.BeginReading(), aStr.Length()));
 
   return true;
 }
 
 void
 StreamSocket::Close()
 {
   MOZ_ASSERT(NS_IsMainThread());
--- a/ipc/unixsocket/StreamSocket.h
+++ b/ipc/unixsocket/StreamSocket.h
@@ -21,27 +21,27 @@ class StreamSocket : public SocketConsum
 {
 public:
   StreamSocket();
 
   /**
    * Queue data to be sent to the socket on the IO thread. Can only be called on
    * originating thread.
    *
-   * @param aMessage Data to be sent to socket
-   *
-   * @return true if data is queued, false otherwise (i.e. not connected)
+   * @param aBuffer Data to be sent to socket
    */
-  bool SendSocketData(UnixSocketRawData* aMessage);
+  void SendSocketData(UnixSocketIOBuffer* aBuffer);
 
   /**
    * Convenience function for sending strings to the socket (common in bluetooth
    * profile usage). Converts to a UnixSocketRawData struct. Can only be called
    * on originating thread.
    *
+   * TODO: Move this method into Bluetooth module.
+   *
    * @param aMessage String to be sent to socket
    *
    * @return true if data is queued, false otherwise (i.e. not connected)
    */
   bool SendSocketData(const nsACString& aMessage);
 
   /**
    * Starts a task on the socket that will try to connect to a socket in a