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 mozilla {
namespace dom { 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_ADDREF(TCPSocketChildBase)
NS_IMPL_CYCLE_COLLECTING_RELEASE(TCPSocketChildBase) NS_IMPL_CYCLE_COLLECTING_RELEASE(TCPSocketChildBase)
@ -61,10 +76,12 @@ NS_INTERFACE_MAP_END
TCPSocketChildBase::TCPSocketChildBase() TCPSocketChildBase::TCPSocketChildBase()
: mIPCOpen(false) : mIPCOpen(false)
{ {
mozilla::HoldJSObjects(this);
} }
TCPSocketChildBase::~TCPSocketChildBase() TCPSocketChildBase::~TCPSocketChildBase()
{ {
mozilla::DropJSObjects(this);
} }
NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketChild::Release(void) NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketChild::Release(void)
@ -78,8 +95,7 @@ NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketChild::Release(void)
} }
TCPSocketChild::TCPSocketChild() TCPSocketChild::TCPSocketChild()
: mWindowObj(nullptr) : mHost()
, mHost()
, mPort(0) , mPort(0)
{ {
} }

View File

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