зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1048581 - Part 2: MobileConnection shouldn't be shutdown if JS still keeps a ref to it. r=smaug
This commit is contained in:
Родитель
8759e5fe89
Коммит
26cd181655
|
@ -85,6 +85,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MobileConnection,
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MobileConnection,
|
||||||
DOMEventTargetHelper)
|
DOMEventTargetHelper)
|
||||||
|
tmp->Shutdown();
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mVoice)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mVoice)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mData)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mData)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||||
|
@ -126,19 +127,28 @@ MobileConnection::MobileConnection(nsPIDOMWindow* aWindow, uint32_t aClientId)
|
||||||
void
|
void
|
||||||
MobileConnection::Shutdown()
|
MobileConnection::Shutdown()
|
||||||
{
|
{
|
||||||
if (mProvider && mListener) {
|
if (mListener) {
|
||||||
|
if (mProvider) {
|
||||||
|
mProvider->UnregisterMobileConnectionMsg(mClientId, mListener);
|
||||||
|
}
|
||||||
|
|
||||||
mListener->Disconnect();
|
mListener->Disconnect();
|
||||||
mProvider->UnregisterMobileConnectionMsg(mClientId, mListener);
|
|
||||||
mProvider = nullptr;
|
|
||||||
mListener = nullptr;
|
mListener = nullptr;
|
||||||
mVoice = nullptr;
|
|
||||||
mData = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MobileConnection::~MobileConnection()
|
MobileConnection::~MobileConnection()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(!(mProvider || mListener || mVoice || mData));
|
Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MobileConnection::DisconnectFromOwner()
|
||||||
|
{
|
||||||
|
DOMEventTargetHelper::DisconnectFromOwner();
|
||||||
|
// Event listeners can't be handled anymore, so we can shutdown
|
||||||
|
// the MobileConnection.
|
||||||
|
Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject*
|
JSObject*
|
||||||
|
|
|
@ -41,6 +41,9 @@ public:
|
||||||
void
|
void
|
||||||
Shutdown();
|
Shutdown();
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
DisconnectFromOwner() MOZ_OVERRIDE;
|
||||||
|
|
||||||
nsPIDOMWindow*
|
nsPIDOMWindow*
|
||||||
GetParentObject() const
|
GetParentObject() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,22 +10,9 @@
|
||||||
|
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnectionArray)
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MobileConnectionArray,
|
||||||
|
mWindow,
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MobileConnectionArray)
|
mMobileConnections)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow)
|
|
||||||
// Notify our mobile connections that we're going away.
|
|
||||||
tmp->DropConnections();
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MobileConnectionArray)
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileConnections)
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(MobileConnectionArray)
|
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(MobileConnectionArray)
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(MobileConnectionArray)
|
||||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(MobileConnectionArray)
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(MobileConnectionArray)
|
||||||
|
@ -49,7 +36,6 @@ MobileConnectionArray::MobileConnectionArray(nsPIDOMWindow* aWindow)
|
||||||
|
|
||||||
MobileConnectionArray::~MobileConnectionArray()
|
MobileConnectionArray::~MobileConnectionArray()
|
||||||
{
|
{
|
||||||
DropConnections();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -63,18 +49,6 @@ MobileConnectionArray::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
MobileConnectionArray::DropConnections()
|
|
||||||
{
|
|
||||||
if (mInitialized) {
|
|
||||||
for (uint32_t i = 0; i < mMobileConnections.Length(); i++) {
|
|
||||||
mMobileConnections[i]->Shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mMobileConnections.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
nsPIDOMWindow*
|
nsPIDOMWindow*
|
||||||
MobileConnectionArray::GetParentObject() const
|
MobileConnectionArray::GetParentObject() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,9 +45,6 @@ private:
|
||||||
void
|
void
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
void
|
|
||||||
DropConnections();
|
|
||||||
|
|
||||||
bool mInitialized;
|
bool mInitialized;
|
||||||
|
|
||||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче