Bug 1365894 - Make SystemGroupImpl be a normal ref-counted object. draft
authorJames Cheng <jacheng@mozilla.com>
Fri, 15 Sep 2017 16:22:49 +0800
changeset 666816 ab3672d1dade1c8eb5e19819970890276c3d37c7
parent 666598 30a386ff1192cba08a2f899343f81f6946bc6148
child 666817 09d17dedc93df970882648a20e76c8d7fec04e2f
push id80498
push userbmo:jacheng@mozilla.com
push dateTue, 19 Sep 2017 06:50:51 +0000
bugs1365894
milestone57.0a1
Bug 1365894 - Make SystemGroupImpl be a normal ref-counted object. MozReview-Commit-ID: LUcoBhNx2M5
xpcom/threads/SystemGroup.cpp
--- a/xpcom/threads/SystemGroup.cpp
+++ b/xpcom/threads/SystemGroup.cpp
@@ -11,50 +11,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;
 }