Bug 1477753: Implement missing cycle collection hooks for SharedMap. r=mccr8 draft
authorKris Maglione <maglione.k@gmail.com>
Thu, 26 Jul 2018 14:36:57 -0700
changeset 823656 b7697484e3cb8a3b5c77332ddca4019160e7fe80
parent 823464 ad1674e9152da31151ab9f9f099f83ca4ff2d832
push id117752
push usermaglione.k@gmail.com
push dateFri, 27 Jul 2018 18:38:37 +0000
reviewersmccr8
bugs1477753
milestone63.0a1
Bug 1477753: Implement missing cycle collection hooks for SharedMap. r=mccr8 MozReview-Commit-ID: E0ncT3e1Wb2
dom/base/nsFrameMessageManager.cpp
dom/ipc/SharedMap.cpp
dom/ipc/SharedMap.h
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -121,28 +121,30 @@ ImplCycleCollectionTraverse(nsCycleColle
   ImplCycleCollectionTraverse(aCallback, aField.mWeakListener, aName, aFlags);
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsFrameMessageManager)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsFrameMessageManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mListeners)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChildManagers)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSharedData)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsFrameMessageManager)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mInitialProcessData)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsFrameMessageManager)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mListeners)
   for (int32_t i = tmp->mChildManagers.Length(); i > 0; --i) {
     tmp->mChildManagers[i - 1]->Disconnect(false);
   }
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mChildManagers)
+  NS_IMPL_CYCLE_COLLECTION_UNLINK(mSharedData)
   tmp->mInitialProcessData.setNull();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameMessageManager)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentFrameMessageManager)
 
   /* Message managers in child process implement nsIMessageSender.
--- a/dom/ipc/SharedMap.cpp
+++ b/dom/ipc/SharedMap.cpp
@@ -509,11 +509,19 @@ SharedMapChangeEvent::Constructor(EventT
   event->SetTrusted(trusted);
   event->SetComposed(aInit.mComposed);
 
   event->mChangedKeys = aInit.mChangedKeys;
 
   return event.forget();
 }
 
+NS_IMPL_CYCLE_COLLECTION_INHERITED(WritableSharedMap, SharedMap, mReadOnly)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WritableSharedMap)
+NS_INTERFACE_MAP_END_INHERITING(SharedMap)
+
+NS_IMPL_ADDREF_INHERITED(WritableSharedMap, SharedMap)
+NS_IMPL_RELEASE_INHERITED(WritableSharedMap, SharedMap)
+
 } // ipc
 } // dom
 } // mozilla
--- a/dom/ipc/SharedMap.h
+++ b/dom/ipc/SharedMap.h
@@ -317,16 +317,18 @@ protected:
   // offsets are relative to this pointer, and Entry objects access their
   // structured clone data by indexing this pointer.
   char* Data() { return mMap.get<char>().get(); }
 };
 
 class WritableSharedMap final : public SharedMap
 {
 public:
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(WritableSharedMap, SharedMap)
 
   WritableSharedMap();
 
   // Sets the value of the given (UTF-8 encoded) key to a structured clone
   // snapshot of the given value.
   void Set(JSContext* cx, const nsACString& name, JS::HandleValue value, ErrorResult& aRv);
 
   // Deletes the given (UTF-8 encoded) key from the map.