Bug 774388 - Patch 11: Use a plain RunnableFunction to release the ImageBridgeParent singleton - r=mattwoodrow

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

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

@ -44,6 +44,8 @@ using namespace mozilla::gfx;
std::map<base::ProcessId, ImageBridgeParent*> ImageBridgeParent::sImageBridges;
MessageLoop* ImageBridgeParent::sMainLoop = nullptr;
ImageBridgeParent::ImageBridgeParent(MessageLoop* aLoop,
Transport* aTransport,
ProcessId aChildProcessId)
@ -57,6 +59,7 @@ ImageBridgeParent::ImageBridgeParent(MessageLoop* aLoop,
// with several bridges
CompositableMap::Create();
sImageBridges[aChildProcessId] = this;
sMainLoop = MessageLoop::current();
}
ImageBridgeParent::~ImageBridgeParent()
@ -271,23 +274,11 @@ MessageLoop * ImageBridgeParent::GetMessageLoop() const {
return mMessageLoop;
}
class ReleaseRunnable : public nsRunnable
static void
DeferredReleaseImageBridgeParentOnMainThread(ImageBridgeParent* aDyingImageBridgeParent)
{
public:
ReleaseRunnable(ImageBridgeParent* aRef)
: mRef(aRef)
{
}
NS_IMETHOD Run()
{
mRef->Release();
return NS_OK;
}
private:
ImageBridgeParent* mRef;
};
aDyingImageBridgeParent->Release();
}
void
ImageBridgeParent::DeferredDestroy()
@ -295,8 +286,9 @@ ImageBridgeParent::DeferredDestroy()
ImageBridgeParent* self;
mSelfRef.forget(&self);
nsCOMPtr<nsIRunnable> runnable = new ReleaseRunnable(self);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(runnable)));
sMainLoop->PostTask(
FROM_HERE,
NewRunnableFunction(&DeferredReleaseImageBridgeParentOnMainThread, this));
}
ImageBridgeParent*

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

@ -151,6 +151,8 @@ private:
* Map of all living ImageBridgeParent instances
*/
static std::map<base::ProcessId, ImageBridgeParent*> sImageBridges;
static MessageLoop* sMainLoop;
};
} // layers