Bug 826829 - Change ImageContainerChild::DispatchSetIdle() to synchronous SetIdle(). r=kanru

This commit is contained in:
Sotaro Ikeda 2013-01-14 20:15:03 -05:00
parent 763138cc5d
commit 5646bb17ed
3 changed files with 39 additions and 13 deletions

View File

@ -183,7 +183,7 @@ ImageContainer::SetCurrentImage(Image *aImage)
if (aImage) {
mImageContainerChild->SendImageAsync(this, aImage);
} else {
mImageContainerChild->DispatchSetIdle();
mImageContainerChild->SetIdle();
}
}

View File

@ -73,12 +73,33 @@ void ImageContainerChild::SetIdleNow()
mImageQueue.Clear();
}
void ImageContainerChild::DispatchSetIdle()
void ImageContainerChild::SetIdleSync(Monitor* aBarrier, bool* aDone)
{
MonitorAutoLock autoMon(*aBarrier);
SetIdleNow();
*aDone = true;
aBarrier->NotifyAll();
}
void ImageContainerChild::SetIdle()
{
if (mStop) return;
if (InImageBridgeChildThread()) {
return SetIdleNow();
}
Monitor barrier("SetIdle Lock");
MonitorAutoLock autoMon(barrier);
bool done = false;
GetMessageLoop()->PostTask(FROM_HERE,
NewRunnableMethod(this, &ImageContainerChild::SetIdleNow));
NewRunnableMethod(this, &ImageContainerChild::SetIdleSync, &barrier, &done));
while (!done) {
barrier.Wait();
}
}
void ImageContainerChild::StopChildAndParent()

View File

@ -106,16 +106,9 @@ public:
void DispatchDestroy();
/**
* Dispatches a task on the ImageBridgeChild's thread that will call SendFlush
* and deallocate the shared images in the pool.
* Can be called on any thread.
* Flush and deallocate the shared images in the pool.
*/
void DispatchSetIdle();
/**
* Must be called on the ImageBridgeChild's thread.
*/
void SetIdleNow();
void SetIdle();
/**
* Can be called from any thread.
@ -168,9 +161,21 @@ protected:
}
/**
* Must be called on the ImageBridgeCHild's thread.
* Must be called on the ImageBridgeChild's thread.
*/
void DestroyNow();
/**
* Dispatches a task on the ImageBridgeChild's thread that will call SendFlush
* and deallocate the shared images in the pool.
* Can be called on any thread.
*/
void SetIdleSync(Monitor* aBarrier, bool* aDone);
/**
* Must be called on the ImageBridgeChild's thread.
*/
void SetIdleNow();
inline void SetID(uint64_t id)
{