Bug 1404198: Part 2d - Switch to NS_NewTimer* in widget. r=njn

MozReview-Commit-ID: G4S8q9DYPS0

--HG--
extra : rebase_source : 9c6da05bf2ef3cfee551879879330a85688b1f5d
This commit is contained in:
Kris Maglione 2017-10-15 23:12:54 -07:00
parent d1f06996d7
commit c2da8a30a3
7 changed files with 17 additions and 19 deletions

View file

@ -2916,7 +2916,7 @@ IMEInputHandler::ResetTimer()
if (mTimer) { if (mTimer) {
mTimer->Cancel(); mTimer->Cancel();
} else { } else {
mTimer = do_CreateInstance(NS_TIMER_CONTRACTID); mTimer = NS_NewTimer();
NS_ENSURE_TRUE(mTimer, ); NS_ENSURE_TRUE(mTimer, );
} }
mTimer->InitWithNamedFuncCallback(FlushPendingMethods, this, 0, mTimer->InitWithNamedFuncCallback(FlushPendingMethods, this, 0,

View file

@ -17,7 +17,7 @@ nsMacDockSupport::nsMacDockSupport()
, mProgressState(STATE_NO_PROGRESS) , mProgressState(STATE_NO_PROGRESS)
, mProgressFraction(0.0) , mProgressFraction(0.0)
{ {
mProgressTimer = do_CreateInstance(NS_TIMER_CONTRACTID); mProgressTimer = NS_NewTimer();
} }
nsMacDockSupport::~nsMacDockSupport() nsMacDockSupport::~nsMacDockSupport()
@ -133,7 +133,7 @@ bool nsMacDockSupport::InitProgress()
} }
if (!mAppIcon) { if (!mAppIcon) {
mProgressTimer = do_CreateInstance(NS_TIMER_CONTRACTID); mProgressTimer = NS_NewTimer();
mAppIcon = [[NSImage imageNamed:@"NSApplicationIcon"] retain]; mAppIcon = [[NSImage imageNamed:@"NSApplicationIcon"] retain];
mProgressBackground = [mAppIcon copyWithZone:nil]; mProgressBackground = [mAppIcon copyWithZone:nil];
mTheme = new nsNativeThemeCocoa(); mTheme = new nsNativeThemeCocoa();

View file

@ -1992,8 +1992,8 @@ nsIWidget::SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint, bool aLongTap,
int elapse = Preferences::GetInt("ui.click_hold_context_menus.delay", int elapse = Preferences::GetInt("ui.click_hold_context_menus.delay",
TOUCH_INJECT_LONG_TAP_DEFAULT_MSEC); TOUCH_INJECT_LONG_TAP_DEFAULT_MSEC);
if (!mLongTapTimer) { if (!mLongTapTimer) {
mLongTapTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv); mLongTapTimer = NS_NewTimer();
if (NS_FAILED(rv)) { if (!mLongTapTimer) {
SynthesizeNativeTouchPoint(pointerId, TOUCH_CANCEL, SynthesizeNativeTouchPoint(pointerId, TOUCH_CANCEL,
aPoint, 0, 0, nullptr); aPoint, 0, 0, nullptr);
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;

View file

@ -154,7 +154,7 @@ nsIdleServiceDaily::Observe(nsISupports *,
nsIdleServiceDaily::nsIdleServiceDaily(nsIIdleService* aIdleService) nsIdleServiceDaily::nsIdleServiceDaily(nsIIdleService* aIdleService)
: mIdleService(aIdleService) : mIdleService(aIdleService)
, mTimer(do_CreateInstance(NS_TIMER_CONTRACTID)) , mTimer(NS_NewTimer())
, mCategoryObservers(OBSERVER_TOPIC_IDLE_DAILY) , mCategoryObservers(OBSERVER_TOPIC_IDLE_DAILY)
, mShutdownInProgress(false) , mShutdownInProgress(false)
, mExpectedTriggerTime(0) , mExpectedTriggerTime(0)
@ -451,9 +451,8 @@ nsIdleService::AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS)
// Create our timer callback if it's not there already. // Create our timer callback if it's not there already.
if (!mTimer) { if (!mTimer) {
nsresult rv; mTimer = NS_NewTimer();
mTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv); NS_ENSURE_TRUE(mTimer, NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_SUCCESS(rv, rv);
} }
// Check if the newly added observer has a smaller wait time than what we // Check if the newly added observer has a smaller wait time than what we

View file

@ -636,7 +636,7 @@ nsNativeTheme::QueueAnimatedContentForRefresh(nsIContent* aContent,
timeout = std::min(mAnimatedContentTimeout, timeout); timeout = std::min(mAnimatedContentTimeout, timeout);
if (!mAnimatedContentTimer) { if (!mAnimatedContentTimer) {
mAnimatedContentTimer = do_CreateInstance(NS_TIMER_CONTRACTID); mAnimatedContentTimer = NS_NewTimer();
NS_ENSURE_TRUE(mAnimatedContentTimer, false); NS_ENSURE_TRUE(mAnimatedContentTimer, false);
} }

View file

@ -455,11 +455,11 @@ public:
// We need to listen to both the xpcom shutdown message and our timer, and // We need to listen to both the xpcom shutdown message and our timer, and
// fire when the first of either of these two messages is received. // fire when the first of either of these two messages is received.
nsresult rv; nsresult rv;
mTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv); rv = NS_NewTimerWithObserver(getter_AddRefs(mTimer),
this, 500, nsITimer::TYPE_ONE_SHOT);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return; return;
} }
mTimer->Init(this, 500, nsITimer::TYPE_ONE_SHOT);
nsCOMPtr<nsIObserverService> observerService = nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1"); do_GetService("@mozilla.org/observer-service;1");

View file

@ -159,16 +159,15 @@ private:
nsTimerCallbackFunc aCallbackFunc, nsTimerCallbackFunc aCallbackFunc,
const char* aName) const char* aName)
{ {
mPickerCallbackTimer = do_CreateInstance("@mozilla.org/timer;1"); NS_NewTimerWithFuncCallback(getter_AddRefs(mPickerCallbackTimer),
aCallbackFunc,
aTarget,
kDialogTimerTimeout,
nsITimer::TYPE_REPEATING_SLACK,
aName);
if (!mPickerCallbackTimer) { if (!mPickerCallbackTimer) {
NS_WARNING("do_CreateInstance for timer failed??"); NS_WARNING("do_CreateInstance for timer failed??");
return;
} }
mPickerCallbackTimer->InitWithNamedFuncCallback(aCallbackFunc,
aTarget,
kDialogTimerTimeout,
nsITimer::TYPE_REPEATING_SLACK,
aName);
} }
nsCOMPtr<nsITimer> mPickerCallbackTimer; nsCOMPtr<nsITimer> mPickerCallbackTimer;
}; };