Bug 1164417: Store PDU consumer in |BluetoothDaemonConnection|, r=kmachulis

This commit is contained in:
Thomas Zimmermann 2015-05-21 13:34:37 +02:00
parent 25b408e533
commit e5eabe4c03
3 changed files with 15 additions and 13 deletions

View File

@ -1702,16 +1702,15 @@ public:
private:
BluetoothDaemonInterface* mInterface;
BluetoothDaemonInterface::Channel mChannel;
BluetoothDaemonPDUConsumer* mConsumer;
};
BluetoothDaemonChannel::BluetoothDaemonChannel(
BluetoothDaemonInterface* aInterface,
BluetoothDaemonInterface::Channel aChannel,
BluetoothDaemonPDUConsumer* aConsumer)
: mInterface(aInterface)
: BluetoothDaemonConnection(aConsumer)
, mInterface(aInterface)
, mChannel(aChannel)
, mConsumer(aConsumer)
{ }
void
@ -1744,7 +1743,7 @@ BluetoothDaemonChannel::OnDisconnect()
ConnectionOrientedSocketIO*
BluetoothDaemonChannel::GetIO()
{
return PrepareAccept(mConsumer);
return PrepareAccept();
}
//

View File

@ -431,25 +431,28 @@ BluetoothDaemonConnectionIO::ShutdownOnIOThread()
// BluetoothDaemonConnection
//
BluetoothDaemonConnection::BluetoothDaemonConnection()
: mIO(nullptr)
{ }
BluetoothDaemonConnection::BluetoothDaemonConnection(
BluetoothDaemonPDUConsumer* aConsumer)
: mConsumer(aConsumer)
, mIO(nullptr)
{
MOZ_ASSERT(mConsumer);
}
BluetoothDaemonConnection::~BluetoothDaemonConnection()
{ }
ConnectionOrientedSocketIO*
BluetoothDaemonConnection::PrepareAccept(BluetoothDaemonPDUConsumer* aConsumer)
BluetoothDaemonConnection::PrepareAccept()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mIO);
MOZ_ASSERT(aConsumer);
SetConnectionStatus(SOCKET_CONNECTING);
mIO = new BluetoothDaemonConnectionIO(
XRE_GetIOMessageLoop(), -1, UnixSocketWatcher::SOCKET_IS_CONNECTING,
this, aConsumer);
this, mConsumer);
return mIO;
}

View File

@ -113,7 +113,7 @@ protected:
class BluetoothDaemonConnection : public ConnectionOrientedSocket
{
public:
BluetoothDaemonConnection();
BluetoothDaemonConnection(BluetoothDaemonPDUConsumer* aConsumer);
virtual ~BluetoothDaemonConnection();
// Methods for |ConnectionOrientedSocket|
@ -136,10 +136,10 @@ protected:
// Prepares an instance of |BluetoothDaemonConnection| in DISCONNECTED
// state for accepting a connection. Subclasses implementing |GetIO|
// need to call this method.
ConnectionOrientedSocketIO*
PrepareAccept(BluetoothDaemonPDUConsumer* aConsumer);
ConnectionOrientedSocketIO* PrepareAccept();
private:
BluetoothDaemonPDUConsumer* mConsumer;
BluetoothDaemonConnectionIO* mIO;
};