Bug 776979 - consolidate InitWithFuncCallback calls into nsTimeout::InitTimer; r=bz

This commit is contained in:
Nathan Froyd 2012-07-24 13:50:45 -04:00
parent bdf70a2faf
commit ea0bad3245
2 changed files with 9 additions and 14 deletions

View File

@ -9400,9 +9400,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
nsRefPtr<nsTimeout> copy = timeout;
rv = timeout->mTimer->InitWithFuncCallback(TimerCallback, timeout,
realInterval,
nsITimer::TYPE_ONE_SHOT);
rv = timeout->InitTimer(TimerCallback, realInterval);
if (NS_FAILED(rv)) {
return rv;
}
@ -9637,10 +9635,7 @@ nsGlobalWindow::RescheduleTimeout(nsTimeout* aTimeout, const TimeStamp& now,
// platforms whether delay is positive or negative (which we
// know is always positive here, but cast anyways for
// consistency).
nsresult rv = aTimeout->mTimer->
InitWithFuncCallback(TimerCallback, aTimeout,
delay.ToMilliseconds(),
nsITimer::TYPE_ONE_SHOT);
nsresult rv = aTimeout->InitTimer(TimerCallback, delay.ToMilliseconds());
if (NS_FAILED(rv)) {
NS_ERROR("Error initializing timer for DOM timeout!");
@ -9982,11 +9977,7 @@ nsresult nsGlobalWindow::ResetTimersForNonBackgroundWindow()
timeout->mFiringDepth = firingDepth;
timeout->Release();
nsresult rv =
timeout->mTimer->InitWithFuncCallback(TimerCallback,
timeout,
delay.ToMilliseconds(),
nsITimer::TYPE_ONE_SHOT);
nsresult rv = timeout->InitTimer(TimerCallback, delay.ToMilliseconds());
if (NS_FAILED(rv)) {
NS_WARNING("Error resetting non background timer for DOM timeout!");
@ -10499,8 +10490,7 @@ nsGlobalWindow::ResumeTimeouts(bool aThawChildren)
t->mTimer = do_CreateInstance("@mozilla.org/timer;1");
NS_ENSURE_TRUE(t->mTimer, NS_ERROR_OUT_OF_MEMORY);
rv = t->mTimer->InitWithFuncCallback(TimerCallback, t, delay,
nsITimer::TYPE_ONE_SHOT);
rv = t->InitTimer(TimerCallback, delay);
if (NS_FAILED(rv)) {
t->mTimer = nsnull;
return rv;

View File

@ -153,6 +153,11 @@ struct nsTimeout : PRCList
return static_cast<nsTimeout*>(PR_PREV_LINK(this));
}
nsresult InitTimer(nsTimerCallbackFunc aFunc, PRUint64 delay) {
return mTimer->InitWithFuncCallback(aFunc, this, delay,
nsITimer::TYPE_ONE_SHOT);
}
// Window for which this timeout fires
nsRefPtr<nsGlobalWindow> mWindow;