Bug 1168806: Use 'consumer thread' in socket interface, r=kmachulis
authorThomas Zimmermann <tdz@users.sourceforge.net>
Tue, 02 Jun 2015 10:01:58 +0200
changeset 246784 fd7c97d41cf392d9e8229e0031c5742d8d586f2b
parent 246783 075e96a57701c252935f7b8d9ecb517da459073f
child 246785 4acadcc14851f20bd493934670a6c0863c131b4c
push id28840
push userkwierso@gmail.com
push dateWed, 03 Jun 2015 01:34:22 +0000
treeherdermozilla-central@b0a507af2b4a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmachulis
bugs1168806
milestone41.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 1168806: Use 'consumer thread' in socket interface, r=kmachulis The socket IPC interfaces still use 'main thread' in a number of places. This patch changes all such interfaces and documentation to speak of 'consumer thread' instead.
dom/bluetooth/bluedroid/BluetoothSocket.cpp
dom/bluetooth/bluedroid/BluetoothSocket.h
dom/bluetooth/bluez/BluetoothSocket.cpp
dom/bluetooth/bluez/BluetoothSocket.h
ipc/bluetooth/BluetoothDaemonConnection.cpp
ipc/bluetooth/BluetoothDaemonConnection.h
ipc/bluetooth/BluetoothDaemonConnectionConsumer.h
ipc/unixsocket/ConnectionOrientedSocket.h
ipc/unixsocket/ListenSocket.cpp
ipc/unixsocket/ListenSocketConsumer.h
ipc/unixsocket/SocketBase.cpp
ipc/unixsocket/SocketBase.h
ipc/unixsocket/StreamSocket.cpp
ipc/unixsocket/StreamSocket.h
ipc/unixsocket/StreamSocketConsumer.h
--- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp
@@ -118,18 +118,18 @@ public:
 
   DataSocket* GetDataSocket()
   {
     return GetBluetoothSocket();
   }
 
   /**
    * Consumer pointer. Non-thread safe RefPtr, so should only be manipulated
-   * directly from main thread. All non-main-thread accesses should happen with
-   * mImpl as container.
+   * directly from consumer thread. All non-consumer-thread accesses should
+   * happen with mImpl as container.
    */
   RefPtr<BluetoothSocket> mConsumer;
 
   // Methods for |DataSocket|
   //
 
   nsresult QueryReceiveBuffer(UnixSocketIOBuffer** aBuffer);
   void ConsumeBuffer();
@@ -138,32 +138,33 @@ public:
   // Methods for |SocketIOBase|
   //
 
   SocketBase* GetSocketBase() override
   {
     return GetDataSocket();
   }
 
-  bool IsShutdownOnMainThread() const override
+  bool IsShutdownOnConsumerThread() const override
   {
     MOZ_ASSERT(IsConsumerThread());
 
     return mConsumer == nullptr;
   }
 
   bool IsShutdownOnIOThread() const override
   {
     return mShuttingDownOnIOThread;
   }
 
