mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1185478: Add leak checks to socket I/O classes
This commit is contained in:
parent
2edd586eed
commit
9e43771c76
@ -8,6 +8,7 @@
|
||||
#include "BluetoothDaemonConnector.h"
|
||||
#include <fcntl.h>
|
||||
#include <sys/un.h>
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
@ -15,10 +16,14 @@ BEGIN_BLUETOOTH_NAMESPACE
|
||||
BluetoothDaemonConnector::BluetoothDaemonConnector(
|
||||
const nsACString& aSocketName)
|
||||
: mSocketName(aSocketName)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(BluetoothDaemonConnector, UnixSocketConnector);
|
||||
}
|
||||
|
||||
BluetoothDaemonConnector::~BluetoothDaemonConnector()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(BluetoothDaemonConnector, UnixSocketConnector);
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothDaemonConnector::CreateSocket(int& aFd) const
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "mozilla/ipc/UnixSocketWatcher.h"
|
||||
#include "mozilla/FileUtils.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
@ -78,11 +79,15 @@ public:
|
||||
, mConsumer(aConsumer)
|
||||
, mShuttingDownOnIOThread(false)
|
||||
, mConnectionStatus(SOCKET_IS_DISCONNECTED)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(DroidSocketImpl, DataSocketIO);
|
||||
}
|
||||
|
||||
~DroidSocketImpl()
|
||||
{
|
||||
MOZ_ASSERT(IsConsumerThread());
|
||||
|
||||
MOZ_COUNT_DTOR_INHERITED(DroidSocketImpl, DataSocketIO);
|
||||
}
|
||||
|
||||
void Send(UnixSocketIOBuffer* aBuffer)
|
||||
@ -582,10 +587,17 @@ BluetoothSocket::BluetoothSocket(BluetoothSocketObserver* aObserver)
|
||||
{
|
||||
MOZ_ASSERT(aObserver);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(BluetoothSocket, DataSocket);
|
||||
|
||||
EnsureBluetoothSocketHalLoad();
|
||||
mDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
|
||||
}
|
||||
|
||||
BluetoothSocket::~BluetoothSocket()
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(BluetoothSocket, DataSocket);
|
||||
}
|
||||
|
||||
class ConnectSocketResultHandler final : public BluetoothSocketResultHandler
|
||||
{
|
||||
public:
|
||||
|
@ -22,6 +22,7 @@ class BluetoothSocket final : public mozilla::ipc::DataSocket
|
||||
{
|
||||
public:
|
||||
BluetoothSocket(BluetoothSocketObserver* aObserver);
|
||||
~BluetoothSocket();
|
||||
|
||||
nsresult Connect(const nsAString& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "BluetoothSocketObserver.h"
|
||||
#include "BluetoothUnixSocketConnector.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
@ -146,12 +147,16 @@ BluetoothSocket::BluetoothSocketIO::BluetoothSocketIO(
|
||||
{
|
||||
MOZ_ASSERT(mConsumer);
|
||||
MOZ_ASSERT(mConnector);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(BluetoothSocketIO, DataSocketIO);
|
||||
}
|
||||
|
||||
BluetoothSocket::BluetoothSocketIO::~BluetoothSocketIO()
|
||||
{
|
||||
MOZ_ASSERT(IsConsumerThread());
|
||||
MOZ_ASSERT(IsShutdownOnConsumerThread());
|
||||
|
||||
MOZ_COUNT_DTOR_INHERITED(BluetoothSocketIO, DataSocketIO);
|
||||
}
|
||||
|
||||
void
|
||||
@ -562,11 +567,15 @@ BluetoothSocket::BluetoothSocket(BluetoothSocketObserver* aObserver)
|
||||
, mIO(nullptr)
|
||||
{
|
||||
MOZ_ASSERT(aObserver);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(BluetoothSocket, DataSocket);
|
||||
}
|
||||
|
||||
BluetoothSocket::~BluetoothSocket()
|
||||
{
|
||||
MOZ_ASSERT(!mIO);
|
||||
|
||||
MOZ_COUNT_DTOR_INHERITED(BluetoothSocket, DataSocket);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
#include "nsThreadUtils.h" // For NS_IsMainThread.
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
@ -52,10 +53,14 @@ BluetoothUnixSocketConnector::BluetoothUnixSocketConnector(
|
||||
, mChannel(aChannel)
|
||||
, mAuth(aAuth)
|
||||
, mEncrypt(aEncrypt)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(BluetoothUnixSocketConnector, UnixSocketConnector);
|
||||
}
|
||||
|
||||
BluetoothUnixSocketConnector::~BluetoothUnixSocketConnector()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(BluetoothUnixSocketConnector, UnixSocketConnector);
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothUnixSocketConnector::CreateSocket(int& aFd) const
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "DaemonSocket.h"
|
||||
#include "mozilla/ipc/DaemonSocketConsumer.h"
|
||||
#include "mozilla/ipc/DaemonSocketPDU.h"
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
|
||||
#ifdef CHROMIUM_LOG
|
||||
#undef CHROMIUM_LOG
|
||||
@ -38,6 +39,8 @@ public:
|
||||
DaemonSocket* aConnection,
|
||||
DaemonSocketIOConsumer* aConsumer);
|
||||
|
||||
~DaemonSocketIO();
|
||||
|
||||
// Methods for |DataSocketIO|
|
||||
//
|
||||
|
||||
@ -82,6 +85,13 @@ DaemonSocketIO::DaemonSocketIO(
|
||||
{
|
||||
MOZ_ASSERT(mConnection);
|
||||
MOZ_ASSERT(mConsumer);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(DaemonSocketIO, ConnectionOrientedSocketIO);
|
||||
}
|
||||
|
||||
DaemonSocketIO::~DaemonSocketIO()
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(DaemonSocketIO, ConnectionOrientedSocketIO);
|
||||
}
|
||||
|
||||
// |DataSocketIO|
|
||||
@ -169,10 +179,14 @@ DaemonSocket::DaemonSocket(
|
||||
, mIndex(aIndex)
|
||||
{
|
||||
MOZ_ASSERT(mConsumer);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(DaemonSocket, ConnectionOrientedSocket);
|
||||
}
|
||||
|
||||
DaemonSocket::~DaemonSocket()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(DaemonSocket, ConnectionOrientedSocket);
|
||||
}
|
||||
|
||||
// |ConnectionOrientedSocket|
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "DaemonSocketPDU.h"
|
||||
#include "mozilla/ipc/DaemonSocketConsumer.h"
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
|
||||
#ifdef CHROMIUM_LOG
|
||||
#undef CHROMIUM_LOG
|
||||
@ -32,6 +33,8 @@ DaemonSocketPDU::DaemonSocketPDU(uint8_t aService, uint8_t aOpcode,
|
||||
: mConsumer(nullptr)
|
||||
, mUserData(nullptr)
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(DaemonSocketPDU, UnixSocketIOBuffer);
|
||||
|
||||
// Allocate memory
|
||||
size_t availableSpace = HEADER_SIZE + aPayloadSize;
|
||||
ResetBuffer(new uint8_t[availableSpace], 0, 0, availableSpace);
|
||||
@ -50,12 +53,16 @@ DaemonSocketPDU::DaemonSocketPDU(size_t aPayloadSize)
|
||||
: mConsumer(nullptr)
|
||||
, mUserData(nullptr)
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(DaemonSocketPDU, UnixSocketIOBuffer);
|
||||
|
||||
size_t availableSpace = HEADER_SIZE + aPayloadSize;
|
||||
ResetBuffer(new uint8_t[availableSpace], 0, 0, availableSpace);
|
||||
}
|
||||
|
||||
DaemonSocketPDU::~DaemonSocketPDU()
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(DaemonSocketPDU, UnixSocketIOBuffer);
|
||||
|
||||
nsAutoArrayPtr<uint8_t> data(GetBuffer());
|
||||
ResetBuffer(nullptr, 0, 0, 0);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/un.h>
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
#include "nsThreadUtils.h" // For NS_IsMainThread.
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
@ -26,10 +27,14 @@ static const char KEYSTORE_SOCKET_PATH[] = "/dev/socket/keystore";
|
||||
|
||||
KeyStoreConnector::KeyStoreConnector(const char** const aAllowedUsers)
|
||||
: mAllowedUsers(aAllowedUsers)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(KeyStoreConnector, UnixSocketConnector);
|
||||
}
|
||||
|
||||
KeyStoreConnector::~KeyStoreConnector()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(KeyStoreConnector, UnixSocketConnector);
|
||||
}
|
||||
|
||||
nsresult
|
||||
KeyStoreConnector::CreateSocket(int& aFd) const
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "NfcConnector.h"
|
||||
#include <fcntl.h>
|
||||
#include <sys/un.h>
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
#include "nsThreadUtils.h" // For NS_IsMainThread.
|
||||
|
||||
namespace mozilla {
|
||||
@ -15,10 +16,14 @@ namespace ipc {
|
||||
|
||||
NfcConnector::NfcConnector(const nsACString& aAddressString)
|
||||
: mAddressString(aAddressString)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(NfcConnector, UnixSocketConnector);
|
||||
}
|
||||
|
||||
NfcConnector::~NfcConnector()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(NfcConnector, UnixSocketConnector);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NfcConnector::CreateSocket(int& aFd) const
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "RilConnector.h"
|
||||
#include <fcntl.h>
|
||||
#include <sys/socket.h>
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
#include "nsThreadUtils.h" // For NS_IsMainThread.
|
||||
|
||||
#ifdef AF_INET
|
||||
@ -27,10 +28,14 @@ RilConnector::RilConnector(const nsACString& aAddressString,
|
||||
unsigned long aClientId)
|
||||
: mAddressString(aAddressString)
|
||||
, mClientId(aClientId)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(RilConnector, UnixSocketConnector);
|
||||
}
|
||||
|
||||
RilConnector::~RilConnector()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(RilConnector, UnixSocketConnector);
|
||||
}
|
||||
|
||||
nsresult
|
||||
RilConnector::CreateSocket(int aDomain, int& aFd) const
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "mozilla/dom/workers/Workers.h"
|
||||
#include "mozilla/ipc/UnixSocketConnector.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "RilSocketConsumer.h"
|
||||
|
||||
@ -108,12 +109,16 @@ RilSocketIO::RilSocketIO(WorkerCrossThreadDispatcher* aDispatcher,
|
||||
{
|
||||
MOZ_ASSERT(mDispatcher);
|
||||
MOZ_ASSERT(mRilSocket);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(RilSocketIO, ConnectionOrientedSocketIO);
|
||||
}
|
||||
|
||||
RilSocketIO::~RilSocketIO()
|
||||
{
|
||||
MOZ_ASSERT(IsConsumerThread());
|
||||
MOZ_ASSERT(IsShutdownOnConsumerThread());
|
||||
|
||||
MOZ_COUNT_DTOR_INHERITED(RilSocketIO, ConnectionOrientedSocketIO);
|
||||
}
|
||||
|
||||
RilSocket*
|
||||
@ -324,11 +329,15 @@ RilSocket::RilSocket(WorkerCrossThreadDispatcher* aDispatcher,
|
||||
{
|
||||
MOZ_ASSERT(mDispatcher);
|
||||
MOZ_ASSERT(mConsumer);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(RilSocket, ConnectionOrientedSocket);
|
||||
}
|
||||
|
||||
RilSocket::~RilSocket()
|
||||
{
|
||||
MOZ_ASSERT(!mIO);
|
||||
|
||||
MOZ_COUNT_DTOR_INHERITED(RilSocket, ConnectionOrientedSocket);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -5,6 +5,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ConnectionOrientedSocket.h"
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
#include "UnixSocketConnector.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -25,6 +26,8 @@ ConnectionOrientedSocketIO::ConnectionOrientedSocketIO(
|
||||
, mPeerAddressLength(0)
|
||||
{
|
||||
MOZ_ASSERT(mConnector);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(ConnectionOrientedSocketIO, DataSocketIO);
|
||||
}
|
||||
|
||||
ConnectionOrientedSocketIO::ConnectionOrientedSocketIO(
|
||||
@ -37,10 +40,14 @@ ConnectionOrientedSocketIO::ConnectionOrientedSocketIO(
|
||||
, mPeerAddressLength(0)
|
||||
{
|
||||
MOZ_ASSERT(mConnector);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(ConnectionOrientedSocketIO, DataSocketIO);
|
||||
}
|
||||
|
||||
ConnectionOrientedSocketIO::~ConnectionOrientedSocketIO()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(ConnectionOrientedSocketIO, DataSocketIO);
|
||||
}
|
||||
|
||||
nsresult
|
||||
ConnectionOrientedSocketIO::Accept(int aFd,
|
||||
@ -181,8 +188,15 @@ ConnectionOrientedSocketIO::OnError(const char* aFunction, int aErrno)
|
||||
// ConnectionOrientedSocket
|
||||
//
|
||||
|
||||
ConnectionOrientedSocket::ConnectionOrientedSocket()
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(ConnectionOrientedSocket, DataSocket);
|
||||
}
|
||||
|
||||
ConnectionOrientedSocket::~ConnectionOrientedSocket()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(ConnectionOrientedSocket, DataSocket);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,8 @@
|
||||
* 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_connectionorientedsocket_h
|
||||
#define mozilla_ipc_connectionorientedsocket_h
|
||||
#ifndef mozilla_ipc_ConnectionOrientedSocket_h
|
||||
#define mozilla_ipc_ConnectionOrientedSocket_h
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include "DataSocket.h"
|
||||
@ -112,10 +112,11 @@ public:
|
||||
ConnectionOrientedSocketIO*& aIO) = 0;
|
||||
|
||||
protected:
|
||||
ConnectionOrientedSocket();
|
||||
virtual ~ConnectionOrientedSocket();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // mozilla_ipc_ConnectionOrientedSocket
|
||||
|
@ -6,10 +6,11 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "mozilla/ipc/DataSocket.h"
|
||||
#include "DataSocket.h"
|
||||
#ifdef MOZ_TASK_TRACER
|
||||
#include "GeckoTaskTracer.h"
|
||||
#endif
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
|
||||
#ifdef MOZ_TASK_TRACER
|
||||
using namespace mozilla::tasktracer;
|
||||
@ -23,7 +24,9 @@ namespace ipc {
|
||||
//
|
||||
|
||||
DataSocketIO::~DataSocketIO()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(DataSocketIO, SocketIOBase);
|
||||
}
|
||||
|
||||
void
|
||||
DataSocketIO::EnqueueData(UnixSocketIOBuffer* aBuffer)
|
||||
@ -111,14 +114,23 @@ DataSocketIO::SendPendingData(int aFd)
|
||||
|
||||
DataSocketIO::DataSocketIO(MessageLoop* aConsumerLoop)
|
||||
: SocketIOBase(aConsumerLoop)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(DataSocketIO, SocketIOBase);
|
||||
}
|
||||
|
||||
//
|
||||
// DataSocket
|
||||
//
|
||||
|
||||
DataSocket::DataSocket()
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(DataSocket, SocketBase);
|
||||
}
|
||||
|
||||
DataSocket::~DataSocket()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(DataSocket, SocketBase);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ public:
|
||||
* @param aBuffer Data to be sent to socket
|
||||
*/
|
||||
virtual void SendSocketData(UnixSocketIOBuffer* aBuffer) = 0;
|
||||
|
||||
protected:
|
||||
DataSocket();
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "DataSocket.h"
|
||||
#include "ListenSocketConsumer.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "UnixSocketConnector.h"
|
||||
|
||||
@ -109,12 +110,16 @@ ListenSocketIO::ListenSocketIO(MessageLoop* aConsumerLoop,
|
||||
{
|
||||
MOZ_ASSERT(mListenSocket);
|
||||
MOZ_ASSERT(mConnector);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(ListenSocketIO, SocketIOBase);
|
||||
}
|
||||
|
||||
ListenSocketIO::~ListenSocketIO()
|
||||
{
|
||||
MOZ_ASSERT(IsConsumerThread());
|
||||
MOZ_ASSERT(IsShutdownOnConsumerThread());
|
||||
|
||||
MOZ_COUNT_DTOR_INHERITED(ListenSocketIO, SocketIOBase);
|
||||
}
|
||||
|
||||
UnixSocketConnector*
|
||||
@ -266,15 +271,21 @@ ListenSocketIO::ShutdownOnIOThread()
|
||||
// Socket tasks
|
||||
//
|
||||
|
||||
class ListenSocketIO::ListenTask final
|
||||
: public SocketIOTask<ListenSocketIO>
|
||||
class ListenSocketIO::ListenTask final : public SocketIOTask<ListenSocketIO>
|
||||
{
|
||||
public:
|
||||
ListenTask(ListenSocketIO* aIO, ConnectionOrientedSocketIO* aCOSocketIO)
|
||||
: SocketIOTask<ListenSocketIO>(aIO)
|
||||
, mCOSocketIO(aCOSocketIO)
|
||||
: SocketIOTask<ListenSocketIO>(aIO)
|
||||
, mCOSocketIO(aCOSocketIO)
|
||||
{
|
||||
MOZ_ASSERT(mCOSocketIO);
|
||||
|
||||
MOZ_COUNT_CTOR(ListenTask);
|
||||
}
|
||||
|
||||
~ListenTask()
|
||||
{
|
||||
MOZ_COUNT_DTOR(ListenTask);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
@ -291,7 +302,7 @@ private:
|
||||
};
|
||||
|
||||
//
|
||||
// UnixSocketConsumer
|
||||
// ListenSocket
|
||||
//
|
||||
|
||||
ListenSocket::ListenSocket(ListenSocketConsumer* aConsumer, int aIndex)
|
||||
@ -300,11 +311,15 @@ ListenSocket::ListenSocket(ListenSocketConsumer* aConsumer, int aIndex)
|
||||
, mIndex(aIndex)
|
||||
{
|
||||
MOZ_ASSERT(mConsumer);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(ListenSocket, SocketBase);
|
||||
}
|
||||
|
||||
ListenSocket::~ListenSocket()
|
||||
{
|
||||
MOZ_ASSERT(!mIO);
|
||||
|
||||
MOZ_COUNT_DTOR_INHERITED(ListenSocket, SocketBase);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -4,11 +4,11 @@
|
||||
* 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_listensocket_h
|
||||
#define mozilla_ipc_listensocket_h
|
||||
#ifndef mozilla_ipc_ListenSocket_h
|
||||
#define mozilla_ipc_ListenSocket_h
|
||||
|
||||
#include "nsString.h"
|
||||
#include "mozilla/ipc/SocketBase.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class MessageLoop;
|
||||
|
||||
@ -90,4 +90,4 @@ private:
|
||||
} // namespace ipc
|
||||
} // namepsace mozilla
|
||||
|
||||
#endif // mozilla_ipc_listensocket_h
|
||||
#endif // mozilla_ipc_ListenSocket_h
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
@ -23,10 +24,14 @@ UnixSocketBuffer::UnixSocketBuffer()
|
||||
, mOffset(0)
|
||||
, mAvailableSpace(0)
|
||||
, mData(nullptr)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR(UnixSocketBuffer);
|
||||
}
|
||||
|
||||
UnixSocketBuffer::~UnixSocketBuffer()
|
||||
{
|
||||
MOZ_COUNT_DTOR(UnixSocketBuffer);
|
||||
|
||||
// Make sure that the caller released the buffer's memory.
|
||||
MOZ_ASSERT(!GetBuffer());
|
||||
}
|
||||
@ -96,8 +101,15 @@ UnixSocketBuffer::CleanupLeadingSpace()
|
||||
// UnixSocketIOBuffer
|
||||
//
|
||||
|
||||
UnixSocketIOBuffer::UnixSocketIOBuffer()
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(UnixSocketIOBuffer, UnixSocketBuffer);
|
||||
}
|
||||
|
||||
UnixSocketIOBuffer::~UnixSocketIOBuffer()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(UnixSocketIOBuffer, UnixSocketBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// UnixSocketRawData
|
||||
@ -107,17 +119,23 @@ UnixSocketRawData::UnixSocketRawData(const void* aData, size_t aSize)
|
||||
{
|
||||
MOZ_ASSERT(aData || !aSize);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(UnixSocketRawData, UnixSocketIOBuffer);
|
||||
|
||||
ResetBuffer(static_cast<uint8_t*>(memcpy(new uint8_t[aSize], aData, aSize)),
|
||||
0, aSize, aSize);
|
||||
}
|
||||
|
||||
UnixSocketRawData::UnixSocketRawData(size_t aSize)
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(UnixSocketRawData, UnixSocketIOBuffer);
|
||||
|
||||
ResetBuffer(new uint8_t[aSize], 0, 0, aSize);
|
||||
}
|
||||
|
||||
UnixSocketRawData::~UnixSocketRawData()
|
||||
{
|
||||
MOZ_COUNT_DTOR_INHERITED(UnixSocketRawData, UnixSocketIOBuffer);
|
||||
|
||||
nsAutoArrayPtr<uint8_t> data(GetBuffer());
|
||||
ResetBuffer(nullptr, 0, 0, 0);
|
||||
}
|
||||
@ -237,11 +255,15 @@ SocketBase::SocketBase()
|
||||
: mConnectionStatus(SOCKET_DISCONNECTED)
|
||||
, mConnectTimestamp(0)
|
||||
, mConnectDelayMs(0)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR(SocketBase);
|
||||
}
|
||||
|
||||
SocketBase::~SocketBase()
|
||||
{
|
||||
MOZ_ASSERT(mConnectionStatus == SOCKET_DISCONNECTED);
|
||||
|
||||
MOZ_COUNT_DTOR(SocketBase);
|
||||
}
|
||||
|
||||
void
|
||||
@ -258,10 +280,14 @@ SocketIOBase::SocketIOBase(MessageLoop* aConsumerLoop)
|
||||
: mConsumerLoop(aConsumerLoop)
|
||||
{
|
||||
MOZ_ASSERT(mConsumerLoop);
|
||||
|
||||
MOZ_COUNT_CTOR(SocketIOBase);
|
||||
}
|
||||
|
||||
SocketIOBase::~SocketIOBase()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_DTOR(SocketIOBase);
|
||||
}
|
||||
|
||||
MessageLoop*
|
||||
SocketIOBase::GetConsumerThread() const
|
||||
@ -282,7 +308,14 @@ SocketIOBase::IsConsumerThread() const
|
||||
SocketEventTask::SocketEventTask(SocketIOBase* aIO, SocketEvent aEvent)
|
||||
: SocketTask<SocketIOBase>(aIO)
|
||||
, mEvent(aEvent)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR(SocketEventTask);
|
||||
}
|
||||
|
||||
SocketEventTask::~SocketEventTask()
|
||||
{
|
||||
MOZ_COUNT_DTOR(SocketEventTask);
|
||||
}
|
||||
|
||||
void
|
||||
SocketEventTask::Run()
|
||||
@ -313,10 +346,16 @@ SocketEventTask::Run()
|
||||
// SocketRequestClosingTask
|
||||
//
|
||||
|
||||
SocketRequestClosingTask::SocketRequestClosingTask(
|
||||
SocketIOBase* aIO)
|
||||
SocketRequestClosingTask::SocketRequestClosingTask(SocketIOBase* aIO)
|
||||
: SocketTask<SocketIOBase>(aIO)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR(SocketRequestClosingTask);
|
||||
}
|
||||
|
||||
SocketRequestClosingTask::~SocketRequestClosingTask()
|
||||
{
|
||||
MOZ_COUNT_DTOR(SocketRequestClosingTask);
|
||||
}
|
||||
|
||||
void
|
||||
SocketRequestClosingTask::Run()
|
||||
@ -341,10 +380,16 @@ SocketRequestClosingTask::Run()
|
||||
// SocketDeleteInstanceTask
|
||||
//
|
||||
|
||||
SocketDeleteInstanceTask::SocketDeleteInstanceTask(
|
||||
SocketIOBase* aIO)
|
||||
SocketDeleteInstanceTask::SocketDeleteInstanceTask(SocketIOBase* aIO)
|
||||
: mIO(aIO)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR(SocketDeleteInstanceTask);
|
||||
}
|
||||
|
||||
SocketDeleteInstanceTask::~SocketDeleteInstanceTask()
|
||||
{
|
||||
MOZ_COUNT_DTOR(SocketDeleteInstanceTask);
|
||||
}
|
||||
|
||||
void
|
||||
SocketDeleteInstanceTask::Run()
|
||||
@ -358,7 +403,14 @@ SocketDeleteInstanceTask::Run()
|
||||
|
||||
SocketIOShutdownTask::SocketIOShutdownTask(SocketIOBase* aIO)
|
||||
: SocketIOTask<SocketIOBase>(aIO)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR(SocketIOShutdownTask);
|
||||
}
|
||||
|
||||
SocketIOShutdownTask::~SocketIOShutdownTask()
|
||||
{
|
||||
MOZ_COUNT_DTOR(SocketIOShutdownTask);
|
||||
}
|
||||
|
||||
void
|
||||
SocketIOShutdownTask::Run()
|
||||
|
@ -197,6 +197,7 @@ private:
|
||||
class UnixSocketIOBuffer : public UnixSocketBuffer
|
||||
{
|
||||
public:
|
||||
UnixSocketIOBuffer();
|
||||
virtual ~UnixSocketIOBuffer();
|
||||
|
||||
/**
|
||||
@ -439,6 +440,7 @@ public:
|
||||
};
|
||||
|
||||
SocketEventTask(SocketIOBase* aIO, SocketEvent aEvent);
|
||||
~SocketEventTask();
|
||||
|
||||
void Run() override;
|
||||
|
||||
@ -454,6 +456,7 @@ class SocketRequestClosingTask final : public SocketTask<SocketIOBase>
|
||||
{
|
||||
public:
|
||||
SocketRequestClosingTask(SocketIOBase* aIO);
|
||||
~SocketRequestClosingTask();
|
||||
|
||||
void Run() override;
|
||||
};
|
||||
@ -465,6 +468,7 @@ class SocketDeleteInstanceTask final : public Task
|
||||
{
|
||||
public:
|
||||
SocketDeleteInstanceTask(SocketIOBase* aIO);
|
||||
~SocketDeleteInstanceTask();
|
||||
|
||||
void Run() override;
|
||||
|
||||
@ -520,6 +524,7 @@ class SocketIOShutdownTask final : public SocketIOTask<SocketIOBase>
|
||||
{
|
||||
public:
|
||||
SocketIOShutdownTask(SocketIOBase* aIO);
|
||||
~SocketIOShutdownTask();
|
||||
|
||||
void Run() override;
|
||||
};
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "StreamSocket.h"
|
||||
#include <fcntl.h>
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "StreamSocketConsumer.h"
|
||||
#include "UnixSocketConnector.h"
|
||||
@ -101,6 +102,8 @@ StreamSocketIO::StreamSocketIO(MessageLoop* aConsumerLoop,
|
||||
, mDelayedConnectTask(nullptr)
|
||||
{
|
||||
MOZ_ASSERT(mStreamSocket);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(StreamSocketIO, ConnectionOrientedSocketIO);
|
||||
}
|
||||
|
||||
StreamSocketIO::StreamSocketIO(MessageLoop* aConsumerLoop,
|
||||
@ -118,12 +121,16 @@ StreamSocketIO::StreamSocketIO(MessageLoop* aConsumerLoop,
|
||||
, mDelayedConnectTask(nullptr)
|
||||
{
|
||||
MOZ_ASSERT(mStreamSocket);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(StreamSocketIO, ConnectionOrientedSocketIO);
|
||||
}
|
||||
|
||||
StreamSocketIO::~StreamSocketIO()
|
||||
{
|
||||
MOZ_ASSERT(IsConsumerThread());
|
||||
MOZ_ASSERT(IsShutdownOnConsumerThread());
|
||||
|
||||
MOZ_COUNT_DTOR_INHERITED(StreamSocketIO, ConnectionOrientedSocketIO);
|
||||
}
|
||||
|
||||
StreamSocket*
|
||||
@ -192,7 +199,14 @@ public:
|
||||
ReceiveTask(StreamSocketIO* aIO, UnixSocketBuffer* aBuffer)
|
||||
: SocketTask<StreamSocketIO>(aIO)
|
||||
, mBuffer(aBuffer)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR(ReceiveTask);
|
||||
}
|
||||
|
||||
~ReceiveTask()
|
||||
{
|
||||
MOZ_COUNT_DTOR(ReceiveTask);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
{
|
||||
@ -274,13 +288,19 @@ StreamSocketIO::ShutdownOnIOThread()
|
||||
// Socket tasks
|
||||
//
|
||||
|
||||
class StreamSocketIO::ConnectTask final
|
||||
: public SocketIOTask<StreamSocketIO>
|
||||
class StreamSocketIO::ConnectTask final : public SocketIOTask<StreamSocketIO>
|
||||
{
|
||||
public:
|
||||
ConnectTask(StreamSocketIO* aIO)
|
||||
: SocketIOTask<StreamSocketIO>(aIO)
|
||||
{ }
|
||||
: SocketIOTask<StreamSocketIO>(aIO)
|
||||
{
|
||||
MOZ_COUNT_CTOR(ReceiveTask);
|
||||
}
|
||||
|
||||
~ConnectTask()
|
||||
{
|
||||
MOZ_COUNT_DTOR(ReceiveTask);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
{
|
||||
@ -297,7 +317,14 @@ class StreamSocketIO::DelayedConnectTask final
|
||||
public:
|
||||
DelayedConnectTask(StreamSocketIO* aIO)
|
||||
: SocketIOTask<StreamSocketIO>(aIO)
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR(DelayedConnectTask);
|
||||
}
|
||||
|
||||
~DelayedConnectTask()
|
||||
{
|
||||
MOZ_COUNT_DTOR(DelayedConnectTask);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
{
|
||||
@ -327,11 +354,15 @@ StreamSocket::StreamSocket(StreamSocketConsumer* aConsumer, int aIndex)
|
||||
, mIndex(aIndex)
|
||||
{
|
||||
MOZ_ASSERT(mConsumer);
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(StreamSocket, ConnectionOrientedSocket);
|
||||
}
|
||||
|
||||
StreamSocket::~StreamSocket()
|
||||
{
|
||||
MOZ_ASSERT(!mIO);
|
||||
|
||||
MOZ_COUNT_DTOR_INHERITED(StreamSocket, ConnectionOrientedSocket);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -5,15 +5,20 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "UnixSocketConnector.h"
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
UnixSocketConnector::UnixSocketConnector()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_CTOR(UnixSocketConnector);
|
||||
}
|
||||
|
||||
UnixSocketConnector::~UnixSocketConnector()
|
||||
{ }
|
||||
{
|
||||
MOZ_COUNT_DTOR(UnixSocketConnector);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user