From ea0bad32454f16716f9d2ae987ad47e7e187fd1e Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Tue, 24 Jul 2012 13:50:45 -0400 Subject: [PATCH] Bug 776979 - consolidate InitWithFuncCallback calls into nsTimeout::InitTimer; r=bz --- dom/base/nsGlobalWindow.cpp | 18 ++++-------------- dom/base/nsGlobalWindow.h | 5 +++++ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index dec4ced4326..7c21a5bb9ce 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -9400,9 +9400,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler, nsRefPtr 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; diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index b9187df6db9..8583a780feb 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -153,6 +153,11 @@ struct nsTimeout : PRCList return static_cast(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 mWindow;