Bug 1365894 - Make SystemGroupImpl be a normal ref-counted object. r=ehsan
authorJames Cheng <jacheng@mozilla.com>
Mon, 09 Oct 2017 13:40:12 -0400
changeset 427731 3959033a31666770047dd460979032464a48ba66
parent 427730 bb1c5e40c33aa16f7a9443d81ab551376ad9a50e
child 427734 60bcd543f1420cb140fbd7c4363ff9fd9018f55f
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewersehsan
bugs1365894
milestone58.0a1
Bug 1365894 - Make SystemGroupImpl be a normal ref-counted object. r=ehsan MozReview-Commit-ID: LUcoBhNx2M5
xpcom/threads/SystemGroup.cpp
--- a/xpcom/threads/SystemGroup.cpp
+++ b/xpcom/threads/SystemGroup.cpp
@@ -12,50 +12,42 @@
 #include "nsINamed.h"
 
 using namespace mozilla;
 
 class SystemGroupImpl final : public SchedulerGroup
 {
 public:
   SystemGroupImpl();
-  ~SystemGroupImpl() {}
+  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SystemGroupImpl)
 
   static void InitStatic();
   static void ShutdownStatic();
   static SystemGroupImpl* Get();
 
   static bool Initialized() { return !!sSingleton; }
 
-  NS_METHOD_(MozExternalRefCountType) AddRef(void)
-  {
-    return 2;
-  }
-  NS_METHOD_(MozExternalRefCountType) Release(void)
-  {
-    return 1;
-  }
-
 private:
-  static UniquePtr<SystemGroupImpl> sSingleton;
+  ~SystemGroupImpl() = default;
+  static StaticRefPtr<SystemGroupImpl> sSingleton;
 };
 
-UniquePtr<SystemGroupImpl> SystemGroupImpl::sSingleton;
+StaticRefPtr<SystemGroupImpl> SystemGroupImpl::sSingleton;
 
 SystemGroupImpl::SystemGroupImpl()
 {
   CreateEventTargets(/* aNeedValidation = */ true);
 }
 
 /* static */ void
 SystemGroupImpl::InitStatic()
 {
   MOZ_ASSERT(!sSingleton);
   MOZ_ASSERT(NS_IsMainThread());
-  sSingleton = MakeUnique<SystemGroupImpl>();
+  sSingleton = new SystemGroupImpl();
 }
 
 /* static */ void
 SystemGroupImpl::ShutdownStatic()
 {
   sSingleton->Shutdown(true);
   sSingleton = nullptr;
 }