Bug 1382095 - Fix Refcountable<> helper to avoid size mismatch in the memory leak logging table.
MozReview-Commit-ID: 5i0iP9aDfHF
--- 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: