Bug 1348738 - (Part 0) Convert nsRepeatService::gInstance to be a file-scoped StaticRefPtr. r=dholbert

MozReview-Commit-ID: KSLs2tEFf7m

--HG--
extra : rebase_source : 902d743ab118e9ff93a364fec13f78eb118e3c73
This commit is contained in:
KuoE0 2017-03-29 11:48:56 +08:00
parent 49d40030b6
commit 123b9045b8
2 changed files with 8 additions and 8 deletions

View File

@ -13,7 +13,9 @@
#include "nsRepeatService.h"
#include "nsIServiceManager.h"
nsRepeatService* nsRepeatService::gInstance = nullptr;
using namespace mozilla;
static StaticRefPtr<nsRepeatService> gRepeatService;
nsRepeatService::nsRepeatService()
: mCallback(nullptr), mCallbackData(nullptr)
@ -25,20 +27,19 @@ nsRepeatService::~nsRepeatService()
NS_ASSERTION(!mCallback && !mCallbackData, "Callback was not removed before shutdown");
}
nsRepeatService*
/* static */ nsRepeatService*
nsRepeatService::GetInstance()
{
if (!gInstance) {
gInstance = new nsRepeatService();
NS_IF_ADDREF(gInstance);
if (!gRepeatService) {
gRepeatService = new nsRepeatService();
}
return gInstance;
return gRepeatService;
}
/*static*/ void
nsRepeatService::Shutdown()
{
NS_IF_RELEASE(gInstance);
gRepeatService = nullptr;
}
void nsRepeatService::Start(Callback aCallback, void* aCallbackData,

View File

@ -53,7 +53,6 @@ private:
Callback mCallback;
void* mCallbackData;
nsCOMPtr<nsITimer> mRepeatTimer;
static nsRepeatService* gInstance;
}; // class nsRepeatService