Bug 774388 - Patch 10: destroy the ImageBridgeChild singleton on the main thread (and sprinkle some assertions) - r=mattwoodrow

This commit is contained in:
Benoit Jacob 2014-07-04 14:04:12 -04:00
Родитель 61671a4f88
Коммит c083b322d1
2 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -221,7 +221,6 @@ static void ImageBridgeShutdownStep2(ReentrantMonitor *aBarrier, bool *aDone)
sImageBridgeChildSingleton->SendStop();
sImageBridgeChildSingleton = nullptr;
*aDone = true;
aBarrier->NotifyAll();
}
@ -248,10 +247,14 @@ static void ConnectImageBridge(ImageBridgeChild * child, ImageBridgeParent * par
ImageBridgeChild::ImageBridgeChild()
: mShuttingDown(false)
{
MOZ_ASSERT(NS_IsMainThread());
mTxn = new CompositableTransaction();
}
ImageBridgeChild::~ImageBridgeChild()
{
MOZ_ASSERT(NS_IsMainThread());
delete mTxn;
}
@ -547,7 +550,7 @@ PImageBridgeChild*
ImageBridgeChild::StartUpInChildProcess(Transport* aTransport,
ProcessId aOtherProcess)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on the main Thread!");
MOZ_ASSERT(NS_IsMainThread());
gfxPlatform::GetPlatform();
@ -572,7 +575,7 @@ ImageBridgeChild::StartUpInChildProcess(Transport* aTransport,
void ImageBridgeChild::ShutDown()
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on the main Thread!");
MOZ_ASSERT(NS_IsMainThread());
if (ImageBridgeChild::IsCreated()) {
MOZ_ASSERT(!sImageBridgeChildSingleton->mShuttingDown);
@ -600,6 +603,8 @@ void ImageBridgeChild::ShutDown()
}
}
sImageBridgeChildSingleton = nullptr;
delete sImageBridgeChildThread;
sImageBridgeChildThread = nullptr;
}

Просмотреть файл

@ -51,6 +51,8 @@ ImageBridgeParent::ImageBridgeParent(MessageLoop* aLoop,
, mTransport(aTransport)
, mChildProcessId(aChildProcessId)
{
MOZ_ASSERT(NS_IsMainThread());
// creates the map only if it has not been created already, so it is safe
// with several bridges
CompositableMap::Create();
@ -59,10 +61,14 @@ ImageBridgeParent::ImageBridgeParent(MessageLoop* aLoop,
ImageBridgeParent::~ImageBridgeParent()
{
MOZ_ASSERT(NS_IsMainThread());
if (mTransport) {
MOZ_ASSERT(XRE_GetIOMessageLoop());
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
new DeleteTask<Transport>(mTransport));
}
sImageBridges.erase(mChildProcessId);
}