-  void ShutdownOnMainThread() override
+  void ShutdownOnConsumerThread() override
   {
     MOZ_ASSERT(IsConsumerThread());
-    MOZ_ASSERT(!IsShutdownOnMainThread());
+    MOZ_ASSERT(!IsShutdownOnConsumerThread());
+
     mConsumer = nullptr;
   }
 
   void ShutdownOnIOThread() override
   {
     MOZ_ASSERT(!IsConsumerThread());
     MOZ_ASSERT(!mShuttingDownOnIOThread);
 
@@ -387,17 +388,17 @@ public:
 
   void Accept(int aFd, const nsAString& aBdAddress,
               int aConnectionStatus) override
   {
     MOZ_ASSERT(mImpl->IsConsumerThread());
 
     mozilla::ScopedClose fd(aFd); // Close received socket fd on error
 
-    if (mImpl->IsShutdownOnMainThread()) {
+    if (mImpl->IsShutdownOnConsumerThread()) {
       BT_LOGD("mConsumer is null, aborting receive!");
       return;
     }
 
     if (aConnectionStatus != 0) {
       mImpl->mConsumer->NotifyError();
       return;
     }
@@ -407,17 +408,17 @@ public:
                                  new AcceptTask(mImpl, fd.forget()));
   }
 
   void OnError(BluetoothStatus aStatus) override
   {
     MOZ_ASSERT(mImpl->IsConsumerThread());
     BT_LOGR("BluetoothSocketInterface::Accept failed: %d", (int)aStatus);
 
-    if (!mImpl->IsShutdownOnMainThread()) {
+    if (!mImpl->IsShutdownOnConsumerThread()) {
       // Instead of NotifyError(), call NotifyDisconnect() to trigger
       // BluetoothOppManager::OnSocketDisconnect() as
       // DroidSocketImpl::OnFileCanReadWithoutBlocking() in Firefox OS 2.0 in
       // order to keep the same behavior and reduce regression risk.
       mImpl->mConsumer->NotifyDisconnect();
     }
   }
 
@@ -529,34 +530,34 @@ DroidSocketImpl::QueryReceiveBuffer(
   }
   *aBuffer = mBuffer.get();
 
   return NS_OK;
 }
 
 /**
  * |ReceiveRunnable| transfers data received on the I/O thread
- * to an instance of |BluetoothSocket| on the main thread.
+ * to an instance of |BluetoothSocket| on the consumer thread.
  */
 class DroidSocketImpl::ReceiveRunnable final
   : public SocketIORunnable<DroidSocketImpl>
 {
 public:
   ReceiveRunnable(DroidSocketImpl* aIO, UnixSocketBuffer* aBuffer)
     : SocketIORunnable<DroidSocketImpl>(aIO)
     , mBuffer(aBuffer)
   { }
 
   NS_IMETHOD Run() override
   {
     DroidSocketImpl* io = SocketIORunnable<DroidSocketImpl>::GetIO();
 
     MOZ_ASSERT(io->IsConsumerThread());
 
-    if (NS_WARN_IF(io->IsShutdownOnMainThread())) {
+    if (NS_WARN_IF(io->IsShutdownOnConsumerThread())) {
       // Since we've already explicitly closed and the close
       // happened before this, this isn't really an error.
       return NS_OK;
     }
 
     BluetoothSocket* bluetoothSocket = io->GetBluetoothSocket();
     MOZ_ASSERT(bluetoothSocket);
 
@@ -606,17 +607,17 @@ public:
     MOZ_ASSERT(mImpl);
   }
 
   void Connect(int aFd, const nsAString& aBdAddress,
                int aConnectionStatus) override
   {
     MOZ_ASSERT(mImpl->IsConsumerThread());
 
-    if (mImpl->IsShutdownOnMainThread()) {
+    if (mImpl->IsShutdownOnConsumerThread()) {
       BT_LOGD("mConsumer is null, aborting send!");
       return;
     }
 
     if (aConnectionStatus != 0) {
       mImpl->mConsumer->NotifyError();
       return;
     }
@@ -626,17 +627,17 @@ public:
                                  new SocketConnectTask(mImpl, aFd));
   }
 
   void OnError(BluetoothStatus aStatus) override
   {
     MOZ_ASSERT(mImpl->IsConsumerThread());
     BT_WARNING("Connect failed: %d", (int)aStatus);
 
-    if (!mImpl->IsShutdownOnMainThread()) {
+    if (!mImpl->IsShutdownOnConsumerThread()) {
       // Instead of NotifyError(), call NotifyDisconnect() to trigger
       // BluetoothOppManager::OnSocketDisconnect() as
       // DroidSocketImpl::OnFileCanReadWithoutBlocking() in Firefox OS 2.0 in
       // order to keep the same behavior and reduce regression risk.
       mImpl->mConsumer->NotifyDisconnect();
     }
   }
 
@@ -767,17 +768,17 @@ BluetoothSocket::ReceiveSocketData(nsAut
 
 // |DataSocket|
 
 void
 BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
 {
   MOZ_ASSERT(mImpl);
   MOZ_ASSERT(mImpl->IsConsumerThread());
-  MOZ_ASSERT(!mImpl->IsShutdownOnMainThread());
+  MOZ_ASSERT(!mImpl->IsShutdownOnConsumerThread());
 
   mImpl->GetIOLoop()->PostTask(
     FROM_HERE,
     new SocketIOSendTask<DroidSocketImpl, UnixSocketIOBuffer>(mImpl, aBuffer));
 }
 
 // |SocketBase|
 
@@ -795,17 +796,17 @@ BluetoothSocket::Close()
   // Stop any watching |SocketMessageWatcher|
   if (mCurrentRes) {
     sBluetoothSocketInterface->Close(mCurrentRes);
   }
 
   // From this point on, we consider mImpl as being deleted.
   // We sever the relationship here so any future calls to listen or connect
   // will create a new implementation.
-  mImpl->ShutdownOnMainThread();
+  mImpl->ShutdownOnConsumerThread();
   mImpl->GetIOLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mImpl));
   mImpl = nullptr;
 
   NotifyDisconnect();
 }
 
 void
 BluetoothSocket::OnConnectSuccess()
--- a/dom/bluetooth/bluedroid/BluetoothSocket.h
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.h
@@ -49,17 +49,17 @@ public:
   nsresult Listen(const nsAString& aServiceName,
                   const BluetoothUuid& aServiceUuid,
                   BluetoothSocketType aType,
                   int aChannel,
                   bool aAuth, bool aEncrypt);
 
   /**
    * Method to be called whenever data is received. This is only called on the
-   * main thread.
+   * consumer thread.
    *
    * @param aBuffer Data received from the socket.
    */
   void ReceiveSocketData(nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aBuffer);
 
   inline void GetAddress(nsAString& aDeviceAddress)
   {
     aDeviceAddress = mDeviceAddress;
--- a/dom/bluetooth/bluez/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluez/BluetoothSocket.cpp
@@ -78,31 +78,31 @@ public:
   void ConsumeBuffer();
   void DiscardBuffer();
 
   // Methods for |SocketIOBase|
   //
 
   SocketBase* GetSocketBase() override;
 
-  bool IsShutdownOnMainThread() const override;
+  bool IsShutdownOnConsumerThread() const override;
   bool IsShutdownOnIOThread() const override;
 
-  void ShutdownOnMainThread() override;
+  void ShutdownOnConsumerThread() override;
   void ShutdownOnIOThread() override;
 
 private:
   class ReceiveRunnable;
 
   void FireSocketError();
 
   /**
    * Consumer pointer. Non-thread safe RefPtr, so should only be manipulated
-   * directly from main thread. All non-main-thread accesses should happen with
-   * mIO as container.
+   * directly from consumer thread. All non-consumer-thread accesses should
+   * happen with mIO as container.
    */
   RefPtr<BluetoothSocket> mConsumer;
 
   /**
    * Connector object used to create the connection we are currently using.
    */
   nsAutoPtr<UnixSocketConnector> mConnector;
 
@@ -117,17 +117,18 @@ private:
   socklen_t mAddressLength;
 
   /**
    * Address structure of the socket currently in use
    */
   struct sockaddr_storage mAddress;
 
   /**
-   * Task member for delayed connect task. Should only be access on main thread.
+   * Task member for delayed connect task. Should only be access on consumer
+   * thread.
    */
   CancelableTask* mDelayedConnectTask;
 
   /**
    * I/O buffer for received data
    */
   nsAutoPtr<UnixSocketRawData> mBuffer;
 };
@@ -147,17 +148,17 @@ BluetoothSocket::BluetoothSocketIO::Blue
 {
   MOZ_ASSERT(mConsumer);
   MOZ_ASSERT(mConnector);
 }
 
 BluetoothSocket::BluetoothSocketIO::~BluetoothSocketIO()
 {
   MOZ_ASSERT(IsConsumerThread());
-  MOZ_ASSERT(IsShutdownOnMainThread());
+  MOZ_ASSERT(IsShutdownOnConsumerThread());
 }
 
 void
 BluetoothSocket::BluetoothSocketIO::GetSocketAddr(nsAString& aAddrStr) const
 {
   if (!mConnector) {
     NS_WARNING("No connector to get socket address from!");
     aAddrStr.Truncate();
@@ -375,17 +376,17 @@ BluetoothSocket::BluetoothSocketIO::OnSo
 void
 BluetoothSocket::BluetoothSocketIO::FireSocketError()
 {
   MOZ_ASSERT(MessageLoopForIO::current() == GetIOLoop());
 
   // Clean up watchers, statuses, fds
   Close();
 
-  // Tell the main thread we've errored
+  // Tell the consumer thread we've errored
   GetConsumerThread()->Dispatch(
     new SocketIOEventRunnable(this, SocketIOEventRunnable::CONNECT_ERROR),
     NS_DISPATCH_NORMAL);
 
 }
 
 // |DataSocketIO|
 
@@ -400,34 +401,34 @@ BluetoothSocket::BluetoothSocketIO::Quer
   }
   *aBuffer = mBuffer.get();
 
   return NS_OK;
 }
 
 /**
  * |ReceiveRunnable| transfers data received on the I/O thread
- * to an instance of |BluetoothSocket| on the main thread.
+ * to an instance of |BluetoothSocket| on the consumer thread.
  */
 class BluetoothSocket::BluetoothSocketIO::ReceiveRunnable final
   : public SocketIORunnable<BluetoothSocketIO>
 {
 public:
   ReceiveRunnable(BluetoothSocketIO* aIO, UnixSocketBuffer* aBuffer)
     : SocketIORunnable<BluetoothSocketIO>(aIO)
     , mBuffer(aBuffer)
   { }
 
   NS_IMETHOD Run() override
   {
     BluetoothSocketIO* io = SocketIORunnable<BluetoothSocketIO>::GetIO();
 
     MOZ_ASSERT(io->IsConsumerThread());
 
-    if (NS_WARN_IF(io->IsShutdownOnMainThread())) {
+    if (NS_WARN_IF(io->IsShutdownOnConsumerThread())) {
       // Since we've already explicitly closed and the close
       // happened before this, this isn't really an error.
       return NS_OK;
     }
 
     BluetoothSocket* bluetoothSocket = io->GetBluetoothSocket();
     MOZ_ASSERT(bluetoothSocket);
 
@@ -457,28 +458,28 @@ BluetoothSocket::BluetoothSocketIO::Disc
 
 SocketBase*
 BluetoothSocket::BluetoothSocketIO::GetSocketBase()
 {
   return GetDataSocket();
 }
 
 bool
-BluetoothSocket::BluetoothSocketIO::IsShutdownOnMainThread() const
+BluetoothSocket::BluetoothSocketIO::IsShutdownOnConsumerThread() const
 {
   MOZ_ASSERT(IsConsumerThread());
 
   return mConsumer == nullptr;
 }
 
 void
-BluetoothSocket::BluetoothSocketIO::ShutdownOnMainThread()
+BluetoothSocket::BluetoothSocketIO::ShutdownOnConsumerThread()
 {
   MOZ_ASSERT(IsConsumerThread());
-  MOZ_ASSERT(!IsShutdownOnMainThread());
+  MOZ_ASSERT(!IsShutdownOnConsumerThread());
 
   mConsumer = nullptr;
 }
 
 bool
 BluetoothSocket::BluetoothSocketIO::IsShutdownOnIOThread() const
 {
   return mShuttingDownOnIOThread;
@@ -546,17 +547,17 @@ public:
   {
     MOZ_ASSERT(GetIO()->IsConsumerThread());
 
     if (IsCanceled()) {
       return;
     }
 
     BluetoothSocketIO* io = GetIO();
-    if (io->IsShutdownOnMainThread()) {
+    if (io->IsShutdownOnConsumerThread()) {
       return;
     }
 
     io->ClearDelayedConnectTask();
     io->GetIOLoop()->PostTask(FROM_HERE, new ConnectTask(io));
   }
 };
 
@@ -725,17 +726,17 @@ BluetoothSocket::GetAddress(nsAString& a
 
 // |DataSocket|
 
 void
 BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
 {
   MOZ_ASSERT(mIO);
   MOZ_ASSERT(mIO->IsConsumerThread());
-  MOZ_ASSERT(!mIO->IsShutdownOnMainThread());
+  MOZ_ASSERT(!mIO->IsShutdownOnConsumerThread());
 
   mIO->GetIOLoop()->PostTask(
     FROM_HERE,
     new SocketIOSendTask<BluetoothSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
 }
 
 // |SocketBase|
 
@@ -748,17 +749,17 @@ BluetoothSocket::Close()
 
   MOZ_ASSERT(mIO->IsConsumerThread());
 
   mIO->CancelDelayedConnectTask();
 
   // From this point on, we consider mIO as being deleted.
   // We sever the relationship here so any future calls to listen or connect
   // will create a new implementation.
-  mIO->ShutdownOnMainThread();
+  mIO->ShutdownOnConsumerThread();
   mIO->GetIOLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
   mIO = nullptr;
 
   NotifyDisconnect();
 }
 
 void
 BluetoothSocket::OnConnectSuccess()
--- a/dom/bluetooth/bluez/BluetoothSocket.h
+++ b/dom/bluetooth/bluez/BluetoothSocket.h
@@ -38,17 +38,17 @@ public:
   nsresult Listen(const nsAString& aServiceName,
                   const BluetoothUuid& aServiceUuid,
                   BluetoothSocketType aType,
                   int aChannel,
                   bool aAuth, bool aEncrypt);
 
   /**
    * Method to be called whenever data is received. This is only called on the
-   * main thread.
+   * consumer thread.
    *
    * @param aBuffer Data received from the socket.
    */
   void ReceiveSocketData(nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aBuffer);
 
   /**
    * Convenience function for sending strings to the socket (common in bluetooth
    * profile usage). Converts to a UnixSocketRawData struct. Can only be called
--- a/ipc/bluetooth/BluetoothDaemonConnection.cpp
+++ b/ipc/bluetooth/BluetoothDaemonConnection.cpp
@@ -237,20 +237,20 @@ public:
   void ConsumeBuffer() override;
   void DiscardBuffer() override;
 
   // Methods for |SocketIOBase|
   //
 
   SocketBase* GetSocketBase() override;
 
-  bool IsShutdownOnMainThread() const override;
+  bool IsShutdownOnConsumerThread() const override;
   bool IsShutdownOnIOThread() const override;
 
-  void ShutdownOnMainThread() override;
+  void ShutdownOnConsumerThread() override;
   void ShutdownOnIOThread() override;
 
 private:
   BluetoothDaemonConnection* mConnection;
   BluetoothDaemonPDUConsumer* mConsumer;
   nsAutoPtr<BluetoothDaemonPDU> mPDU;
   bool mShuttingDownOnIOThread;
 };
@@ -327,17 +327,17 @@ BluetoothDaemonConnectionIO::OnError(con
 {
   MOZ_ASSERT(MessageLoopForIO::current() == GetIOLoop());
 
   UnixFdWatcher::OnError(aFunction, aErrno);
 
   // Clean up watchers, status, fd
   Close();
 
-  // Tell the main thread we've errored
+  // Tell the consumer thread we've errored
   GetConsumerThread()->Dispatch(
     new SocketIOEventRunnable(this, SocketIOEventRunnable::CONNECT_ERROR),
     NS_DISPATCH_NORMAL);
 }
 
 // |ConnectionOrientedSocketIO|
 
 nsresult
@@ -398,34 +398,34 @@ BluetoothDaemonConnectionIO::DiscardBuff
 
 SocketBase*
 BluetoothDaemonConnectionIO::GetSocketBase()
 {
   return mConnection;
 }
 
 bool
-BluetoothDaemonConnectionIO::IsShutdownOnMainThread() const
+BluetoothDaemonConnectionIO::IsShutdownOnConsumerThread() const
 {
   MOZ_ASSERT(IsConsumerThread());
 
   return mConnection == nullptr;
 }
 
 bool
 BluetoothDaemonConnectionIO::IsShutdownOnIOThread() const
 {
   return mShuttingDownOnIOThread;
 }
 
 void
-BluetoothDaemonConnectionIO::ShutdownOnMainThread()
+BluetoothDaemonConnectionIO::ShutdownOnConsumerThread()
 {
   MOZ_ASSERT(IsConsumerThread());
-  MOZ_ASSERT(!IsShutdownOnMainThread());
+  MOZ_ASSERT(!IsShutdownOnConsumerThread());
 
   mConnection = nullptr;
 }
 
 void
 BluetoothDaemonConnectionIO::ShutdownOnIOThread()
 {
   MOZ_ASSERT(!IsConsumerThread());
@@ -500,17 +500,17 @@ BluetoothDaemonConnection::Close()
 {
   if (!mIO) {
     CHROMIUM_LOG("Bluetooth daemon already disconnected!");
     return;
   }
 
   MOZ_ASSERT(mIO->IsConsumerThread());
 
-  mIO->ShutdownOnMainThread();
+  mIO->ShutdownOnConsumerThread();
   mIO->GetIOLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
   mIO = nullptr;
 
   NotifyDisconnect();
 }
 
 void
 BluetoothDaemonConnection::OnConnectSuccess()
--- a/ipc/bluetooth/BluetoothDaemonConnection.h
+++ b/ipc/bluetooth/BluetoothDaemonConnection.h
@@ -89,17 +89,17 @@ private:
   BluetoothDaemonPDUConsumer* mConsumer;
   void* mUserData;
   ScopedClose mReceivedFd;
 };
 
 /*
  * |BluetoothDaemonPDUConsumer| processes incoming PDUs from the Bluetooth
  * daemon. Please note that its method |Handle| runs on a different than the
- * main thread.
+ * consumer thread.
  */
 class BluetoothDaemonPDUConsumer
 {
 public:
   virtual ~BluetoothDaemonPDUConsumer();
 
   virtual void Handle(BluetoothDaemonPDU& aPDU) = 0;
   virtual void StoreUserData(const BluetoothDaemonPDU& aPDU) = 0;
--- a/ipc/bluetooth/BluetoothDaemonConnectionConsumer.h
+++ b/ipc/bluetooth/BluetoothDaemonConnectionConsumer.h
@@ -17,31 +17,31 @@ namespace ipc {
 
 /*
  * |BluetoothDaemonConnectionConsumer| handles socket events.
  */
 class BluetoothDaemonConnectionConsumer
 {
 public:
   /**
-   * Callback for socket success. Main-thread only.
+   * 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;
 
   /**
-   * Callback for socket errors. Main-thread only.
+   * Callback for socket errors. Consumer-thread only.
    *
    * @param aIndex The index that has been given to the stream socket.
    */
   virtual void OnConnectError(int aIndex) = 0;
 
   /**
-   * Callback for socket disconnect. Main-thread only.
+   * Callback for socket disconnect. Consumer-thread only.
    *
    * @param aIndex The index that has been given to the stream socket.
    */
   virtual void OnDisconnect(int aIndex) = 0;
 
 protected:
   BluetoothDaemonConnectionConsumer();
   virtual ~BluetoothDaemonConnectionConsumer();
--- a/ipc/unixsocket/ConnectionOrientedSocket.h
+++ b/ipc/unixsocket/ConnectionOrientedSocket.h
@@ -14,17 +14,17 @@ class MessageLoop;
 
 namespace mozilla {
 namespace ipc {
 
 class UnixSocketConnector;
 
 /*
  * |ConnectionOrientedSocketIO| and |ConnectionOrientedSocket| define
- * interfaces for implementing stream sockets on I/O and main thread.
+ * interfaces for implementing stream sockets on I/O and consumer thread.
  * |ListenSocket| uses these classes to handle accepted sockets.
  */
 
 class ConnectionOrientedSocketIO : public DataSocketIO
 {
 public:
   ConnectionOrientedSocketIO(nsIThread* aConsumerThread);
   virtual ~ConnectionOrientedSocketIO();
@@ -34,17 +34,17 @@ public:
                           socklen_t aAddressLength) = 0;
 };
 
 class ConnectionOrientedSocket : public DataSocket
 {
 public:
   /**
    * Prepares an instance of |ConnectionOrientedSocket| in DISCONNECTED
-   * state for accepting a connection. Main-thread only.
+   * state for accepting a connection. Consumer-thread only.
    *
    * @param aConnector The new connector object, owned by the
    *                   connection-oriented socket.
    * @param aConsumerThread The socket's consumer thread.
    * @param aIOLoop The socket's I/O thread.
    * @param[out] aIO, Returns an instance of |ConnectionOrientedSocketIO|.
    * @return NS_OK on success, or an XPCOM error code otherwise.
    */
--- a/ipc/unixsocket/ListenSocket.cpp
+++ b/ipc/unixsocket/ListenSocket.cpp
@@ -51,29 +51,29 @@ public:
   void OnListening() override;
   void OnSocketCanAcceptWithoutBlocking() override;
 
   // Methods for |SocketIOBase|
   //
 
   SocketBase* GetSocketBase() override;
 
-  bool IsShutdownOnMainThread() const override;
+  bool IsShutdownOnConsumerThread() const override;
   bool IsShutdownOnIOThread() const override;
 
-  void ShutdownOnMainThread() override;
+  void ShutdownOnConsumerThread() override;
   void ShutdownOnIOThread() override;
 
 private:
   void FireSocketError();
 
   /**
    * Consumer pointer. Non-thread safe RefPtr, so should only be manipulated
-   * directly from main thread. All non-main-thread accesses should happen with
-   * mIO as container.
+   * directly from consumer thread. All non-consumer-thread accesses should
+   * happen with mIO as container.
    */
   RefPtr<ListenSocket> mListenSocket;
 
   /**
    * Connector object used to create the connection we are currently using.
    */
   nsAutoPtr<UnixSocketConnector> mConnector;
 
@@ -109,17 +109,17 @@ ListenSocketIO::ListenSocketIO(nsIThread
 {
   MOZ_ASSERT(mListenSocket);
   MOZ_ASSERT(mConnector);
 }
 
 ListenSocketIO::~ListenSocketIO()
 {
   MOZ_ASSERT(IsConsumerThread());
-  MOZ_ASSERT(IsShutdownOnMainThread());
+  MOZ_ASSERT(IsShutdownOnConsumerThread());
 }
 
 UnixSocketConnector*
 ListenSocketIO::GetConnector() const
 {
   return mConnector;
 }
 
@@ -185,17 +185,17 @@ ListenSocketIO::OnError(const char* aFun
 void
 ListenSocketIO::FireSocketError()
 {
   MOZ_ASSERT(MessageLoopForIO::current() == GetIOLoop());
 
   // Clean up watchers, statuses, fds
   Close();
 
-  // Tell the main thread we've errored
+  // Tell the consumer thread we've errored
   GetConsumerThread()->Dispatch(
     new SocketIOEventRunnable(this, SocketIOEventRunnable::CONNECT_ERROR),
     NS_DISPATCH_NORMAL);
 }
 
 void
 ListenSocketIO::OnSocketCanAcceptWithoutBlocking()
 {
@@ -227,34 +227,34 @@ ListenSocketIO::OnSocketCanAcceptWithout
 
 SocketBase*
 ListenSocketIO::GetSocketBase()
 {
   return mListenSocket.get();
 }
 
 bool
-ListenSocketIO::IsShutdownOnMainThread() const
+ListenSocketIO::IsShutdownOnConsumerThread() const
 {
   MOZ_ASSERT(IsConsumerThread());
 
   return mListenSocket == nullptr;
 }
 
 bool
 ListenSocketIO::IsShutdownOnIOThread() const
 {
   return mShuttingDownOnIOThread;
 }
 
 void
-ListenSocketIO::ShutdownOnMainThread()
+ListenSocketIO::ShutdownOnConsumerThread()
 {
   MOZ_ASSERT(IsConsumerThread());
-  MOZ_ASSERT(!IsShutdownOnMainThread());
+  MOZ_ASSERT(!IsShutdownOnConsumerThread());
 
   mListenSocket = nullptr;
 }
 
 void
 ListenSocketIO::ShutdownOnIOThread()
 {
   MOZ_ASSERT(!IsConsumerThread());
@@ -386,17 +386,17 @@ ListenSocket::Close()
     return;
   }
 
   MOZ_ASSERT(mIO->IsConsumerThread());
 
   // From this point on, we consider mIO as being deleted. We sever
   // the relationship here so any future calls to listen or connect
   // will create a new implementation.
-  mIO->ShutdownOnMainThread();
+  mIO->ShutdownOnConsumerThread();
   mIO->GetIOLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
   mIO = nullptr;
 
   NotifyDisconnect();
 }
 
 void
 ListenSocket::OnConnectSuccess()
--- a/ipc/unixsocket/ListenSocketConsumer.h
+++ b/ipc/unixsocket/ListenSocketConsumer.h
@@ -14,31 +14,31 @@ namespace ipc {
  * |ListenSocketConsumer| handles socket events.
  */
 class ListenSocketConsumer
 {
 public:
   virtual ~ListenSocketConsumer();
 
   /**
-   * Callback for socket success. Main-thread only.
+   * Callback for socket success. Consumer-thread only.
    *
    * @param aIndex The index that has been given to the listening socket.
    */
   virtual void OnConnectSuccess(int aIndex) = 0;
 
   /**
-   * Callback for socket errors. Main-thread only.
+   * Callback for socket errors. Consumer-thread only.
    *
    * @param aIndex The index that has been given to the listening socket.
    */
   virtual void OnConnectError(int aIndex) = 0;
 
   /**
-   * Callback for socket disconnect. Main-thread only.
+   * Callback for socket disconnect. Consumer-thread only.
    *
    * @param aIndex The index that has been given to the listeing socket.
    */
   virtual void OnDisconnect(int aIndex) = 0;
 };
 
 }
 }
--- a/ipc/unixsocket/SocketBase.cpp
+++ b/ipc/unixsocket/SocketBase.cpp
@@ -297,17 +297,17 @@ SocketIOEventRunnable::SocketIOEventRunn
 
 NS_METHOD
 SocketIOEventRunnable::Run()
 {
   SocketIOBase* io = SocketIORunnable<SocketIOBase>::GetIO();
 
   MOZ_ASSERT(io->IsConsumerThread());
 
-  if (NS_WARN_IF(io->IsShutdownOnMainThread())) {
+  if (NS_WARN_IF(io->IsShutdownOnConsumerThread())) {
     // Since we've already explicitly closed and the close
     // happened before this, this isn't really an error.
     return NS_OK;
   }
 
   SocketBase* socketBase = io->GetSocketBase();
   MOZ_ASSERT(socketBase);
 
@@ -333,17 +333,17 @@ SocketIORequestClosingRunnable::SocketIO
 
 NS_METHOD
 SocketIORequestClosingRunnable::Run()
 {
   SocketIOBase* io = SocketIORunnable<SocketIOBase>::GetIO();
 
   MOZ_ASSERT(io->IsConsumerThread());
 
-  if (NS_WARN_IF(io->IsShutdownOnMainThread())) {
+  if (NS_WARN_IF(io->IsShutdownOnConsumerThread())) {
     // Since we've already explicitly closed and the close
     // happened before this, this isn't really an error.
     return NS_OK;
   }
 
   SocketBase* socketBase = io->GetSocketBase();
   MOZ_ASSERT(socketBase);
 
@@ -383,17 +383,17 @@ SocketIOShutdownTask::Run()
   SocketIOBase* io = SocketIOTask<SocketIOBase>::GetIO();
 
   MOZ_ASSERT(!io->IsConsumerThread());
   MOZ_ASSERT(!io->IsShutdownOnIOThread());
 
   // At this point, there should be no new events on the I/O thread
   // after this one with the possible exception of an accept task,
   // which ShutdownOnIOThread will cancel for us. We are now fully
-  // shut down, so we can send a message to the main thread to delete
-  // |io| safely knowing that it's not reference any longer.
+  // shut down, so we can send a message to the consumer thread to
+  // delete |io| safely knowing that it's not reference any longer.
   io->ShutdownOnIOThread();
   io->GetConsumerThread()->Dispatch(new SocketIODeleteInstanceRunnable(io),
                                     NS_DISPATCH_NORMAL);
 }
 
 }
 }
--- a/ipc/unixsocket/SocketBase.h
+++ b/ipc/unixsocket/SocketBase.h
@@ -251,33 +251,33 @@ public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SocketBase)
 
   SocketConnectionStatus GetConnectionStatus() const;
 
   int GetSuggestedConnectDelayMs() const;
 
   /**
    * Queues the internal representation of socket for deletion. Can be called
-   * from main thread.
+   * from consumer thread.
    */
   virtual void Close() = 0;
 
   /**
    * Callback for socket connect/accept success. Called after connect/accept has
-   * finished. Will be run on main thread, before any reads take place.
+   * finished. Will be run on consumer thread before any reads take place.
    */
   virtual void OnConnectSuccess() = 0;
 
   /**
-   * Callback for socket connect/accept error. Will be run on main thread.
+   * Callback for socket connect/accept error. Will be run on consumer thread.
    */
   virtual void OnConnectError() = 0;
 
   /**
-   * Callback for socket disconnect. Will be run on main thread.
+   * Callback for socket disconnect. Will be run on consumer thread.
    */
   virtual void OnDisconnect() = 0;
 
   /**
    * Called by implementation to notify consumer of success.
    */
   void NotifySuccess();
 
@@ -335,28 +335,28 @@ public:
   virtual bool IsShutdownOnIOThread() const = 0;
 
   /**
    * Implemented by socket I/O classes to signal that socket class has
    * been shut down.
    *
    * @return True if the socket class has been shut down, false otherwise.
    */
-  virtual bool IsShutdownOnMainThread() const = 0;
+  virtual bool IsShutdownOnConsumerThread() const = 0;
 
   /**
    * Signals to the socket I/O classes that it has been shut down.
    */
   virtual void ShutdownOnIOThread() = 0;
 
   /**
    * Signals to the socket I/O classes that the socket class has been
    * shut down.
    */
-  virtual void ShutdownOnMainThread() = 0;
+  virtual void ShutdownOnConsumerThread() = 0;
 
   /**
    * Returns the consumer thread.
    *
    * @return A pointer to the consumer thread.
    */
   nsIThread* GetConsumerThread() const;
 
@@ -373,17 +373,17 @@ private:
   nsCOMPtr<nsIThread> mConsumerThread;
 };
 
 //
 // Socket I/O runnables
 //
 
 /* |SocketIORunnable| is a runnable for sending a message from
- * the I/O thread to the main thread.
+ * the I/O thread to the consumer thread.
  */
 template <typename T>
 class SocketIORunnable : public nsRunnable
 {
 public:
   virtual ~SocketIORunnable()
   { }
 
@@ -400,17 +400,17 @@ protected:
   }
 
 private:
   T* mIO;
 };
 
 /**
  * |SocketIOEventRunnable| reports the connection state on the
- * I/O thread back to the main thread.
+ * I/O thread back to the consumer thread.
  */
 class SocketIOEventRunnable final : public SocketIORunnable<SocketIOBase>
 {
 public:
   enum SocketEvent {
     CONNECT_SUCCESS,
     CONNECT_ERROR,
     DISCONNECT
@@ -421,29 +421,29 @@ public:
   NS_IMETHOD Run() override;
 
 private:
   SocketEvent mEvent;
 };
 
 /**
  * |SocketIORequestClosingRunnable| closes an instance of |SocketBase|
- * to the main thread.
+ * to the consumer thread.
  */
 class SocketIORequestClosingRunnable final
   : public SocketIORunnable<SocketIOBase>
 {
 public:
   SocketIORequestClosingRunnable(SocketIOBase* aIO);
 
   NS_IMETHOD Run() override;
 };
 
 /**
- * |SocketIODeleteInstanceRunnable| deletes an object on the main thread.
+ * |SocketIODeleteInstanceRunnable| deletes an object on the consumer thread.
  */
 class SocketIODeleteInstanceRunnable final : public nsRunnable
 {
 public:
   SocketIODeleteInstanceRunnable(SocketIOBase* aIO);
 
   NS_IMETHOD Run() override;
 
@@ -488,17 +488,17 @@ protected:
   }
 
 private:
   Tio* mIO;
 };
 
 /**
  * |SocketIOShutdownTask| signals shutdown to the socket I/O class on
- * the I/O thread and sends it to the main thread for destruction.
+ * the I/O thread and sends it to the consumer thread for destruction.
  */
 class SocketIOShutdownTask final : public SocketIOTask<SocketIOBase>
 {
 public:
   SocketIOShutdownTask(SocketIOBase* aIO);
 
   void Run() override;
 };
--- a/ipc/unixsocket/StreamSocket.cpp
+++ b/ipc/unixsocket/StreamSocket.cpp
@@ -83,29 +83,29 @@ public:
   void ConsumeBuffer() override;
   void DiscardBuffer() override;
 
   // Methods for |SocketIOBase|
   //
 
   SocketBase* GetSocketBase() override;
 
-  bool IsShutdownOnMainThread() const override;
+  bool IsShutdownOnConsumerThread() const override;
   bool IsShutdownOnIOThread() const override;
 
-  void ShutdownOnMainThread() override;
+  void ShutdownOnConsumerThread() override;
   void ShutdownOnIOThread() override;
 
 private:
   void FireSocketError();
 
   /**
    * Consumer pointer. Non-thread safe RefPtr, so should only be manipulated
-   * directly from main thread. All non-main-thread accesses should happen with
-   * mIO as container.
+   * directly from consumer thread. All non-consumer-thread accesses should
+   * happen with mIO as container.
    */
   RefPtr<StreamSocket> mStreamSocket;
 
   /**
    * Connector object used to create the connection we are currently using.
    */
   nsAutoPtr<UnixSocketConnector> mConnector;
 
@@ -120,17 +120,18 @@ private:
   socklen_t mAddressLength;
 
   /**
    * Address structure of the socket currently in use
    */
   struct sockaddr_storage mAddress;
 
   /**
-   * Task member for delayed connect task. Should only be access on main thread.
+   * Task member for delayed connect task. Should only be access on consumer
+   * thread.
    */
   CancelableTask* mDelayedConnectTask;
 
   /**
    * I/O buffer for received data
    */
   nsAutoPtr<UnixSocketRawData> mBuffer;
 };
@@ -166,17 +167,17 @@ StreamSocketIO::StreamSocketIO(nsIThread
 {
   MOZ_ASSERT(mStreamSocket);
   MOZ_ASSERT(mConnector);
 }
 
 StreamSocketIO::~StreamSocketIO()
 {
   MOZ_ASSERT(IsConsumerThread());
-  MOZ_ASSERT(IsShutdownOnMainThread());
+  MOZ_ASSERT(IsShutdownOnConsumerThread());
 }
 
 StreamSocket*
 StreamSocketIO::GetStreamSocket()
 {
   return mStreamSocket.get();
 }
 
@@ -314,17 +315,17 @@ StreamSocketIO::OnSocketCanSendWithoutBl
 void
 StreamSocketIO::FireSocketError()
 {
   MOZ_ASSERT(MessageLoopForIO::current() == GetIOLoop());
 
   // Clean up watchers, statuses, fds
   Close();
 
-  // Tell the main thread we've errored
+  // Tell the consumer thread we've errored
   GetConsumerThread()->Dispatch(
     new SocketIOEventRunnable(this, SocketIOEventRunnable::CONNECT_ERROR),
     NS_DISPATCH_NORMAL);
 }
 
 // |ConnectionOrientedSocketIO|
 
 nsresult
@@ -366,34 +367,34 @@ StreamSocketIO::QueryReceiveBuffer(UnixS
   }
   *aBuffer = mBuffer.get();
 
   return NS_OK;
 }
 
 /**
  * |ReceiveRunnable| transfers data received on the I/O thread
- * to an instance of |StreamSocket| on the main thread.
+ * to an instance of |StreamSocket| on the consumer thread.
  */
 class StreamSocketIO::ReceiveRunnable final
   : public SocketIORunnable<StreamSocketIO>
 {
 public:
   ReceiveRunnable(StreamSocketIO* aIO, UnixSocketBuffer* aBuffer)
     : SocketIORunnable<StreamSocketIO>(aIO)
     , mBuffer(aBuffer)
   { }
 
   NS_IMETHOD Run() override
   {
     StreamSocketIO* io = SocketIORunnable<StreamSocketIO>::GetIO();
 
     MOZ_ASSERT(io->IsConsumerThread());
 
-    if (NS_WARN_IF(io->IsShutdownOnMainThread())) {
+    if (NS_WARN_IF(io->IsShutdownOnConsumerThread())) {
       // Since we've already explicitly closed and the close
       // happened before this, this isn't really an error.
       return NS_OK;
     }
 
     StreamSocket* streamSocket = io->GetStreamSocket();
     MOZ_ASSERT(streamSocket);
 
@@ -423,34 +424,34 @@ StreamSocketIO::DiscardBuffer()
 
 SocketBase*
 StreamSocketIO::GetSocketBase()
 {
   return GetDataSocket();
 }
 
 bool
-StreamSocketIO::IsShutdownOnMainThread() const
+StreamSocketIO::IsShutdownOnConsumerThread() const
 {
   MOZ_ASSERT(IsConsumerThread());
 
   return mStreamSocket == nullptr;
 }
 
 bool
 StreamSocketIO::IsShutdownOnIOThread() const
 {
   return mShuttingDownOnIOThread;
 }
 
 void
-StreamSocketIO::ShutdownOnMainThread()
+StreamSocketIO::ShutdownOnConsumerThread()
 {
   MOZ_ASSERT(IsConsumerThread());
-  MOZ_ASSERT(!IsShutdownOnMainThread());
+  MOZ_ASSERT(!IsShutdownOnConsumerThread());
 
   mStreamSocket = nullptr;
 }
 
 void
 StreamSocketIO::ShutdownOnIOThread()
 {
   MOZ_ASSERT(!IsConsumerThread());
@@ -493,17 +494,17 @@ public:
   {
     MOZ_ASSERT(GetIO()->IsConsumerThread());
 
     if (IsCanceled()) {
       return;
     }
 
     StreamSocketIO* io = GetIO();
-    if (io->IsShutdownOnMainThread()) {
+    if (io->IsShutdownOnConsumerThread()) {
       return;
     }
 
     io->ClearDelayedConnectTask();
     io->GetIOLoop()->PostTask(FROM_HERE, new ConnectTask(io));
   }
 };
 
@@ -586,17 +587,17 @@ StreamSocket::PrepareAccept(UnixSocketCo
 
 // |DataSocket|
 
 void
 StreamSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
 {
   MOZ_ASSERT(mIO);
   MOZ_ASSERT(mIO->IsConsumerThread());
-  MOZ_ASSERT(!mIO->IsShutdownOnMainThread());
+  MOZ_ASSERT(!mIO->IsShutdownOnConsumerThread());
 
   mIO->GetIOLoop()->PostTask(
     FROM_HERE,
     new SocketIOSendTask<StreamSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
 }
 
 // |SocketBase|
 
@@ -606,17 +607,17 @@ StreamSocket::Close()
   MOZ_ASSERT(mIO);
   MOZ_ASSERT(mIO->IsConsumerThread());
 
   mIO->CancelDelayedConnectTask();
 
   // From this point on, we consider |mIO| as being deleted. We sever
   // the relationship here so any future calls to |Connect| will create
   // a new I/O object.
-  mIO->ShutdownOnMainThread();
+  mIO->ShutdownOnConsumerThread();
   mIO->GetIOLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
   mIO = nullptr;
 
   NotifyDisconnect();
 }
 
 void
 StreamSocket::OnConnectSuccess()
--- a/ipc/unixsocket/StreamSocket.h
+++ b/ipc/unixsocket/StreamSocket.h
@@ -25,17 +25,17 @@ public:
    * Constructs an instance of |StreamSocket|.
    *
    * @param aConsumer The consumer for the socket.
    * @param aIndex An arbitrary index.
    */
   StreamSocket(StreamSocketConsumer* aConsumer, int aIndex);
 
   /**
-   * Method to be called whenever data is received. Main-thread only.
+   * Method to be called whenever data is received. Consumer-thread only.
    *
    * @param aBuffer Data received from the socket.
    */
   void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer);
 
   /**
    * Starts a task on the socket that will try to connect to a socket in a
    * non-blocking manner.
--- a/ipc/unixsocket/StreamSocketConsumer.h
+++ b/ipc/unixsocket/StreamSocketConsumer.h
@@ -16,40 +16,40 @@ class UnixSocketBuffer;
 
 /**
  * |StreamSocketConsumer| handles socket events and received data.
  */
 class StreamSocketConsumer
 {
 public:
   /**
-   * Method to be called whenever data is received. Main-thread only.
+   * 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;
 
   /**
-   * Callback for socket success. Main-thread only.
+   * 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;
 
   /**
-   * Callback for socket errors. Main-thread only.
+   * Callback for socket errors. Consumer-thread only.
    *
    * @param aIndex The index that has been given to the stream socket.
    */
   virtual void OnConnectError(int aIndex) = 0;
 
   /**
-   * Callback for socket disconnect. Main-thread only.
+   * Callback for socket disconnect. Consumer-thread only.
    *
    * @param aIndex The index that has been given to the stream socket.
    */
   virtual void OnDisconnect(int aIndex) = 0;
 
 protected:
   virtual ~StreamSocketConsumer();
 };