mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
Bug 1334677 Make PostMessageRunnable handle the port being cycle collected. r=baku
This commit is contained in:
parent
d8b5080e39
commit
de35243abb
@ -63,7 +63,14 @@ public:
|
||||
NS_IMETHOD
|
||||
Run() override
|
||||
{
|
||||
MOZ_ASSERT(mPort);
|
||||
NS_ASSERT_OWNINGTHREAD(Runnable);
|
||||
|
||||
// The port can be cycle collected while this runnable is pending in
|
||||
// the event queue.
|
||||
if (!mPort) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mPort->mPostMessageRunnable == this);
|
||||
|
||||
nsresult rv = DispatchMessage();
|
||||
@ -81,6 +88,8 @@ public:
|
||||
nsresult
|
||||
Cancel() override
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(Runnable);
|
||||
|
||||
mPort = nullptr;
|
||||
mData = nullptr;
|
||||
return NS_OK;
|
||||
@ -90,6 +99,8 @@ private:
|
||||
nsresult
|
||||
DispatchMessage() const
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(Runnable);
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> globalObject = mPort->GetParentObject();
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
|
Loading…
Reference in New Issue
Block a user