Bug 1176542 - Trace the window object in the TCPSocket child proxy. r=mccr8
authorJosh Matthews <josh@joshmatthews.net>
Wed, 08 Jul 2015 16:06:33 -0400
changeset 283616 e9bbcf97e8250d16c2e8cab95e6713b5436b8cb1
parent 283615 d4b9c91aa19ee420376c88edcf5d8bf362c00a67
child 283617 5d2047a4e54e8c8f7ad98a236665072f89786709
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1176542
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1176542 - Trace the window object in the TCPSocket child proxy. r=mccr8
dom/network/TCPSocketChild.cpp
dom/network/TCPSocketChild.h
--- a/dom/network/TCPSocketChild.cpp
+++ b/dom/network/TCPSocketChild.cpp
@@ -44,47 +44,63 @@ DeserializeArrayBuffer(JS::Handle<JSObje
   return true;
 }
 
 } // namespace IPC
 
 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)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TCPSocketChildBase)
   NS_INTERFACE_MAP_ENTRY(nsITCPSocketChild)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 TCPSocketChildBase::TCPSocketChildBase()
 : mIPCOpen(false)
 {
+  mozilla::HoldJSObjects(this);
 }
 
 TCPSocketChildBase::~TCPSocketChildBase()
 {
+  mozilla::DropJSObjects(this);
 }
 
 NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketChild::Release(void)
 {
   nsrefcnt refcnt = TCPSocketChildBase::Release();
   if (refcnt == 1 && mIPCOpen) {
     PTCPSocketChild::SendRequestDelete();
     return 1;
   }
   return refcnt;
 }
 
 TCPSocketChild::TCPSocketChild()
-: mWindowObj(nullptr)
-, mHost()
+: mHost()
 , mPort(0)
 {
 }
 
 void TCPSocketChild::Init(const nsString& aHost, const uint16_t& aPort) {
   mHost = aHost;
   mPort = aPort;
 }
--- a/dom/network/TCPSocketChild.h
+++ b/dom/network/TCPSocketChild.h
@@ -18,27 +18,28 @@
 
 class nsITCPSocketInternal;
 
 namespace mozilla {
 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();
   void ReleaseIPDLReference();
 
 protected:
   TCPSocketChildBase();
   virtual ~TCPSocketChildBase();
 
   nsCOMPtr<nsITCPSocketInternal> mSocket;
+  JS::Heap<JSObject*> mWindowObj;
   bool mIPCOpen;
 };
 
 class TCPSocketChild : public mozilla::net::PTCPSocketChild
                      , public TCPSocketChildBase
 {
 public:
   NS_DECL_NSITCPSOCKETCHILD
@@ -51,17 +52,16 @@ public:
 
   virtual bool RecvCallback(const nsString& aType,
                             const CallbackData& aData,
                             const nsString& aReadyState) override;
   virtual bool RecvRequestDelete() override;
   virtual bool RecvUpdateBufferedAmount(const uint32_t& aBufferred,
                                         const uint32_t& aTrackingNumber) override;
 private:
-  JSObject* mWindowObj;
   nsString mHost;
   uint16_t mPort;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif