Bug 796184 - Revert UnixSocketImpl to a bare pointer, make Bluetooth*Managers use CloseSocket; r=cjones r=gyeh

--HG--
extra : rebase_source : fe8f4633eb9fb86ffc4a87e6b483b3357ab9896d
This commit is contained in:
Kyle Machulis 2012-10-05 16:05:35 -07:00
parent c8c29e0e1e
commit 0e56497b27
4 changed files with 10 additions and 8 deletions

View File

@ -202,7 +202,6 @@ BluetoothHfpManager::Get()
NS_ENSURE_TRUE(manager, nullptr);
if (!manager->Init()) {
manager->Cleanup();
return nullptr;
}
@ -334,7 +333,7 @@ BluetoothHfpManager::HandleShutdown()
{
MOZ_ASSERT(NS_IsMainThread());
gInShutdown = true;
Cleanup();
CloseSocket();
gBluetoothHfpManager = nullptr;
return NS_OK;
}

View File

@ -108,7 +108,6 @@ BluetoothScoManager::Get()
NS_ENSURE_TRUE(manager, nullptr);
if (!manager->Init()) {
manager->Cleanup();
return nullptr;
}
@ -142,7 +141,7 @@ BluetoothScoManager::HandleShutdown()
{
MOZ_ASSERT(NS_IsMainThread());
gInShutdown = true;
Cleanup();
CloseSocket();
gBluetoothScoManager = nullptr;
return NS_OK;
}

View File

@ -118,7 +118,8 @@ public:
void PrepareRemoval()
{
mConsumer.forget();
mTask = nullptr;
mCurrentTaskIsCanceled = true;
}
/**
@ -229,6 +230,7 @@ private:
static void
DestroyImpl(UnixSocketImpl* impl)
{
MOZ_ASSERT(impl);
delete impl;
}
@ -498,13 +500,15 @@ UnixSocketConsumer::CloseSocket()
if (!mImpl) {
return;
}
UnixSocketImpl* impl = mImpl;
mImpl->mConsumer.forget();
mImpl = nullptr;
// To make sure the owner doesn't die on the IOThread, remove pointer here
mImpl->PrepareRemoval();
// Line it up to be destructed on the IO Thread
// Kill our pointer to it
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
NewRunnableFunction(DestroyImpl,
mImpl.forget()));
impl));
}
void

View File

@ -173,7 +173,7 @@ public:
*/
void CancelSocketTask();
private:
nsAutoPtr<UnixSocketImpl> mImpl;
UnixSocketImpl* mImpl;
};
} // namespace ipc