Bug 1124452 - Ensure the widget continues to be destroyed on the main thread. r=BenWa

--HG--
extra : rebase_source : 012cfddceefea66299e3476d2a4ae831a586ad1c
This commit is contained in:
Kartikaya Gupta 2015-01-29 12:57:55 -05:00
parent cdfc8917b3
commit 2326c50381
5 changed files with 24 additions and 0 deletions

View File

@ -157,6 +157,7 @@ public:
int aArg = 0) {}
GeckoContentController() {}
virtual void Destroy() {}
protected:
// Protected destructor, to discourage deletion outside of Release():

View File

@ -83,3 +83,17 @@ ChromeProcessController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aSc
{
APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
}
void
ChromeProcessController::Destroy()
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ChromeProcessController::Destroy));
return;
}
MOZ_ASSERT(MessageLoop::current() == mUILoop);
mWidget = nullptr;
}

View File

@ -27,6 +27,7 @@ class ChromeProcessController : public mozilla::layers::GeckoContentController
public:
explicit ChromeProcessController(nsIWidget* aWidget);
virtual void Destroy() MOZ_OVERRIDE;
// GeckoContentController interface
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) MOZ_OVERRIDE;

View File

@ -88,6 +88,13 @@ CompositorParent::LayerTreeState::LayerTreeState()
{
}
CompositorParent::LayerTreeState::~LayerTreeState()
{
if (mController) {
mController->Destroy();
}
}
typedef map<uint64_t, CompositorParent::LayerTreeState> LayerTreeMap;
static LayerTreeMap sIndirectLayerTrees;
static StaticAutoPtr<mozilla::Monitor> sIndirectLayerTreesLock;

View File

@ -291,6 +291,7 @@ public:
struct LayerTreeState {
LayerTreeState();
~LayerTreeState();
nsRefPtr<Layer> mRoot;
nsRefPtr<GeckoContentController> mController;
CompositorParent* mParent;