зеркало из 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,
|
||||
DOMEventTargetHelper)
|
||||
tmp->Shutdown();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mVoice)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mData)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
@ -126,19 +127,28 @@ MobileConnection::MobileConnection(nsPIDOMWindow* aWindow, uint32_t aClientId)
|
|||
void
|
||||
MobileConnection::Shutdown()
|
||||
{
|
||||
if (mProvider && mListener) {
|
||||
if (mListener) {
|
||||
if (mProvider) {
|
||||
mProvider->UnregisterMobileConnectionMsg(mClientId, mListener);
|
||||
}
|
||||
|
||||
mListener->Disconnect();
|
||||
mProvider->UnregisterMobileConnectionMsg(mClientId, mListener);
|
||||
mProvider = nullptr;
|
||||
mListener = nullptr;
|
||||
mVoice = nullptr;
|
||||
mData = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
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*
|
||||
|
|
|
@ -41,6 +41,9 @@ public:
|
|||
void
|
||||
Shutdown();
|
||||
|
||||
virtual void
|
||||
DisconnectFromOwner() MOZ_OVERRIDE;
|
||||
|
||||
nsPIDOMWindow*
|
||||
GetParentObject() const
|
||||
{
|
||||
|
|
|
@ -10,22 +10,9 @@
|
|||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnectionArray)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MobileConnectionArray)
|
||||
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_COLLECTION_WRAPPERCACHE(MobileConnectionArray,
|
||||
mWindow,
|
||||
mMobileConnections)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(MobileConnectionArray)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(MobileConnectionArray)
|
||||
|
@ -49,7 +36,6 @@ MobileConnectionArray::MobileConnectionArray(nsPIDOMWindow* aWindow)
|
|||
|
||||
MobileConnectionArray::~MobileConnectionArray()
|
||||
{
|
||||
DropConnections();
|
||||
}
|
||||
|
||||
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*
|
||||
MobileConnectionArray::GetParentObject() const
|
||||
{
|
||||
|
|
|
@ -45,9 +45,6 @@ private:
|
|||
void
|
||||
Init();
|
||||
|
||||
void
|
||||
DropConnections();
|
||||
|
||||
bool mInitialized;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
|
|
Загрузка…
Ссылка в новой задаче