Bug 1382095 - Fix Refcountable<> helper to avoid size mismatch in the memory leak logging table. draft
authorJan-Ivar Bruaroey <jib@mozilla.com>
Sat, 01 Jul 2017 21:37:18 -0400
changeset 610990 a1e23adeb54a8753dac6313eed0d6a30cb5c2a88
parent 610989 e946dc6555af0b26eab20d60bbc18130b6d91d81
child 638030 470a6e4ce643c7fc25527d9cc6be16bd2b03c276
push id69080
push userjbruaroey@mozilla.com
push dateWed, 19 Jul 2017 02:43:31 +0000
bugs1382095
milestone56.0a1
Bug 1382095 - Fix Refcountable<> helper to avoid size mismatch in the memory leak logging table. MozReview-Commit-ID: 5i0iP9aDfHF
dom/media/systemservices/MediaUtils.h
--- a/dom/media/systemservices/MediaUtils.h
+++ b/dom/media/systemservices/MediaUtils.h
@@ -319,21 +319,38 @@ private:
  * Lists in particular often aren't ref-countable, yet are expensive to copy,
  * e.g. nsTArray<RefPtr<Foo>>. Refcountable can be used to make such objects
  * (or owning smart-pointers to such objects) refcountable.
  *
  * Technical limitation: A template specialization is needed for types that take
  * a constructor. Please add below (UniquePtr covers a lot of ground though).
  */
 
-template<typename T>
-class Refcountable : public T
+class RefcountableBase
 {
 public:
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Refcountable<T>)
+  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RefcountableBase)
+protected:
+  virtual ~RefcountableBase() {}
+};
+
+template<typename T>
+class Refcountable : public T, public RefcountableBase
+{
+public:
+  NS_METHOD_(MozExternalRefCountType) AddRef()
+  {
+    return RefcountableBase::AddRef();
+  }
+
+  NS_METHOD_(MozExternalRefCountType) Release()
+  {
+    return RefcountableBase::Release();
+  }
+
 private:
   ~Refcountable<T>() {}
 };
 
 template<typename T>
 class Refcountable<UniquePtr<T>> : public UniquePtr<T>
 {
 public: