Bug 1176542 - Trace the window object in the TCPSocket child proxy. r=mccr8

This commit is contained in:
Josh Matthews 2015-07-08 16:06:33 -04:00
parent 53fd117b5f
commit e76b9d6234
2 changed files with 21 additions and 5 deletions

View File

@ -49,7 +49,22 @@ DeserializeArrayBuffer(JS::Handle<JSObject*> aObj,
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION(TCPSocketChildBase, mSocket)
NS_IMPL_CYCLE_COLLECTION_CLASS(TCPSocketChildBase)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(TCPSocketChildBase)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSocket)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(TCPSocketChildBase)
tmp->mWindowObj = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSocket)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(TCPSocketChildBase)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mWindowObj)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(TCPSocketChildBase)
NS_IMPL_CYCLE_COLLECTING_RELEASE(TCPSocketChildBase)
@ -61,10 +76,12 @@ NS_INTERFACE_MAP_END
TCPSocketChildBase::TCPSocketChildBase()
: mIPCOpen(false)
{
mozilla::HoldJSObjects(this);
}
TCPSocketChildBase::~TCPSocketChildBase()
{
mozilla::DropJSObjects(this);
}
NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketChild::Release(void)
@ -78,8 +95,7 @@ NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketChild::Release(void)
}
TCPSocketChild::TCPSocketChild()
: mWindowObj(nullptr)
, mHost()
: mHost()
, mPort(0)
{
}

View File

@ -23,7 +23,7 @@ namespace dom {
class TCPSocketChildBase : public nsITCPSocketChild {
public:
NS_DECL_CYCLE_COLLECTION_CLASS(TCPSocketChildBase)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TCPSocketChildBase)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
void AddIPDLReference();
@ -34,6 +34,7 @@ protected:
virtual ~TCPSocketChildBase();
nsCOMPtr<nsITCPSocketInternal> mSocket;
JS::Heap<JSObject*> mWindowObj;
bool mIPCOpen;
};
@ -56,7 +57,6 @@ public:
virtual bool RecvUpdateBufferedAmount(const uint32_t& aBufferred,
const uint32_t& aTrackingNumber) override;
private:
JSObject* mWindowObj;
nsString mHost;
uint16_t mPort;
};