Bug 1334421 - Don't use templated class for refcount macros in MediaParent. r?jib draft
authorAndreas Pehrson <pehrsons@gmail.com>
Mon, 20 Mar 2017 16:55:31 +0100
changeset 503505 da576900234a8ea01f61c1a8a48e8635063edbb2
parent 503306 7513b3f42058e9bcf9950d4acf4647d4ad2240f0
child 503506 6e7376bc992fa2688110ab134ce16ffee645b73f
push id50594
push userbmo:pehrson@telenordigital.com
push dateThu, 23 Mar 2017 08:20:17 +0000
reviewersjib
bugs1334421
milestone55.0a1
Bug 1334421 - Don't use templated class for refcount macros in MediaParent. r?jib The assert in bug 1334421 mentions the MOZ_COUNT_{C|D}TOR macros, but the same comment seems to apply to the NS_LogAddRef that's part of the NS_INLINE_DECL_THREADSAFE_REFCOUNTING macro. This fixes it for me. MozReview-Commit-ID: CPjdO8YBbt0
dom/media/systemservices/MediaParent.h
--- a/dom/media/systemservices/MediaParent.h
+++ b/dom/media/systemservices/MediaParent.h
@@ -35,26 +35,37 @@ protected:
                                                          const bool& aOnlyPrivateBrowsing) = 0;
   virtual void
   ActorDestroy(ActorDestroyReason aWhy) = 0;
 
   bool SendGetPrincipalKeyResponse(const uint32_t& aRequestId,
                                    nsCString aKey);
 };
 
+/**
+ * Dummy class to avoid a templated class being passed to the refcounting macro
+ * (see Bug 1334421 for what happens then)
+ */
+class RefCountedParent
+{
+public:
+  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RefCountedParent)
+
+protected:
+  virtual ~RefCountedParent() {}
+};
+
 // Super = PMediaParent or NonE10s
 
 template<class Super>
-class Parent : public Super
+class Parent : public RefCountedParent, public Super
 {
   typedef mozilla::ipc::IProtocol::ActorDestroyReason
       ActorDestroyReason;
 public:
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Parent<Super>)
-
   virtual mozilla::ipc::IPCResult
   RecvGetPrincipalKey(const uint32_t& aRequestId,
                       const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
                       const bool& aPersist) override;
   virtual mozilla::ipc::IPCResult RecvSanitizeOriginKeys(const uint64_t& aSinceWhen,
                                                          const bool& aOnlyPrivateBrowsing) override;
   virtual void ActorDestroy(ActorDestroyReason aWhy) override;