diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index 35749031619..35737c74682 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -241,7 +241,8 @@ NS_IMETHODIMP nsRootAccessible::GetAccValue(nsAString& aAccValue) return GetURL(aAccValue); } -void nsRootAccessible::Notify(nsITimer *timer) + +NS_IMETHODIMP nsRootAccessible::Notify(nsITimer *timer) { if (mScrollPositionChangedTicks) { if (++mScrollPositionChangedTicks > 2) { @@ -269,6 +270,7 @@ void nsRootAccessible::Notify(nsITimer *timer) mLastScrolledPresShell = nsnull; } } + return NS_OK; } void nsRootAccessible::AddScrollListener(nsIPresShell *aPresShell) @@ -374,7 +376,7 @@ NS_IMETHODIMP nsRootAccessible::ScrollPositionDidChange(nsIScrollableView *aScro mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (NS_SUCCEEDED(rv)) { const PRUint32 kScrollPosCheckWait = 50; - mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kScrollPosCheckWait, PR_TRUE, NS_TYPE_REPEATING_SLACK); + mTimer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback*, this), kScrollPosCheckWait, nsITimer::TYPE_REPEATING_SLACK); } mScrollPositionChangedTicks = 1; mLastScrolledPresShell = weakShell; diff --git a/accessible/src/base/nsRootAccessible.h b/accessible/src/base/nsRootAccessible.h index da71bbaa8f7..a7cc956395c 100644 --- a/accessible/src/base/nsRootAccessible.h +++ b/accessible/src/base/nsRootAccessible.h @@ -51,7 +51,6 @@ #include "nsIWebProgressListener.h" #include "nsIWeakReference.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsIWebProgress.h" #include "nsIScrollPositionListener.h" #include "nsIScrollableView.h" @@ -134,7 +133,7 @@ class nsRootAccessible : public nsAccessible, NS_IMETHOD ScrollPositionDidChange(nsIScrollableView *aView, nscoord aX, nscoord aY); // ----- nsITimerCallback ------------------------------------ - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK NS_DECL_NSIACCESSIBLEDOCUMENT NS_DECL_NSIWEBPROGRESSLISTENER diff --git a/content/base/src/nsPagePrintTimer.cpp b/content/base/src/nsPagePrintTimer.cpp index 5dd907a3426..ba4114888c0 100644 --- a/content/base/src/nsPagePrintTimer.cpp +++ b/content/base/src/nsPagePrintTimer.cpp @@ -38,6 +38,7 @@ #include "nsPagePrintTimer.h" #include "nsPrintEngine.h" #include "nsIContentViewer.h" +#include "nsIServiceManager.h" NS_IMPL_ISUPPORTS1(nsPagePrintTimer, nsITimerCallback) @@ -71,7 +72,7 @@ nsPagePrintTimer::StartTimer(PRBool aUseDelay) if (NS_FAILED(result)) { NS_WARNING("unable to start the timer"); } else { - mTimer->Init(this, aUseDelay?mDelay:0, PR_TRUE, NS_TYPE_ONE_SHOT); + mTimer->InitWithCallback(this, aUseDelay?mDelay:0, nsITimer::TYPE_ONE_SHOT); } return result; } @@ -79,7 +80,7 @@ nsPagePrintTimer::StartTimer(PRBool aUseDelay) // nsITimerCallback -NS_IMETHODIMP_(void) +NS_IMETHODIMP nsPagePrintTimer::Notify(nsITimer *timer) { if (mPresContext && mDocViewerPrint) { @@ -105,6 +106,7 @@ nsPagePrintTimer::Notify(nsITimer *timer) } } } + return NS_OK; } void diff --git a/content/base/src/nsPagePrintTimer.h b/content/base/src/nsPagePrintTimer.h index 7a77021709a..713d2768f52 100644 --- a/content/base/src/nsPagePrintTimer.h +++ b/content/base/src/nsPagePrintTimer.h @@ -39,7 +39,6 @@ // Timer Includes #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsITimelineService.h" // Interfaces @@ -66,7 +65,7 @@ public: virtual ~nsPagePrintTimer(); // nsITimerCallback - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK // Other Methods nsresult StartTimer(PRBool aUseDelay = PR_TRUE); diff --git a/content/base/src/nsSelection.cpp b/content/base/src/nsSelection.cpp index 777fc026c75..8e8560137fc 100644 --- a/content/base/src/nsSelection.cpp +++ b/content/base/src/nsSelection.cpp @@ -95,7 +95,6 @@ static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID); #include "nsIScrollableView.h" #include "nsIDeviceContext.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsIServiceManager.h" #include "nsIAutoCopy.h" #include "nsIEventQueue.h" @@ -602,7 +601,7 @@ public: return result; } - return mTimer->Init(this, mDelay); + return mTimer->InitWithCallback(this, mDelay, nsITimer::TYPE_ONE_SHOT); } nsresult Stop() @@ -631,7 +630,7 @@ public: return NS_OK; } - NS_IMETHOD_(void) Notify(nsITimer *timer) + NS_IMETHOD Notify(nsITimer *timer) { if (mSelection && mPresContext && mView) { @@ -640,7 +639,7 @@ public: nsIFrame *frame = (nsIFrame *)clientData; if (!frame) - return; + return NS_OK; //the frame passed in here will be a root frame for the view. there is no need to call the constrain //method here. the root frame has NO content now unfortunately... @@ -658,6 +657,7 @@ public: //mFrameSelection->HandleDrag(mPresContext, mFrame, mPoint); mSelection->DoAutoScrollView(mPresContext, mView, mPoint, PR_TRUE); } + return NS_OK; } private: nsSelection *mFrameSelection; diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index 92e330caeb2..5e2536f2c57 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -136,7 +136,6 @@ #include "nsIDOMHTMLTitleElement.h" #include "nsTimer.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsDOMError.h" #include "nsIScrollable.h" #include "nsContentPolicyUtils.h" @@ -280,7 +279,7 @@ public: NS_IMETHOD DoFragment(PRBool aFlag); // nsITimerCallback - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK // nsICSSLoaderObserver NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet* aSheet, @@ -2579,7 +2578,7 @@ HTMLContentSink::DidBuildModel(PRInt32 aQualityLevel) return NS_OK; } -NS_IMETHODIMP_(void) +NS_IMETHODIMP HTMLContentSink::Notify(nsITimer *timer) { MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::Notify()\n")); @@ -2610,6 +2609,7 @@ HTMLContentSink::Notify(nsITimer *timer) mNotificationTimer = 0; MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::Notify()\n")); MOZ_TIMER_STOP(mWatch); + return NS_OK; } NS_IMETHODIMP @@ -2666,7 +2666,7 @@ HTMLContentSink::WillInterrupt() SINK_TRACE(SINK_TRACE_REFLOW, ("HTMLContentSink::WillInterrupt: setting up timer with delay %d", delay)); - result = mNotificationTimer->Init(this, delay); + result = mNotificationTimer->InitWithCallback(this, delay, nsITimer::TYPE_ONE_SHOT); } } } diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index d2fb0366f8c..cf04ecb40b1 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -3644,7 +3644,7 @@ nsDocShell::RefreshURI(nsIURI * aURI, PRInt32 aDelay, PRBool aRepeat, PRBool aMe NS_ENSURE_TRUE(timer, NS_ERROR_FAILURE); mRefreshURIList->AppendElement(timer); // owning timer ref - timer->Init(refreshTimer, aDelay); + timer->InitWithCallback(refreshTimer, aDelay, nsITimer::TYPE_ONE_SHOT); } return NS_OK; } @@ -3890,7 +3890,7 @@ nsDocShell::RefreshURIFromQueue() // load comes through before the timer can go off, the timer will // get cancelled in CancelRefreshURITimer() mRefreshURIList->ReplaceElementAt(timer, n); - timer->Init(refreshInfo, delay); + timer->InitWithCallback(refreshInfo, delay, nsITimer::TYPE_ONE_SHOT); } } } // while @@ -6587,7 +6587,7 @@ NS_INTERFACE_MAP_END_THREADSAFE ///***************************************************************************** // nsRefreshTimer::nsITimerCallback //***************************************************************************** -NS_IMETHODIMP_(void) +NS_IMETHODIMP nsRefreshTimer::Notify(nsITimer * aTimer) { NS_ASSERTION(mDocShell, "DocShell is somehow null"); @@ -6599,10 +6599,10 @@ nsRefreshTimer::Notify(nsITimer * aTimer) PRBool allowRedirects = PR_TRUE; mDocShell->GetAllowMetaRedirects(&allowRedirects); if (!allowRedirects) - return; + return NS_OK; // Get the delay count - PRUint32 delay; - delay = aTimer->GetDelay(); + PRUint32 delay = 0; + aTimer->GetDelay(&delay); // Get the current uri from the docshell. nsCOMPtr webNav(do_QueryInterface(mDocShell)); nsCOMPtr currURI; @@ -6633,13 +6633,14 @@ nsRefreshTimer::Notify(nsITimer * aTimer) */ mDocShell->LoadURI(mURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, PR_TRUE); - return; + return NS_OK; } else loadInfo->SetLoadType(nsIDocShellLoadInfo::loadRefresh); mDocShell->LoadURI(mURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, PR_TRUE); } + return NS_OK; } //***************************************************************************** diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index d0eaf5a6509..ae510facf9a 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -32,6 +32,7 @@ #include "nsIPref.h" #include "nsVoidArray.h" #include "nsIScriptContext.h" +#include "nsITimer.h" #include "nsCDocShell.h" #include "nsIDocShellTreeOwner.h" @@ -69,7 +70,6 @@ #include "nsISHistory.h" #include "nsIStringBundle.h" #include "nsISupportsArray.h" -#include "nsITimerCallback.h" #include "nsIWebNavigation.h" #include "nsIWebPageDescriptor.h" #include "nsIWebProgressListener.h" @@ -116,9 +116,8 @@ public: nsRefreshTimer(); NS_DECL_ISUPPORTS - - // nsITimerCallback interface - NS_IMETHOD_(void) Notify(nsITimer * timer); + NS_DECL_NSITIMERCALLBACK + PRInt32 GetDelay() { return mDelay ;} nsCOMPtr mDocShell; diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index d697d7930a8..68be47fda28 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -4428,8 +4428,8 @@ GlobalWindowImpl::SetTimeoutOrInterval(PRBool aIsInterval, PRInt32 *aReturn) return err; } - err = timeout->timer->Init(TimerCallback, timeout, (PRInt32)interval, - PR_TRUE); + err = timeout->timer->InitWithFuncCallback(TimerCallback, timeout, (PRInt32)interval, + nsITimer::TYPE_ONE_SHOT); if (NS_OK != err) { DropTimeout(timeout); return err; @@ -4666,8 +4666,8 @@ GlobalWindowImpl::RunTimeout(nsTimeoutImpl *aTimeout) // no big deal. if (timeout->timer) { - rv = timeout->timer->Init(TimerCallback, timeout, delay32, - PR_TRUE); + rv = timeout->timer->InitWithFuncCallback(TimerCallback, timeout, delay32, + nsITimer::TYPE_ONE_SHOT); // Likewise, don't return early even if we fail to // initialize the new OS timer. diff --git a/dom/src/base/nsJSEnvironment.cpp b/dom/src/base/nsJSEnvironment.cpp index 6be1e04774d..6fe8634ed80 100644 --- a/dom/src/base/nsJSEnvironment.cpp +++ b/dom/src/base/nsJSEnvironment.cpp @@ -1586,7 +1586,7 @@ nsJSContext::ScriptExecuted() return ScriptEvaluated(PR_FALSE); } -NS_IMETHODIMP_(void) +NS_IMETHODIMP nsJSContext::Notify(nsITimer *timer) { NS_ASSERTION(mContext, "No context in nsJSContext::Notify()!"); @@ -1596,6 +1596,7 @@ nsJSContext::Notify(nsITimer *timer) sReadyForGC = PR_TRUE; NS_RELEASE(sGCTimer); + return NS_OK; } void @@ -1625,8 +1626,9 @@ nsJSContext::FireGCTimer() static PRBool first = PR_TRUE; - sGCTimer->Init(this, first ? NS_FIRST_GC_DELAY : NS_GC_DELAY, - PR_TRUE); + sGCTimer->InitWithCallback(this, + first ? NS_FIRST_GC_DELAY : NS_GC_DELAY, + nsITimer::TYPE_ONE_SHOT); first = PR_FALSE; } diff --git a/dom/src/base/nsJSEnvironment.h b/dom/src/base/nsJSEnvironment.h index 2cbb022b54e..7a3be515315 100644 --- a/dom/src/base/nsJSEnvironment.h +++ b/dom/src/base/nsJSEnvironment.h @@ -45,7 +45,7 @@ #include "nsIObserver.h" #include "nsIScriptSecurityManager.h" #include "nsIXPCScriptNotify.h" -#include "nsITimerCallback.h" +#include "nsITimer.h" class nsJSContext : public nsIScriptContext, @@ -131,7 +131,7 @@ public: NS_DECL_NSIXPCSCRIPTNOTIFY - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK protected: nsresult InitClasses(); diff --git a/editor/composer/src/nsComposerCommandsUpdater.cpp b/editor/composer/src/nsComposerCommandsUpdater.cpp index db917eeb43c..c9978fbd590 100644 --- a/editor/composer/src/nsComposerCommandsUpdater.cpp +++ b/editor/composer/src/nsComposerCommandsUpdater.cpp @@ -23,7 +23,7 @@ #include "nsComposerCommandsUpdater.h" - +#include "nsIServiceManager.h" #include "nsIDOMDocument.h" #include "nsIDocument.h" #include "nsISelection.h" @@ -212,7 +212,9 @@ nsComposerCommandsUpdater::PrimeUpdateTimer() if (NS_FAILED(rv)) return rv; const PRUint32 kUpdateTimerDelay = 150; - return mUpdateTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kUpdateTimerDelay); + return mUpdateTimer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback*, this), + kUpdateTimerDelay, + nsITimer::TYPE_ONE_SHOT); } @@ -302,12 +304,13 @@ nsComposerCommandsUpdater::SelectionIsCollapsed() #pragma mark - #endif -void +nsresult nsComposerCommandsUpdater::Notify(nsITimer *timer) { NS_ASSERTION(timer == mUpdateTimer.get(), "Hey, this ain't my timer!"); mUpdateTimer = NULL; // release my hold TimerCallback(); + return NS_OK; } #if 0 diff --git a/editor/composer/src/nsComposerCommandsUpdater.h b/editor/composer/src/nsComposerCommandsUpdater.h index aa54ea8acd9..b6f4b472fb5 100644 --- a/editor/composer/src/nsComposerCommandsUpdater.h +++ b/editor/composer/src/nsComposerCommandsUpdater.h @@ -27,14 +27,13 @@ #ifndef nsComposerCommandsUpdater_h__ #define nsComposerCommandsUpdater_h__ +#include "nsCOMPtr.h" #include "nsString.h" #include "nsITimer.h" #include "nsISelectionListener.h" #include "nsIDocumentStateListener.h" #include "nsITransactionListener.h" -#include "nsITimerCallback.h" - class nsIEditor; class nsIDocShell; @@ -60,7 +59,7 @@ public: NS_DECL_NSIDOCUMENTSTATELISTENER // nsITimerCallback interfaces - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK /** nsITransactionListener interfaces */ diff --git a/editor/composer/src/nsInterfaceState.cpp b/editor/composer/src/nsInterfaceState.cpp index 16073fc0b5f..e03548d2322 100644 --- a/editor/composer/src/nsInterfaceState.cpp +++ b/editor/composer/src/nsInterfaceState.cpp @@ -40,7 +40,7 @@ #include "nsCOMPtr.h" - +#include "nsIServiceManager.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" #include "nsISelection.h" @@ -234,7 +234,9 @@ nsresult nsInterfaceState::PrimeUpdateTimer() if (NS_FAILED(rv)) return rv; const PRUint32 kUpdateTimerDelay = 150; - return mUpdateTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kUpdateTimerDelay); + return mUpdateTimer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback*, this), + kUpdateTimerDelay, + nsITimer::TYPE_ONE_SHOT); } @@ -330,12 +332,13 @@ nsInterfaceState::SelectionIsCollapsed() #endif -void +NS_IMETHODIMP nsInterfaceState::Notify(nsITimer *timer) { NS_ASSERTION(timer == mUpdateTimer.get(), "Hey, this ain't my timer!"); mUpdateTimer = NULL; // release my hold TimerCallback(); + return NS_OK; } #ifdef XP_MAC diff --git a/editor/composer/src/nsInterfaceState.h b/editor/composer/src/nsInterfaceState.h index 6a38dae3343..b1a347ca28a 100644 --- a/editor/composer/src/nsInterfaceState.h +++ b/editor/composer/src/nsInterfaceState.h @@ -46,7 +46,6 @@ #include "nsITransactionListener.h" #include "nsIWebShell.h" #include "nsITimer.h" -#include "nsITimerCallback.h" class nsIHTMLEditor; class nsIDOMDocument; @@ -74,7 +73,7 @@ public: NS_DECL_NSIDOCUMENTSTATELISTENER // nsITimerCallback interfaces - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK /** nsITransactionListener interfaces */ diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index 6466a30e636..279596f6d7f 100644 --- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -1200,7 +1200,8 @@ ChromeTooltipListener::MouseMove(nsIDOMEvent* aMouseEvent) if ( eventTarget ) mPossibleTooltipNode = do_QueryInterface(eventTarget); if ( mPossibleTooltipNode ) { - nsresult rv = mTooltipTimer->Init(sTooltipCallback, this, kTooltipShowTime, PR_TRUE); + nsresult rv = mTooltipTimer->InitWithFuncCallback(sTooltipCallback, this, kTooltipShowTime, + nsITimer::TYPE_ONE_SHOT); if (NS_FAILED(rv)) mPossibleTooltipNode = nsnull; } @@ -1332,7 +1333,8 @@ ChromeTooltipListener :: CreateAutoHideTimer ( ) mAutoHideTimer = do_CreateInstance("@mozilla.org/timer;1"); if ( mAutoHideTimer ) - mAutoHideTimer->Init(sAutoHideCallback, this, kTooltipAutoHideTime, PR_TRUE); + mAutoHideTimer->InitWithFuncCallback(sAutoHideCallback, this, kTooltipAutoHideTime, + nsITimer::TYPE_ONE_SHOT); } // CreateAutoHideTimer diff --git a/extensions/inspector/base/src/inSearchLoop.cpp b/extensions/inspector/base/src/inSearchLoop.cpp index 6afc03f3d87..eb58df28627 100644 --- a/extensions/inspector/base/src/inSearchLoop.cpp +++ b/extensions/inspector/base/src/inSearchLoop.cpp @@ -39,7 +39,7 @@ #include "inSearchLoop.h" #include "nsITimer.h" - +#include "nsIServiceManager.h" /////////////////////////////////////////////////////////////////////////////// inSearchLoop::inSearchLoop(inISearchProcess* aSearchProcess) @@ -59,7 +59,7 @@ inSearchLoop::~inSearchLoop() nsresult inSearchLoop::Start() { - mTimer->Init(inSearchLoop::TimerCallback, (void*)this, 0, PR_TRUE, NS_TYPE_REPEATING_SLACK); + mTimer->InitWithFuncCallback(inSearchLoop::TimerCallback, (void*)this, 0, nsITimer::TYPE_REPEATING_SLACK); return NS_OK; } diff --git a/extensions/inspector/base/src/inSearchLoop.h b/extensions/inspector/base/src/inSearchLoop.h index 0d479303528..b694fea953f 100644 --- a/extensions/inspector/base/src/inSearchLoop.h +++ b/extensions/inspector/base/src/inSearchLoop.h @@ -39,6 +39,7 @@ #ifndef __inSearchLoop_h__ #define __inSearchLoop_h__ +#include "nsCOMPtr.h" #include "nsITimer.h" #include "inISearchProcess.h" diff --git a/extensions/pref/autoconfig/src/nsAutoConfig.cpp b/extensions/pref/autoconfig/src/nsAutoConfig.cpp index 6384b3f4846..469c250b09a 100644 --- a/extensions/pref/autoconfig/src/nsAutoConfig.cpp +++ b/extensions/pref/autoconfig/src/nsAutoConfig.cpp @@ -182,9 +182,10 @@ nsAutoConfig::OnStopRequest(nsIRequest *request, nsISupports *context, } // Notify method as a TimerCallBack function -NS_IMETHODIMP_(void) nsAutoConfig::Notify(nsITimer *timer) +NS_IMETHODIMP nsAutoConfig::Notify(nsITimer *timer) { downloadAutoConfig(); + return NS_OK; } /* Observe() is called twice: once at the instantiation time and other @@ -379,8 +380,8 @@ nsresult nsAutoConfig::downloadAutoConfig() mTimer = do_CreateInstance("@mozilla.org/timer;1",&rv); if (NS_FAILED(rv)) return rv; - rv = mTimer->Init(this, minutes * 60 * 1000, PR_TRUE, - NS_TYPE_REPEATING_SLACK); + rv = mTimer->InitWithCallback(this, minutes * 60 * 1000, + nsITimer::TYPE_REPEATING_SLACK); if (NS_FAILED(rv)) return rv; } diff --git a/extensions/pref/autoconfig/src/nsAutoConfig.h b/extensions/pref/autoconfig/src/nsAutoConfig.h index 9b1d09bca12..5bc4c593656 100644 --- a/extensions/pref/autoconfig/src/nsAutoConfig.h +++ b/extensions/pref/autoconfig/src/nsAutoConfig.h @@ -38,7 +38,6 @@ #include "nsIAutoConfig.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsIFile.h" #include "nsIObserver.h" #include "nsNetUtil.h" @@ -60,7 +59,8 @@ class nsAutoConfig : public nsIAutoConfig, NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSISTREAMLISTENER NS_DECL_NSIOBSERVER - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK + nsAutoConfig(); virtual ~nsAutoConfig(); nsresult Init(); diff --git a/extensions/typeaheadfind/src/nsTypeAheadFind.cpp b/extensions/typeaheadfind/src/nsTypeAheadFind.cpp index 83012da1bd7..3e17db6f75b 100644 --- a/extensions/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/extensions/typeaheadfind/src/nsTypeAheadFind.cpp @@ -295,10 +295,11 @@ nsTypeAheadFind::PrefsReset(const char* aPrefName, void* instance_data) // ------- nsITimer Methods (1) --------------- -void +NS_IMETHODIMP nsTypeAheadFind::Notify(nsITimer *timer) { CancelFind(); + return NS_OK; } // ----------- nsIObserver Methods (1) ------------------- @@ -760,7 +761,7 @@ nsTypeAheadFind::KeyPress(nsIDOMEvent* aEvent) } if (mTimer) { - mTimer->Init(this, mTimeoutLength); + mTimer->InitWithCallback(this, mTimeoutLength, nsITimer::TYPE_ONE_SHOT); } } diff --git a/extensions/typeaheadfind/src/nsTypeAheadFind.h b/extensions/typeaheadfind/src/nsTypeAheadFind.h index 43ce331ba81..8b763653fe9 100644 --- a/extensions/typeaheadfind/src/nsTypeAheadFind.h +++ b/extensions/typeaheadfind/src/nsTypeAheadFind.h @@ -43,7 +43,6 @@ #include "nsIScrollPositionListener.h" #include "nsISelectionListener.h" #include "nsISelectionController.h" -#include "nsITimerCallback.h" #include "nsIObserver.h" #include "nsITimer.h" #include "nsUnicharUtils.h" @@ -102,7 +101,7 @@ public: nscoord aX, nscoord aY); // ----- nsITimerCallback ----------------------------- - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK static nsTypeAheadFind *GetInstance(); static void ReleaseInstance(void); diff --git a/js/src/xpconnect/tests/components/xpctest_echo.cpp b/js/src/xpconnect/tests/components/xpctest_echo.cpp index 644da8e213b..b2a9158585a 100644 --- a/js/src/xpconnect/tests/components/xpctest_echo.cpp +++ b/js/src/xpconnect/tests/components/xpctest_echo.cpp @@ -51,8 +51,7 @@ public: NS_DECL_NSIECHO #ifdef IMPLEMENT_TIMER_STUFF - // not very xpcom compilant method from nsITimerCallback - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK #endif // IMPLEMENT_TIMER_STUFF xpctestEcho(); @@ -532,7 +531,8 @@ xpctestEcho::CallReceiverSometimeLater(void) timer = do_CreateInstance("@mozilla.org/timer;1", &rv); if(NS_FAILED(rv)) return NS_ERROR_FAILURE; - timer->Init(NS_STATIC_CAST(nsITimerCallback*,this), 2000); + timer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback*,this), 2000, + nsITimer::TYPE_ONE_SHOT); return NS_OK; #else return NS_ERROR_NOT_IMPLEMENTED; @@ -540,12 +540,13 @@ xpctestEcho::CallReceiverSometimeLater(void) } #ifdef IMPLEMENT_TIMER_STUFF -NS_IMETHODIMP_(void) +NS_IMETHODIMP xpctestEcho::Notify(nsITimer *timer) { if(mReceiver) mReceiver->CallReceiverSometimeLater(); NS_RELEASE(timer); + return NS_OK; } #endif // IMPLEMENT_TIMER_STUFF diff --git a/js/src/xpconnect/tests/components/xpctest_private.h b/js/src/xpconnect/tests/components/xpctest_private.h index 2b4a11d017d..0c9e0d4d8d8 100644 --- a/js/src/xpconnect/tests/components/xpctest_private.h +++ b/js/src/xpconnect/tests/components/xpctest_private.h @@ -60,7 +60,6 @@ #ifdef IMPLEMENT_TIMER_STUFF #include "nsITimer.h" -#include "nsITimerCallback.h" #endif // IMPLEMENT_TIMER_STUFF // {ED132C20-EED1-11d2-BAA4-00805F8A5DD7} diff --git a/layout/base/nsCaret.cpp b/layout/base/nsCaret.cpp index 01f772be008..835d69a45d7 100644 --- a/layout/base/nsCaret.cpp +++ b/layout/base/nsCaret.cpp @@ -40,7 +40,6 @@ #include "nsCOMPtr.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" @@ -465,7 +464,8 @@ nsresult nsCaret::PrimeTimer() if (NS_FAILED(err)) return err; - mBlinkTimer->Init(CaretBlinkCallback, this, mBlinkRate, PR_TRUE, NS_TYPE_REPEATING_PRECISE); + mBlinkTimer->InitWithFuncCallback(CaretBlinkCallback, this, mBlinkRate, + nsITimer::TYPE_REPEATING_PRECISE); } return NS_OK; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index b5980f4c9fe..25978112fd2 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -147,6 +147,7 @@ #include "nsIDOMHTMLLinkElement.h" #include "nsIDOMHTMLImageElement.h" #include "nsITimer.h" +#include "nsITimerInternal.h" // For style data reconstruction #include "nsStyleChangeList.h" @@ -2893,7 +2894,12 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) nsCOMPtr prefs(do_GetService(kPrefServiceCID)); if (prefs) prefs->GetIntPref("nglayout.initialpaint.delay", &delay); - mPaintSuppressionTimer->Init(sPaintSuppressionCallback, this, delay, PR_FALSE); + + nsCOMPtr ti = do_QueryInterface(mPaintSuppressionTimer); + ti->SetIdle(PR_TRUE); + + mPaintSuppressionTimer->InitWithFuncCallback(sPaintSuppressionCallback, this, delay, + nsITimer::TYPE_ONE_SHOT); } } @@ -3030,7 +3036,8 @@ PresShell::CreateResizeEventTimer () mResizeEventTimer = do_CreateInstance("@mozilla.org/timer;1"); if (mResizeEventTimer) { - mResizeEventTimer->Init(sResizeEventCallback, this, RESIZE_EVENT_DELAY, PR_TRUE); + mResizeEventTimer->InitWithFuncCallback(sResizeEventCallback, this, RESIZE_EVENT_DELAY, + nsITimer::TYPE_ONE_SHOT); } } diff --git a/layout/base/src/nsCaret.cpp b/layout/base/src/nsCaret.cpp index 01f772be008..835d69a45d7 100644 --- a/layout/base/src/nsCaret.cpp +++ b/layout/base/src/nsCaret.cpp @@ -40,7 +40,6 @@ #include "nsCOMPtr.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" @@ -465,7 +464,8 @@ nsresult nsCaret::PrimeTimer() if (NS_FAILED(err)) return err; - mBlinkTimer->Init(CaretBlinkCallback, this, mBlinkRate, PR_TRUE, NS_TYPE_REPEATING_PRECISE); + mBlinkTimer->InitWithFuncCallback(CaretBlinkCallback, this, mBlinkRate, + nsITimer::TYPE_REPEATING_PRECISE); } return NS_OK; diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 8abd4ea3a90..870a8d32de2 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -89,7 +89,6 @@ // Timer Includes #include "nsITimer.h" -#include "nsITimerCallback.h" // Constants const nscoord kMaxDropDownRows = 20; // This matches the setting for 4.x browsers @@ -249,8 +248,7 @@ public: } virtual ~nsSelectUpdateTimer(); - - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK // Additional Methods nsresult Start(nsIPresContext *aPresContext) @@ -273,7 +271,7 @@ public: NS_RELEASE_THIS(); } - result = mTimer->Init(this, mDelay); + result = mTimer->InitWithCallback(this, mDelay, nsITimer::TYPE_ONE_SHOT); if (mHasBeenNotified) { mItemsAdded = PR_FALSE; @@ -366,7 +364,7 @@ nsresult NS_NewUpdateTimer(nsSelectUpdateTimer **aResult) } // nsITimerCallback -NS_IMETHODIMP_(void) nsSelectUpdateTimer::Notify(nsITimer *timer) +NS_IMETHODIMP nsSelectUpdateTimer::Notify(nsITimer *timer) { if (mPresContext && mListControl && !mHasBeenNotified) { mHasBeenNotified = PR_TRUE; @@ -376,6 +374,7 @@ NS_IMETHODIMP_(void) nsSelectUpdateTimer::Notify(nsITimer *timer) mListControl->ItemsHaveBeenRemoved(mPresContext); } } + return NS_OK; } nsSelectUpdateTimer::~nsSelectUpdateTimer() diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 43ce923323f..e5b6633b40c 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -70,7 +70,6 @@ #include "nsIScrollPositionListener.h" #include "nsIStringStream.h" // for NS_NewCharInputStream #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsLayoutAtoms.h" #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeOwner.h" @@ -305,7 +304,7 @@ public: void Paint(const nsRect& aDirtyRect, PRUint32 ndc = nsnull); // nsITimerCallback interface - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK void CancelTimer(); @@ -3741,7 +3740,7 @@ void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, PRUint32 ndc) // Here's how we give idle time to plugins. -NS_IMETHODIMP_(void) nsPluginInstanceOwner::Notify(nsITimer* /* timer */) +NS_IMETHODIMP nsPluginInstanceOwner::Notify(nsITimer* /* timer */) { #ifdef XP_MAC // validate the plugin clipping information by syncing the plugin window info to @@ -3772,8 +3771,9 @@ NS_IMETHODIMP_(void) nsPluginInstanceOwner::Notify(nsITimer* /* timer */) nsresult rv; mPluginTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (NS_SUCCEEDED(rv)) - mPluginTimer->Init(this, 1020 / 60); + mPluginTimer->InitWithCallback(this, 1020 / 60, nsITimer::TYPE_ONE_SHOT); #endif + return NS_OK; } void nsPluginInstanceOwner::CancelTimer() @@ -3986,7 +3986,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void) // start a periodic timer to provide null events to the plugin instance. mPluginTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (rv == NS_OK) - rv = mPluginTimer->Init(this, 1020 / 60, PR_TRUE, NS_TYPE_REPEATING_SLACK); + rv = mPluginTimer->InitWithCallback(this, 1020 / 60, nsITimer::TYPE_REPEATING_SLACK); #endif } } diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 777fc026c75..8e8560137fc 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -95,7 +95,6 @@ static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID); #include "nsIScrollableView.h" #include "nsIDeviceContext.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsIServiceManager.h" #include "nsIAutoCopy.h" #include "nsIEventQueue.h" @@ -602,7 +601,7 @@ public: return result; } - return mTimer->Init(this, mDelay); + return mTimer->InitWithCallback(this, mDelay, nsITimer::TYPE_ONE_SHOT); } nsresult Stop() @@ -631,7 +630,7 @@ public: return NS_OK; } - NS_IMETHOD_(void) Notify(nsITimer *timer) + NS_IMETHOD Notify(nsITimer *timer) { if (mSelection && mPresContext && mView) { @@ -640,7 +639,7 @@ public: nsIFrame *frame = (nsIFrame *)clientData; if (!frame) - return; + return NS_OK; //the frame passed in here will be a root frame for the view. there is no need to call the constrain //method here. the root frame has NO content now unfortunately... @@ -658,6 +657,7 @@ public: //mFrameSelection->HandleDrag(mPresContext, mFrame, mPoint); mSelection->DoAutoScrollView(mPresContext, mView, mPoint, PR_TRUE); } + return NS_OK; } private: nsSelection *mFrameSelection; diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index f38f9f37a01..8b5553eaa77 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -57,7 +57,6 @@ #include "nsIPresShell.h" #include "nsIView.h" #include "nsIViewManager.h" -#include "nsITimerCallback.h" #include "nsITimer.h" #include "prtime.h" #include "nsVoidArray.h" @@ -224,7 +223,7 @@ public: void Stop(); - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK static nsresult AddBlinkFrame(nsIPresContext* aPresContext, nsIFrame* aFrame); static nsresult RemoveBlinkFrame(nsIFrame* aFrame); @@ -277,7 +276,7 @@ void nsBlinkTimer::Start() nsresult rv; mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (NS_OK == rv) { - mTimer->Init(this, 750, PR_TRUE, NS_TYPE_REPEATING_PRECISE); + mTimer->InitWithCallback(this, 750, nsITimer::TYPE_REPEATING_PRECISE); } } @@ -321,7 +320,7 @@ PRInt32 nsBlinkTimer::FrameCount() { return mFrames.Count(); } -NS_IMETHODIMP_(void) nsBlinkTimer::Notify(nsITimer *timer) +NS_IMETHODIMP nsBlinkTimer::Notify(nsITimer *timer) { // Toggle blink state bit so that text code knows whether or not to // render. All text code shares the same flag so that they all blink @@ -362,6 +361,7 @@ NS_IMETHODIMP_(void) nsBlinkTimer::Notify(nsITimer *timer) vm->UpdateView(view, bounds, 0); NS_RELEASE(vm); } + return NS_OK; } diff --git a/layout/html/base/src/nsObjectFrame.cpp b/layout/html/base/src/nsObjectFrame.cpp index 43ce923323f..e5b6633b40c 100644 --- a/layout/html/base/src/nsObjectFrame.cpp +++ b/layout/html/base/src/nsObjectFrame.cpp @@ -70,7 +70,6 @@ #include "nsIScrollPositionListener.h" #include "nsIStringStream.h" // for NS_NewCharInputStream #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsLayoutAtoms.h" #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeOwner.h" @@ -305,7 +304,7 @@ public: void Paint(const nsRect& aDirtyRect, PRUint32 ndc = nsnull); // nsITimerCallback interface - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK void CancelTimer(); @@ -3741,7 +3740,7 @@ void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, PRUint32 ndc) // Here's how we give idle time to plugins. -NS_IMETHODIMP_(void) nsPluginInstanceOwner::Notify(nsITimer* /* timer */) +NS_IMETHODIMP nsPluginInstanceOwner::Notify(nsITimer* /* timer */) { #ifdef XP_MAC // validate the plugin clipping information by syncing the plugin window info to @@ -3772,8 +3771,9 @@ NS_IMETHODIMP_(void) nsPluginInstanceOwner::Notify(nsITimer* /* timer */) nsresult rv; mPluginTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (NS_SUCCEEDED(rv)) - mPluginTimer->Init(this, 1020 / 60); + mPluginTimer->InitWithCallback(this, 1020 / 60, nsITimer::TYPE_ONE_SHOT); #endif + return NS_OK; } void nsPluginInstanceOwner::CancelTimer() @@ -3986,7 +3986,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void) // start a periodic timer to provide null events to the plugin instance. mPluginTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (rv == NS_OK) - rv = mPluginTimer->Init(this, 1020 / 60, PR_TRUE, NS_TYPE_REPEATING_SLACK); + rv = mPluginTimer->InitWithCallback(this, 1020 / 60, nsITimer::TYPE_REPEATING_SLACK); #endif } } diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index b5980f4c9fe..25978112fd2 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -147,6 +147,7 @@ #include "nsIDOMHTMLLinkElement.h" #include "nsIDOMHTMLImageElement.h" #include "nsITimer.h" +#include "nsITimerInternal.h" // For style data reconstruction #include "nsStyleChangeList.h" @@ -2893,7 +2894,12 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) nsCOMPtr prefs(do_GetService(kPrefServiceCID)); if (prefs) prefs->GetIntPref("nglayout.initialpaint.delay", &delay); - mPaintSuppressionTimer->Init(sPaintSuppressionCallback, this, delay, PR_FALSE); + + nsCOMPtr ti = do_QueryInterface(mPaintSuppressionTimer); + ti->SetIdle(PR_TRUE); + + mPaintSuppressionTimer->InitWithFuncCallback(sPaintSuppressionCallback, this, delay, + nsITimer::TYPE_ONE_SHOT); } } @@ -3030,7 +3036,8 @@ PresShell::CreateResizeEventTimer () mResizeEventTimer = do_CreateInstance("@mozilla.org/timer;1"); if (mResizeEventTimer) { - mResizeEventTimer->Init(sResizeEventCallback, this, RESIZE_EVENT_DELAY, PR_TRUE); + mResizeEventTimer->InitWithFuncCallback(sResizeEventCallback, this, RESIZE_EVENT_DELAY, + nsITimer::TYPE_ONE_SHOT); } } diff --git a/layout/html/base/src/nsTextFrame.cpp b/layout/html/base/src/nsTextFrame.cpp index f38f9f37a01..8b5553eaa77 100644 --- a/layout/html/base/src/nsTextFrame.cpp +++ b/layout/html/base/src/nsTextFrame.cpp @@ -57,7 +57,6 @@ #include "nsIPresShell.h" #include "nsIView.h" #include "nsIViewManager.h" -#include "nsITimerCallback.h" #include "nsITimer.h" #include "prtime.h" #include "nsVoidArray.h" @@ -224,7 +223,7 @@ public: void Stop(); - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK static nsresult AddBlinkFrame(nsIPresContext* aPresContext, nsIFrame* aFrame); static nsresult RemoveBlinkFrame(nsIFrame* aFrame); @@ -277,7 +276,7 @@ void nsBlinkTimer::Start() nsresult rv; mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (NS_OK == rv) { - mTimer->Init(this, 750, PR_TRUE, NS_TYPE_REPEATING_PRECISE); + mTimer->InitWithCallback(this, 750, nsITimer::TYPE_REPEATING_PRECISE); } } @@ -321,7 +320,7 @@ PRInt32 nsBlinkTimer::FrameCount() { return mFrames.Count(); } -NS_IMETHODIMP_(void) nsBlinkTimer::Notify(nsITimer *timer) +NS_IMETHODIMP nsBlinkTimer::Notify(nsITimer *timer) { // Toggle blink state bit so that text code knows whether or not to // render. All text code shares the same flag so that they all blink @@ -362,6 +361,7 @@ NS_IMETHODIMP_(void) nsBlinkTimer::Notify(nsITimer *timer) vm->UpdateView(view, bounds, 0); NS_RELEASE(vm); } + return NS_OK; } diff --git a/layout/html/forms/src/nsListControlFrame.cpp b/layout/html/forms/src/nsListControlFrame.cpp index 8abd4ea3a90..870a8d32de2 100644 --- a/layout/html/forms/src/nsListControlFrame.cpp +++ b/layout/html/forms/src/nsListControlFrame.cpp @@ -89,7 +89,6 @@ // Timer Includes #include "nsITimer.h" -#include "nsITimerCallback.h" // Constants const nscoord kMaxDropDownRows = 20; // This matches the setting for 4.x browsers @@ -249,8 +248,7 @@ public: } virtual ~nsSelectUpdateTimer(); - - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK // Additional Methods nsresult Start(nsIPresContext *aPresContext) @@ -273,7 +271,7 @@ public: NS_RELEASE_THIS(); } - result = mTimer->Init(this, mDelay); + result = mTimer->InitWithCallback(this, mDelay, nsITimer::TYPE_ONE_SHOT); if (mHasBeenNotified) { mItemsAdded = PR_FALSE; @@ -366,7 +364,7 @@ nsresult NS_NewUpdateTimer(nsSelectUpdateTimer **aResult) } // nsITimerCallback -NS_IMETHODIMP_(void) nsSelectUpdateTimer::Notify(nsITimer *timer) +NS_IMETHODIMP nsSelectUpdateTimer::Notify(nsITimer *timer) { if (mPresContext && mListControl && !mHasBeenNotified) { mHasBeenNotified = PR_TRUE; @@ -376,6 +374,7 @@ NS_IMETHODIMP_(void) nsSelectUpdateTimer::Notify(nsITimer *timer) mListControl->ItemsHaveBeenRemoved(mPresContext); } } + return NS_OK; } nsSelectUpdateTimer::~nsSelectUpdateTimer() diff --git a/layout/printing/nsPagePrintTimer.cpp b/layout/printing/nsPagePrintTimer.cpp index 5dd907a3426..ba4114888c0 100644 --- a/layout/printing/nsPagePrintTimer.cpp +++ b/layout/printing/nsPagePrintTimer.cpp @@ -38,6 +38,7 @@ #include "nsPagePrintTimer.h" #include "nsPrintEngine.h" #include "nsIContentViewer.h" +#include "nsIServiceManager.h" NS_IMPL_ISUPPORTS1(nsPagePrintTimer, nsITimerCallback) @@ -71,7 +72,7 @@ nsPagePrintTimer::StartTimer(PRBool aUseDelay) if (NS_FAILED(result)) { NS_WARNING("unable to start the timer"); } else { - mTimer->Init(this, aUseDelay?mDelay:0, PR_TRUE, NS_TYPE_ONE_SHOT); + mTimer->InitWithCallback(this, aUseDelay?mDelay:0, nsITimer::TYPE_ONE_SHOT); } return result; } @@ -79,7 +80,7 @@ nsPagePrintTimer::StartTimer(PRBool aUseDelay) // nsITimerCallback -NS_IMETHODIMP_(void) +NS_IMETHODIMP nsPagePrintTimer::Notify(nsITimer *timer) { if (mPresContext && mDocViewerPrint) { @@ -105,6 +106,7 @@ nsPagePrintTimer::Notify(nsITimer *timer) } } } + return NS_OK; } void diff --git a/layout/printing/nsPagePrintTimer.h b/layout/printing/nsPagePrintTimer.h index 7a77021709a..713d2768f52 100644 --- a/layout/printing/nsPagePrintTimer.h +++ b/layout/printing/nsPagePrintTimer.h @@ -39,7 +39,6 @@ // Timer Includes #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsITimelineService.h" // Interfaces @@ -66,7 +65,7 @@ public: virtual ~nsPagePrintTimer(); // nsITimerCallback - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK // Other Methods nsresult StartTimer(PRBool aUseDelay = PR_TRUE); diff --git a/layout/xul/base/src/nsListBoxBodyFrame.cpp b/layout/xul/base/src/nsListBoxBodyFrame.cpp index f09874e76c5..31d4fbfafe6 100644 --- a/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -66,7 +66,6 @@ #include "nsIDeviceContext.h" #include "nsIFontMetrics.h" #include "nsITimer.h" -#include "nsITimerCallback.h" /////////////// nsListScrollSmoother ////////////////// @@ -103,7 +102,7 @@ public: virtual ~nsListScrollSmoother(); // nsITimerCallback - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK void Start(); void Stop(); @@ -126,16 +125,17 @@ nsListScrollSmoother::~nsListScrollSmoother() Stop(); } -NS_IMETHODIMP_(void) +NS_IMETHODIMP nsListScrollSmoother::Notify(nsITimer *timer) { Stop(); NS_ASSERTION(mOuter, "mOuter is null, see bug #68365"); - if (!mOuter) return; + if (!mOuter) return NS_OK; // actually do some work. mOuter->InternalPositionChangedCallback(); + return NS_OK; } PRBool @@ -149,7 +149,7 @@ nsListScrollSmoother::Start() { Stop(); mRepeatTimer = do_CreateInstance("@mozilla.org/timer;1"); - mRepeatTimer->Init(this, SMOOTH_INTERVAL); + mRepeatTimer->InitWithCallback(this, SMOOTH_INTERVAL, nsITimer::TYPE_ONE_SHOT); } void diff --git a/layout/xul/base/src/nsMenuBarFrame.cpp b/layout/xul/base/src/nsMenuBarFrame.cpp index 3271542e9a3..deafc99d64a 100644 --- a/layout/xul/base/src/nsMenuBarFrame.cpp +++ b/layout/xul/base/src/nsMenuBarFrame.cpp @@ -41,6 +41,7 @@ #include "nsMenuListener.h" #include "nsMenuBarFrame.h" +#include "nsIServiceManager.h" #include "nsIContent.h" #include "prtypes.h" #include "nsIAtom.h" diff --git a/layout/xul/base/src/nsMenuFrame.cpp b/layout/xul/base/src/nsMenuFrame.cpp index 6f40698e44d..6ba6e016dcb 100644 --- a/layout/xul/base/src/nsMenuFrame.cpp +++ b/layout/xul/base/src/nsMenuFrame.cpp @@ -84,7 +84,7 @@ #include "nsIStringBundle.h" #include "nsGUIEvent.h" #include "nsIEventStateManager.h" - +#include "nsITimerInternal.h" #define NS_MENU_POPUP_LIST_INDEX 0 #ifdef XP_PC @@ -533,7 +533,12 @@ nsMenuFrame::HandleEvent(nsIPresContext* aPresContext, // We're a menu, we're built, we're closed, and no timer has been kicked off. mOpenTimer = do_CreateInstance("@mozilla.org/timer;1"); - mOpenTimer->Init(this, menuDelay, PR_FALSE); + + nsCOMPtr ti = do_QueryInterface(mOpenTimer); + ti->SetIdle(PR_TRUE); + + mOpenTimer->InitWithCallback(this, menuDelay, nsITimer::TYPE_ONE_SHOT); + } } @@ -1314,7 +1319,7 @@ nsMenuFrame::IsMenu() return mIsMenu; } -NS_IMETHODIMP_(void) +NS_IMETHODIMP nsMenuFrame::Notify(nsITimer* aTimer) { // Our timer has fired. @@ -1334,6 +1339,7 @@ nsMenuFrame::Notify(nsITimer* aTimer) } mOpenTimer = nsnull; + return NS_OK; } PRBool diff --git a/layout/xul/base/src/nsMenuFrame.h b/layout/xul/base/src/nsMenuFrame.h index a0dfe02bbdc..dfab93cd96c 100644 --- a/layout/xul/base/src/nsMenuFrame.h +++ b/layout/xul/base/src/nsMenuFrame.h @@ -53,7 +53,6 @@ #include "nsIMenuFrame.h" #include "nsMenuDismissalListener.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsISupportsArray.h" #include "nsIDOMText.h" #include "nsIContent.h" @@ -84,7 +83,7 @@ public: NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize); // The nsITimerCallback interface - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index d8a43c72f79..210ff296a95 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -70,6 +70,7 @@ #include "nsGUIEvent.h" #include "nsIRootBox.h" #include "nsIDocShellTreeItem.h" +#include "nsITimerInternal.h" #ifdef XP_WIN #include "nsISound.h" #endif @@ -1500,7 +1501,9 @@ NS_IMETHODIMP nsMenuPopupFrame::SetCurrentMenuItem(nsIMenuFrame* aMenuItem) // Kick off the timer. mCloseTimer = do_CreateInstance("@mozilla.org/timer;1"); - mCloseTimer->Init(this, menuDelay, PR_FALSE); + nsCOMPtr ti = do_QueryInterface(mCloseTimer); + ti->SetIdle(PR_TRUE); + mCloseTimer->InitWithCallback(this, menuDelay, nsITimer::TYPE_ONE_SHOT); mTimerMenu = mCurrentMenu; } } @@ -2111,7 +2114,7 @@ nsMenuPopupFrame::GetFrameForPoint(nsIPresContext* aPresContext, // // The code below melds the two cases together. // -NS_IMETHODIMP_(void) +NS_IMETHODIMP nsMenuPopupFrame::Notify(nsITimer* aTimer) { // Our timer has fired. @@ -2164,6 +2167,7 @@ nsMenuPopupFrame::Notify(nsITimer* aTimer) mCloseTimer = nsnull; mTimerMenu = nsnull; + return NS_OK; } NS_IMETHODIMP diff --git a/layout/xul/base/src/nsMenuPopupFrame.h b/layout/xul/base/src/nsMenuPopupFrame.h index cd8bf2b144c..741f4c647f7 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.h +++ b/layout/xul/base/src/nsMenuPopupFrame.h @@ -56,7 +56,6 @@ #include "nsIWidget.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #define INC_TYP_INTERVAL 2500 // 2.5s. If the interval of two typings is shorter than this, // treat as a continue typing @@ -78,7 +77,7 @@ public: NS_DECL_ISUPPORTS // The nsITimerCallback interface - NS_IMETHOD_(void) Notify(nsITimer *aTimer); + NS_DECL_NSITIMERCALLBACK // nsIMenuParentInterface NS_IMETHOD GetCurrentMenuItem(nsIMenuFrame** aResult); diff --git a/layout/xul/base/src/nsPopupSetFrame.h b/layout/xul/base/src/nsPopupSetFrame.h index f3187f351b7..93eb946e149 100644 --- a/layout/xul/base/src/nsPopupSetFrame.h +++ b/layout/xul/base/src/nsPopupSetFrame.h @@ -36,7 +36,6 @@ #include "nsFrameList.h" #include "nsIMenuParent.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsISupportsArray.h" nsresult NS_NewPopupSetFrame(nsIPresShell* aPresShell, nsIFrame** aResult) ; diff --git a/layout/xul/base/src/nsRepeatService.cpp b/layout/xul/base/src/nsRepeatService.cpp index 69fda2a89b3..71730f7c32b 100644 --- a/layout/xul/base/src/nsRepeatService.cpp +++ b/layout/xul/base/src/nsRepeatService.cpp @@ -43,6 +43,7 @@ // #include "nsRepeatService.h" +#include "nsIServiceManager.h" #if defined(XP_MAC) || defined(XP_MACOSX) #define INITAL_REPEAT_DELAY 250 @@ -92,7 +93,7 @@ void nsRepeatService::Start(nsITimerCallback* aCallback) mRepeatTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (NS_OK == rv) { - mRepeatTimer->Init(this, INITAL_REPEAT_DELAY); + mRepeatTimer->InitWithCallback(this, INITAL_REPEAT_DELAY, nsITimer::TYPE_ONE_SHOT); } } @@ -107,7 +108,7 @@ void nsRepeatService::Stop() } } -NS_IMETHODIMP_(void) nsRepeatService::Notify(nsITimer *timer) +NS_IMETHODIMP nsRepeatService::Notify(nsITimer *timer) { // if the repeat delay is the initial one reset it. if (mRepeatTimer) { @@ -121,9 +122,9 @@ NS_IMETHODIMP_(void) nsRepeatService::Notify(nsITimer *timer) // start timer again. if (mRepeatTimer) { mRepeatTimer = do_CreateInstance("@mozilla.org/timer;1"); - mRepeatTimer->Init(this, REPEAT_DELAY); + mRepeatTimer->InitWithCallback(this, REPEAT_DELAY, nsITimer::TYPE_ONE_SHOT); } - + return NS_OK; } NS_IMPL_ISUPPORTS1(nsRepeatService, nsITimerCallback) diff --git a/layout/xul/base/src/nsRepeatService.h b/layout/xul/base/src/nsRepeatService.h index 28101edc23a..bd23c76513a 100644 --- a/layout/xul/base/src/nsRepeatService.h +++ b/layout/xul/base/src/nsRepeatService.h @@ -42,7 +42,6 @@ #define nsRepeatService_h__ #include "nsCOMPtr.h" -#include "nsITimerCallback.h" #include "nsITimer.h" class nsITimer; @@ -51,7 +50,7 @@ class nsRepeatService : public nsITimerCallback { public: - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK void Start(nsITimerCallback* aCallback); void Stop(); diff --git a/layout/xul/base/src/nsScrollBoxFrame.cpp b/layout/xul/base/src/nsScrollBoxFrame.cpp index 19651b4cefe..f31e0ad8410 100644 --- a/layout/xul/base/src/nsScrollBoxFrame.cpp +++ b/layout/xul/base/src/nsScrollBoxFrame.cpp @@ -60,7 +60,7 @@ #include "nsISupportsPrimitives.h" #include "nsIPresState.h" #include "nsButtonBoxFrame.h" -#include "nsITimerCallback.h" +#include "nsITimer.h" #include "nsRepeatService.h" static NS_DEFINE_IID(kWidgetCID, NS_CHILD_CID); @@ -873,8 +873,7 @@ public: nsIStyleContext* aContext, nsIFrame* aPrevInFlow); - NS_IMETHOD_(void) Notify(nsITimer *timer); - + NS_DECL_NSITIMERCALLBACK nsIPresContext* mPresContext; }; @@ -940,10 +939,11 @@ nsAutoRepeatBoxFrame::HandleEvent(nsIPresContext* aPresContext, return nsButtonBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus); } -NS_IMETHODIMP_(void) +NS_IMETHODIMP nsAutoRepeatBoxFrame::Notify(nsITimer *timer) { MouseClicked(mPresContext, nsnull); + return NS_OK; } NS_IMETHODIMP diff --git a/layout/xul/base/src/nsScrollbarButtonFrame.cpp b/layout/xul/base/src/nsScrollbarButtonFrame.cpp index 28c99282547..3465b83a3b2 100644 --- a/layout/xul/base/src/nsScrollbarButtonFrame.cpp +++ b/layout/xul/base/src/nsScrollbarButtonFrame.cpp @@ -131,9 +131,10 @@ nsScrollbarButtonFrame::HandleRelease(nsIPresContext* aPresContext, } -NS_IMETHODIMP_(void) nsScrollbarButtonFrame::Notify(nsITimer *timer) +NS_IMETHODIMP nsScrollbarButtonFrame::Notify(nsITimer *timer) { MouseClicked(); + return NS_OK; } void diff --git a/layout/xul/base/src/nsScrollbarButtonFrame.h b/layout/xul/base/src/nsScrollbarButtonFrame.h index 0400deae80d..0c42ef45174 100644 --- a/layout/xul/base/src/nsScrollbarButtonFrame.h +++ b/layout/xul/base/src/nsScrollbarButtonFrame.h @@ -46,7 +46,7 @@ #define nsScrollbarButtonFrame_h___ #include "nsButtonBoxFrame.h" -#include "nsITimerCallback.h" +#include "nsITimer.h" class nsSliderFrame; @@ -86,7 +86,7 @@ public: nsGUIEvent * aEvent, nsEventStatus* aEventStatus); - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); NS_IMETHOD_(nsrefcnt) AddRef(void) { return NS_OK; } diff --git a/layout/xul/base/src/nsSliderFrame.cpp b/layout/xul/base/src/nsSliderFrame.cpp index 8aa921e7ce9..a5defe50c78 100644 --- a/layout/xul/base/src/nsSliderFrame.cpp +++ b/layout/xul/base/src/nsSliderFrame.cpp @@ -1246,10 +1246,11 @@ nsSliderFrame::SetScrollbarListener(nsIScrollbarListener* aListener) mScrollbarListener = aListener; } -NS_IMETHODIMP_(void) nsSliderMediator::Notify(nsITimer *timer) +NS_IMETHODIMP nsSliderMediator::Notify(nsITimer *timer) { if (mSlider) mSlider->Notify(timer); + return NS_OK; } NS_IMETHODIMP_(void) nsSliderFrame::Notify(nsITimer *timer) diff --git a/layout/xul/base/src/nsSliderFrame.h b/layout/xul/base/src/nsSliderFrame.h index a89029c296b..d0442974497 100644 --- a/layout/xul/base/src/nsSliderFrame.h +++ b/layout/xul/base/src/nsSliderFrame.h @@ -43,7 +43,7 @@ #include "prtypes.h" #include "nsIAtom.h" #include "nsCOMPtr.h" -#include "nsITimerCallback.h" +#include "nsITimer.h" #include "nsIDOMMouseListener.h" class nsString; @@ -115,8 +115,7 @@ public: NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; } - - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK }; // class nsSliderFrame diff --git a/layout/xul/base/src/nsXULTooltipListener.cpp b/layout/xul/base/src/nsXULTooltipListener.cpp index 3f02c673396..2174edf4246 100644 --- a/layout/xul/base/src/nsXULTooltipListener.cpp +++ b/layout/xul/base/src/nsXULTooltipListener.cpp @@ -195,7 +195,8 @@ nsXULTooltipListener::MouseMove(nsIDOMEvent* aMouseEvent) mTargetNode = targetContent; } if (mTargetNode) { - nsresult rv = mTooltipTimer->Init(sTooltipCallback, this, kTooltipShowTime, PR_TRUE); + nsresult rv = mTooltipTimer->InitWithFuncCallback(sTooltipCallback, this, + kTooltipShowTime, nsITimer::TYPE_ONE_SHOT); if (NS_FAILED(rv)) mTargetNode = nsnull; } @@ -650,7 +651,8 @@ nsXULTooltipListener::CreateAutoHideTimer() mAutoHideTimer = do_CreateInstance("@mozilla.org/timer;1"); if ( mAutoHideTimer ) - mAutoHideTimer->Init(sAutoHideCallback, this, kTooltipAutoHideTime, PR_TRUE); + mAutoHideTimer->InitWithFuncCallback(sAutoHideCallback, this, kTooltipAutoHideTime, + nsITimer::TYPE_ONE_SHOT); } void diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 0a0ce424b11..0b228b62652 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -88,7 +88,7 @@ #include "nsIScrollableView.h" #include "nsITheme.h" #include "nsITimelineService.h" - +#include "nsITimerInternal.h" #ifdef USE_IMG2 #include "imgIRequest.h" #include "imgIContainer.h" @@ -3513,9 +3513,16 @@ nsTreeBodyFrame::OnDragOver(nsIDOMEvent* aEvent) mTimer->Cancel(); mTimer = nsnull; } - NS_NewTimer(getter_AddRefs(mTimer), ScrollCallback, this, - kLazyScrollDelay, PR_FALSE, NS_TYPE_REPEATING_SLACK); - } + + mTimer = do_CreateInstance("@mozilla.org/timer;1"); + + nsCOMPtr ti = do_QueryInterface(mTimer); + ti->SetIdle(PR_TRUE); + + mTimer->InitWithFuncCallback(ScrollCallback, this, kLazyScrollDelay, + nsITimer::TYPE_REPEATING_SLACK); + + } #else ScrollByLines(mScrollLines); #endif @@ -3549,8 +3556,11 @@ nsTreeBodyFrame::OnDragOver(nsIDOMEvent* aEvent) mView->IsContainerOpen(mDropRow, &isOpen); if (!isOpen) { // This node isn't expanded, set a timer to expand it. - NS_NewTimer(getter_AddRefs(mTimer), OpenCallback, this, - kOpenDelay, PR_FALSE, NS_TYPE_ONE_SHOT); + mTimer = do_CreateInstance("@mozilla.org/timer;1"); + nsCOMPtr ti = do_QueryInterface(mTimer); + ti->SetIdle(PR_TRUE); + mTimer->InitWithFuncCallback(OpenCallback, this, kOpenDelay, + nsITimer::TYPE_ONE_SHOT); } } } @@ -3706,7 +3716,9 @@ nsTreeBodyFrame::ScrollCallback(nsITimer *aTimer, void *aClosure) // Don't scroll if we are already at the top or bottom of the view. if (self->CanAutoScroll(self->mDropRow)) { self->ScrollByLines(self->mScrollLines); - if (aTimer->GetDelay() != kScrollDelay) + PRUint32 delay = 0; + aTimer->GetDelay(&delay); + if (delay != kScrollDelay) aTimer->SetDelay(kScrollDelay); } else { diff --git a/layout/xul/base/src/tree/src/nsTreeSelection.cpp b/layout/xul/base/src/tree/src/nsTreeSelection.cpp index 29e3838056e..ea3ba998bed 100644 --- a/layout/xul/base/src/tree/src/nsTreeSelection.cpp +++ b/layout/xul/base/src/tree/src/nsTreeSelection.cpp @@ -317,7 +317,8 @@ NS_IMETHODIMP nsTreeSelection::TimedSelect(PRInt32 aIndex, PRInt32 aMsec) mSelectTimer->Cancel(); mSelectTimer = do_CreateInstance("@mozilla.org/timer;1"); - mSelectTimer->Init(SelectCallback, this, aMsec, PR_TRUE); + mSelectTimer->InitWithFuncCallback(SelectCallback, this, aMsec, + nsITimer::TYPE_ONE_SHOT); } } diff --git a/mailnews/base/search/src/nsMsgSearchSession.cpp b/mailnews/base/search/src/nsMsgSearchSession.cpp index 608dbe755f3..04241b1cf14 100644 --- a/mailnews/base/search/src/nsMsgSearchSession.cpp +++ b/mailnews/base/search/src/nsMsgSearchSession.cpp @@ -533,7 +533,8 @@ nsresult nsMsgSearchSession::StartTimer() PRBool done; m_backgroundTimer = do_CreateInstance("@mozilla.org/timer;1", &err); - m_backgroundTimer->Init(TimerCallback, (void *) this, 0, PR_TRUE, NS_TYPE_REPEATING_SLACK); + m_backgroundTimer->InitWithFuncCallback(TimerCallback, (void *) this, 0, + nsITimer::TYPE_REPEATING_SLACK); // ### start meteors? return TimeSlice(&done); } diff --git a/mailnews/base/src/nsMessengerWinIntegration.cpp b/mailnews/base/src/nsMessengerWinIntegration.cpp index 7740356d000..8f37ab5b275 100644 --- a/mailnews/base/src/nsMessengerWinIntegration.cpp +++ b/mailnews/base/src/nsMessengerWinIntegration.cpp @@ -1169,7 +1169,8 @@ nsMessengerWinIntegration::SetupUnreadCountUpdateTimer() } mUnreadCountUpdateTimer = do_CreateInstance("@mozilla.org/timer;1"); - mUnreadCountUpdateTimer->Init(OnUnreadCountUpdateTimer, (void*)this, timeInMSUint32, PR_TRUE, NS_TYPE_REPEATING_SLACK); + mUnreadCountUpdateTimer->InitWithFuncCallback(OnUnreadCountUpdateTimer, (void*)this, timeInMSUint32, + nsITimer::TYPE_REPEATING_SLACK); return NS_OK; } diff --git a/mailnews/base/src/nsMsgBiffManager.cpp b/mailnews/base/src/nsMsgBiffManager.cpp index 0c9e8963302..8ae3db7d5e4 100644 --- a/mailnews/base/src/nsMsgBiffManager.cpp +++ b/mailnews/base/src/nsMsgBiffManager.cpp @@ -311,7 +311,8 @@ nsresult nsMsgBiffManager::SetupNextBiff() mBiffTimer->Cancel(); } mBiffTimer = do_CreateInstance("@mozilla.org/timer;1"); - mBiffTimer->Init(OnBiffTimer, (void*)this, timeInMSUint32); + mBiffTimer->InitWithFuncCallback(OnBiffTimer, (void*)this, timeInMSUint32, + nsITimer::TYPE_ONE_SHOT); } return NS_OK; diff --git a/mailnews/base/src/nsMsgBiffManager.h b/mailnews/base/src/nsMsgBiffManager.h index 5813dfee4e4..a574b2e3ccd 100644 --- a/mailnews/base/src/nsMsgBiffManager.h +++ b/mailnews/base/src/nsMsgBiffManager.h @@ -41,7 +41,6 @@ #include "msgCore.h" #include "nsIMsgBiffManager.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsVoidArray.h" #include "nsTime.h" #include "nsCOMPtr.h" diff --git a/mailnews/news/src/nsNNTPProtocol.cpp b/mailnews/news/src/nsNNTPProtocol.cpp index 1f12a812180..dc998c3aca1 100644 --- a/mailnews/news/src/nsNNTPProtocol.cpp +++ b/mailnews/news/src/nsNNTPProtocol.cpp @@ -3292,7 +3292,8 @@ PRInt32 nsNNTPProtocol::ReadNewsList(nsIInputStream * inputStream, PRUint32 leng mInputStream = inputStream; const PRUint32 kUpdateTimerDelay = READ_NEWS_LIST_TIMEOUT; - rv = mUpdateTimer->Init(NS_STATIC_CAST(nsITimerCallback*,this), kUpdateTimerDelay); + rv = mUpdateTimer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback*,this), kUpdateTimerDelay, + nsITimer::TYPE_ONE_SHOT); NS_ASSERTION(NS_SUCCEEDED(rv),"failed to init timer"); if (NS_FAILED(rv)) { PR_FREEIF(orig_line); @@ -3307,12 +3308,13 @@ PRInt32 nsNNTPProtocol::ReadNewsList(nsIInputStream * inputStream, PRUint32 leng return(status); } -void +NS_IMETHODIMP nsNNTPProtocol::Notify(nsITimer *timer) { NS_ASSERTION(timer == mUpdateTimer.get(), "Hey, this ain't my timer!"); mUpdateTimer = nsnull; // release my hold TimerCallback(); + return NS_OK; } void nsNNTPProtocol::TimerCallback() diff --git a/mailnews/news/src/nsNNTPProtocol.h b/mailnews/news/src/nsNNTPProtocol.h index bca1e614b21..55572b98239 100644 --- a/mailnews/news/src/nsNNTPProtocol.h +++ b/mailnews/news/src/nsNNTPProtocol.h @@ -59,7 +59,6 @@ #include "nsXPIDLString.h" #include "nsIStringBundle.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsICacheListener.h" // this is only needed as long as our libmime hack is in place @@ -170,7 +169,7 @@ public: NS_DECL_NSICACHELISTENER // nsITimerCallback interfaces - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK // Creating a protocol instance requires the URL // need to call Initialize after we do a new of nsNNTPProtocol diff --git a/mailnews/news/src/nsNntpIncomingServer.cpp b/mailnews/news/src/nsNntpIncomingServer.cpp index 612f6f67193..8f3c30bf1a4 100644 --- a/mailnews/news/src/nsNntpIncomingServer.cpp +++ b/mailnews/news/src/nsNntpIncomingServer.cpp @@ -302,7 +302,8 @@ nsresult nsNntpIncomingServer::SetupNewsrcSaveTimer() mNewsrcSaveTimer->Cancel(); } mNewsrcSaveTimer = do_CreateInstance("@mozilla.org/timer;1"); - mNewsrcSaveTimer->Init(OnNewsrcSaveTimer, (void*)this, timeInMSUint32, PR_TRUE, NS_TYPE_REPEATING_SLACK); + mNewsrcSaveTimer->InitWithFuncCallback(OnNewsrcSaveTimer, (void*)this, timeInMSUint32, + nsITimer::TYPE_REPEATING_SLACK); return NS_OK; } diff --git a/modules/libpr0n/decoders/mng/imgContainerMNG.cpp b/modules/libpr0n/decoders/mng/imgContainerMNG.cpp index b4937fc6104..fbcf80193d4 100644 --- a/modules/libpr0n/decoders/mng/imgContainerMNG.cpp +++ b/modules/libpr0n/decoders/mng/imgContainerMNG.cpp @@ -489,7 +489,8 @@ il_mng_settimer(mng_handle handle, mng_uint32 msec) EXTRACT_CONTAINER; container->mTimer = do_CreateInstance("@mozilla.org/timer;1"); - container->mTimer->Init(il_mng_timeout_func, (void *)handle, msec); + container->mTimer->InitWithFuncCallback(il_mng_timeout_func, (void *)handle, msec, + nsITimer::TYPE_ONE_SHOT); return MNG_TRUE; } diff --git a/modules/libpr0n/decoders/mng/imgContainerMNG.h b/modules/libpr0n/decoders/mng/imgContainerMNG.h index 98ac936c84b..e69de29bb2d 100644 --- a/modules/libpr0n/decoders/mng/imgContainerMNG.h +++ b/modules/libpr0n/decoders/mng/imgContainerMNG.h @@ -1,87 +0,0 @@ -/* - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Tim Rowley. - * Portions created by Tim Rowley are - * Copyright (C) 2001 Tim Rowley. Rights Reserved. - * - * Contributor(s): - * Tim Rowley - */ - -#ifndef _imgContainerMNG_h_ -#define _imgContainerMNG_h_ - -#include "imgIContainerObserver.h" -#include "imgIContainer.h" -#include "nsSize.h" -#include "nsSupportsArray.h" -#include "nsCOMPtr.h" -#include "nsITimer.h" -#include "nsITimerCallback.h" -#include "imgIDecoderObserver.h" -#include "gfxIImageFrame.h" -#include "nsWeakReference.h" -#include "nsIInputStream.h" -#include "nsMNGDecoder.h" -#include "libmng.h" - -#define NS_MNGCONTAINER_CID \ -{ /* 7fc64c50-1dd2-11b2-85fe-997f8a1263d6 */ \ - 0x7fc64c50, \ - 0x1dd2, \ - 0x11b2, \ - {0x85, 0xfe, 0x99, 0x7f, 0x8a, 0x12, 0x63, 0xd6} \ -} - -class imgContainerMNG : public imgIContainer -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_IMGICONTAINER - - imgContainerMNG(); - virtual ~imgContainerMNG(); - - NS_IMETHODIMP WriteMNG(nsIInputStream *inStr, PRInt32 count, PRUint32 *_retval); - void InitMNG(nsMNGDecoder *decoder); - - nsWeakPtr mObserver; - nsMNGDecoder *mDecoder; - nsCOMPtr mFrame; - nsSize mSize; - PRUint16 mAnimationMode; - - // Unfortunately we need to keep a copy of the image because partial - // reads in necko aren't guaranteed to work (darin 5/11/2001). - // Brute force for now, keeping the entire stream around. - - PRUint8 *mBuffer; // copy of image stream - PRUint32 mBufferEnd; // size - PRUint32 mBufferPtr; // libmng current read location - - PRUint8 *image; // full image buffer - PRUint8 *alpha; // full alpha buffer - - mng_handle mHandle; // libmng handle -// PRUint32 mWidth; // width (for offset calcs) -// PRUint32 mHeight; - PRUint32 mByteWidth, mByteWidthAlpha; - nsCOMPtr mTimer; - - PRPackedBool mResumeNeeded; // display_resume call needed? - PRPackedBool mFrozen; // animation frozen? - PRPackedBool mErrorPending; // decode error to report? -}; - -#endif diff --git a/modules/libpr0n/src/imgContainer.cpp b/modules/libpr0n/src/imgContainer.cpp index 60b07d184f8..bf8d01b3d7e 100644 --- a/modules/libpr0n/src/imgContainer.cpp +++ b/modules/libpr0n/src/imgContainer.cpp @@ -32,6 +32,7 @@ #include "nsIInterfaceRequestorUtils.h" #include "gfxIImageFrame.h" #include "nsMemory.h" +#include "nsITimer.h" NS_IMPL_ISUPPORTS3(imgContainer, imgIContainer, nsITimerCallback, imgIDecoderObserver) @@ -199,8 +200,8 @@ NS_IMETHODIMP imgContainer::AppendFrame(gfxIImageFrame *item) if (mAnimating) { // Since we have more than one frame we need a timer mTimer = do_CreateInstance("@mozilla.org/timer;1"); - mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), - timeout, PR_TRUE, NS_TYPE_REPEATING_SLACK); + mTimer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback*, this), + timeout, nsITimer::TYPE_REPEATING_SLACK); } } } @@ -322,16 +323,16 @@ NS_IMETHODIMP imgContainer::StartAnimation() mAnimating = PR_TRUE; if (!mTimer) mTimer = do_CreateInstance("@mozilla.org/timer;1"); - mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), - timeout, PR_TRUE, NS_TYPE_REPEATING_SLACK); + mTimer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback*, this), + timeout, nsITimer::TYPE_REPEATING_SLACK); } } else { // XXX hack.. the timer notify code will do the right thing, so just get that started mAnimating = PR_TRUE; if (!mTimer) mTimer = do_CreateInstance("@mozilla.org/timer;1"); - mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), - 100, PR_TRUE, NS_TYPE_REPEATING_SLACK); + mTimer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback*, this), + 100, nsITimer::TYPE_REPEATING_SLACK); } } @@ -378,25 +379,26 @@ NS_IMETHODIMP imgContainer::SetLoopCount(PRInt32 aLoopCount) } -NS_IMETHODIMP_(void) imgContainer::Notify(nsITimer *timer) + +NS_IMETHODIMP imgContainer::Notify(nsITimer *timer) { NS_ASSERTION(mTimer == timer, "uh"); if(!mAnimating || !mTimer) - return; + return NS_OK; nsCOMPtr observer(do_QueryReferent(mObserver)); if (!observer) { // the imgRequest that owns us is dead, we should die now too. this->StopAnimation(); - return; + return NS_OK; } nsCOMPtr nextFrame; PRInt32 timeout = 100; PRUint32 numFrames = inlinedGetNumFrames(); if(!numFrames) - return; + return NS_OK; // If we're done decoding the next frame, go ahead and display it now and reinit // the timer with the next frame's delay time. @@ -411,7 +413,7 @@ NS_IMETHODIMP_(void) imgContainer::Notify(nsITimer *timer) } else { // twiddle our thumbs inlinedGetFrameAt(mCurrentAnimationFrameIndex, getter_AddRefs(nextFrame)); - if(!nextFrame) return; + if(!nextFrame) return NS_OK; nextFrame->GetTimeout(&timeout); } @@ -420,12 +422,12 @@ NS_IMETHODIMP_(void) imgContainer::Notify(nsITimer *timer) // If animation mode is "loop once", it's time to stop animating if (mAnimationMode == kLoopOnceAnimMode || mLoopCount == 0) { this->StopAnimation(); - return; + return NS_OK; } // Go back to the beginning of the animation inlinedGetFrameAt(0, getter_AddRefs(nextFrame)); - if(!nextFrame) return; + if(!nextFrame) return NS_OK; mCurrentAnimationFrameIndex = 0; nextFrame->GetTimeout(&timeout); @@ -434,13 +436,13 @@ NS_IMETHODIMP_(void) imgContainer::Notify(nsITimer *timer) } else { mCurrentAnimationFrameIndex++; inlinedGetFrameAt(mCurrentAnimationFrameIndex, getter_AddRefs(nextFrame)); - if(!nextFrame) return; + if(!nextFrame) return NS_OK; nextFrame->GetTimeout(&timeout); } } else { inlinedGetFrameAt(mCurrentAnimationFrameIndex, getter_AddRefs(nextFrame)); - if(!nextFrame) return; + if(!nextFrame) return NS_OK; } if(timeout > 0) @@ -464,7 +466,7 @@ NS_IMETHODIMP_(void) imgContainer::Notify(nsITimer *timer) // do notification to FE to draw this frame observer->FrameChanged(this, nsnull, nextFrame, &dirtyRect); } - + return NS_OK; } //****************************************************************************** // DoComposite gets called when the timer for animation get fired and we have to diff --git a/modules/libpr0n/src/imgContainer.h b/modules/libpr0n/src/imgContainer.h index 73ade28747d..0aa53ca35a1 100644 --- a/modules/libpr0n/src/imgContainer.h +++ b/modules/libpr0n/src/imgContainer.h @@ -35,7 +35,6 @@ #include "nsCOMPtr.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "imgIDecoderObserver.h" #include "gfxIImageFrame.h" @@ -59,8 +58,7 @@ public: NS_DECL_IMGICONTAINER NS_DECL_IMGIDECODEROBSERVER NS_DECL_IMGICONTAINEROBSERVER - - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK imgContainer(); virtual ~imgContainer(); diff --git a/modules/plugin/base/src/nsPluginViewer.cpp b/modules/plugin/base/src/nsPluginViewer.cpp index c68d7f0fe6b..c0433018380 100644 --- a/modules/plugin/base/src/nsPluginViewer.cpp +++ b/modules/plugin/base/src/nsPluginViewer.cpp @@ -67,7 +67,6 @@ #include "nsContentCID.h" #include "nsIScriptGlobalObject.h" #include "nsITimer.h" -#include "nsITimerCallback.h" class nsIPrintSettings; class nsIDOMWindow; @@ -152,7 +151,8 @@ public: NS_IMETHOD Init(PluginViewerImpl *aViewer, nsIWidget *aWindow); // nsITimerCallback interface - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK + void CancelTimer(); nsPluginPort* GetPluginPort(); @@ -1083,7 +1083,7 @@ NS_IMETHODIMP pluginInstanceOwner :: CreateWidget(void) // start a periodic timer to provide null events to the plugin instance. mPluginTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (rv == NS_OK) - rv = mPluginTimer->Init(this, 1020 / 60, PR_TRUE, NS_TYPE_REPEATING_SLACK); + rv = mPluginTimer->InitWithCallback(this, 1020 / 60, nsITimer::TYPE_REPEATING_SLACK); #endif @@ -1326,7 +1326,7 @@ nsEventStatus pluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent) // Here's how we give idle time to plugins. -NS_IMETHODIMP_(void) pluginInstanceOwner::Notify(nsITimer* /* timer */) +NS_IMETHODIMP pluginInstanceOwner::Notify(nsITimer* /* timer */) { #ifdef XP_MAC // validate the plugin clipping information by syncing the plugin window info to @@ -1356,9 +1356,10 @@ NS_IMETHODIMP_(void) pluginInstanceOwner::Notify(nsITimer* /* timer */) nsresult rv; mPluginTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (NS_SUCCEEDED(rv)) - mPluginTimer->Init(this, 1020 / 60); + mPluginTimer->InitWithCallback(this, 1020 / 60, nsITimer::TYPE_ONE_SHOT); #endif // REPEATING_TIMERS #endif // XP_MAC + return NS_OK; } diff --git a/netwerk/protocol/ftp/src/nsFtpProtocolHandler.cpp b/netwerk/protocol/ftp/src/nsFtpProtocolHandler.cpp index 34667371443..6dd06e6fc91 100644 --- a/netwerk/protocol/ftp/src/nsFtpProtocolHandler.cpp +++ b/netwerk/protocol/ftp/src/nsFtpProtocolHandler.cpp @@ -316,10 +316,10 @@ nsFtpProtocolHandler::InsertConnection(nsIURI *aKey, nsISupports *aConn) if (!ts) return NS_ERROR_OUT_OF_MEMORY; - rv = timer->Init(nsFtpProtocolHandler::Timeout, - ts, - mIdleTimeout*1000, - PR_TRUE); + rv = timer->InitWithFuncCallback(nsFtpProtocolHandler::Timeout, + ts, + mIdleTimeout*1000, + nsITimer::TYPE_REPEATING_SLACK); if (NS_FAILED(rv)) { delete ts; return rv; diff --git a/netwerk/protocol/http/src/nsHttpHandler.cpp b/netwerk/protocol/http/src/nsHttpHandler.cpp index 434d167b349..abdf71f32ba 100644 --- a/netwerk/protocol/http/src/nsHttpHandler.cpp +++ b/netwerk/protocol/http/src/nsHttpHandler.cpp @@ -245,9 +245,8 @@ nsHttpHandler::Init() // failure to create a timer is not a fatal error, but idle connections // may not be cleaned up as aggressively. if (mTimer) - mTimer->Init(DeadConnectionCleanupCB, this, 15*1000, // 15 seconds - PR_TRUE, - NS_TYPE_REPEATING_SLACK); + mTimer->InitWithFuncCallback(DeadConnectionCleanupCB, this, 15*1000, // 15 seconds + nsITimer::TYPE_REPEATING_SLACK); return NS_OK; } diff --git a/security/manager/ssl/src/nsNSSComponent.cpp b/security/manager/ssl/src/nsNSSComponent.cpp index c0e06f0c6bc..757bcbc763b 100644 --- a/security/manager/ssl/src/nsNSSComponent.cpp +++ b/security/manager/ssl/src/nsNSSComponent.cpp @@ -694,7 +694,8 @@ nsresult nsNSSComponent::getParamsForNextCrlToDownload(nsAutoString *url, PRTime return rv; } -void nsNSSComponent::Notify(nsITimer *timer) +NS_IMETHODIMP +nsNSSComponent::Notify(nsITimer *timer) { nsresult rv; @@ -709,6 +710,7 @@ void nsNSSComponent::Notify(nsITimer *timer) //Dont Worry if successful or not //Set the next timer DefineNextTimer(); + return NS_OK; } nsresult @@ -767,7 +769,9 @@ nsNSSComponent::DefineNextTimer() interval = primaryDelay; } - mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), interval); + mTimer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback*, this), + interval, + nsITimer::TYPE_ONE_SHOT); crlDownloadTimerOn = PR_TRUE; //Release PR_Unlock(mCrlTimerLock); diff --git a/security/manager/ssl/src/nsNSSComponent.h b/security/manager/ssl/src/nsNSSComponent.h index a4000fc0023..9bcc006a0c4 100644 --- a/security/manager/ssl/src/nsNSSComponent.h +++ b/security/manager/ssl/src/nsNSSComponent.h @@ -41,7 +41,6 @@ #include "nsWeakReference.h" #include "nsIScriptSecurityManager.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsNetUtil.h" #include "nsHashtable.h" #include "prlock.h" @@ -150,6 +149,7 @@ public: NS_DECL_NSISIGNATUREVERIFIER NS_DECL_NSIENTROPYCOLLECTOR NS_DECL_NSIOBSERVER + NS_DECL_NSITIMERCALLBACK NS_METHOD Init(); @@ -169,7 +169,7 @@ public: NS_IMETHOD DefineNextTimer(); NS_IMETHOD DownloadCRLDirectly(nsAutoString, nsAutoString); NS_IMETHOD RememberCert(CERTCertificate *cert); - NS_IMETHOD_(void) Notify(nsITimer *timer); + private: nsresult InitializeNSS(); diff --git a/view/src/nsScrollPortView.h b/view/src/nsScrollPortView.h index f683393640c..531a59e1d37 100644 --- a/view/src/nsScrollPortView.h +++ b/view/src/nsScrollPortView.h @@ -46,7 +46,7 @@ class nsISupportsArray; //this is a class that acts as a container for other views and provides //automatic management of scrolling of the views it contains. -class nsScrollPortView : public nsView, public nsIScrollableView //, public nsITimerCallback +class nsScrollPortView : public nsView, public nsIScrollableView { public: nsScrollPortView(); @@ -103,9 +103,6 @@ private: protected: virtual ~nsScrollPortView(); - // nsITimerCallback Interface - //NS_IMETHOD_(void) Notify(nsITimer *timer); - //private void AdjustChildWidgets(nsScrollPortView *aScrolling, nsView *aView, nscoord aDx, nscoord aDy, float aScale); void Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy, float scale, PRUint32 aUpdateFlags); diff --git a/view/src/nsScrollingView.cpp b/view/src/nsScrollingView.cpp index b239e2596a0..862f04d8b70 100644 --- a/view/src/nsScrollingView.cpp +++ b/view/src/nsScrollingView.cpp @@ -759,7 +759,7 @@ void nsScrollingView::HandleScrollEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags } } -NS_IMETHODIMP_(void) nsScrollingView::Notify(nsITimer * aTimer) +NS_IMETHODIMP nsScrollingView::Notify(nsITimer * aTimer) { nscoord xoff, yoff; @@ -801,7 +801,9 @@ NS_IMETHODIMP_(void) nsScrollingView::Notify(nsITimer * aTimer) nsresult rv; mScrollingTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (NS_SUCCEEDED(rv)) - mScrollingTimer->Init(this, 25); + mScrollingTimer->InitWithCallback(this, 25, nsITimer::TYPE_ONE_SHOT); + + return NS_OK; } NS_IMETHODIMP nsScrollingView::CreateScrollControls(nsNativeWidget aNative) diff --git a/view/src/nsScrollingView.h b/view/src/nsScrollingView.h index cfa48ae437e..79d4a7e84d8 100644 --- a/view/src/nsScrollingView.h +++ b/view/src/nsScrollingView.h @@ -40,8 +40,8 @@ #include "nsView.h" #include "nsIScrollableView.h" +#include "nsCOMPtr.h" #include "nsITimer.h" -#include "nsITimerCallback.h" class nsISupportsArray; @@ -131,7 +131,7 @@ protected: virtual ~nsScrollingView(); // nsITimerCallback Interface - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK //private void AdjustChildWidgets(nsScrollingView *aScrolling, nsView *aView, nscoord aDx, nscoord aDy, float aScale); diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h index 70c90c549e8..b9762191a54 100644 --- a/view/src/nsViewManager.h +++ b/view/src/nsViewManager.h @@ -37,7 +37,7 @@ #ifndef nsViewManager_h___ #define nsViewManager_h___ - +#include "nsCOMPtr.h" #include "nsIViewManager.h" #include "nsCRT.h" #include "nsIPresContext.h" diff --git a/webshell/tests/viewer/nsThrobber.cpp b/webshell/tests/viewer/nsThrobber.cpp index 93d7068e8bf..a39d661901c 100644 --- a/webshell/tests/viewer/nsThrobber.cpp +++ b/webshell/tests/viewer/nsThrobber.cpp @@ -335,7 +335,8 @@ nsThrobber::Tick() nsresult rv; mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (NS_OK == rv) { - mTimer->Init(ThrobTimerCallback, this, 33); + mTimer->InitWithFuncCallback(ThrobTimerCallback, this, 33, + nsITimer::TYPE_ONE_SHOT); } #endif } @@ -364,7 +365,7 @@ nsThrobber::LoadThrobberImages(const nsString& aFileNameMask, PRInt32 aNumImages if (NS_OK != rv) { return rv; } - mTimer->Init(ThrobTimerCallback, this, 33, PR_TRUE, NS_TYPE_REPEATING_SLACK); + mTimer->InitWithFuncCallback(ThrobTimerCallback, this, 33, nsITimer::TYPE_REPEATING_SLACK); char * mask = ToNewCString(aFileNameMask); for (PRInt32 cnt = 0; cnt < mNumImages; cnt++) diff --git a/webshell/tests/viewer/nsWebCrawler.cpp b/webshell/tests/viewer/nsWebCrawler.cpp index 4c719b4869f..2afc9bf16d2 100644 --- a/webshell/tests/viewer/nsWebCrawler.cpp +++ b/webshell/tests/viewer/nsWebCrawler.cpp @@ -337,7 +337,8 @@ nsWebCrawler::LoadNextURLCallback(nsITimer *aTimer, void *aClosure) viewerFile->GetPrintable(&printable); if (PR_TRUE !=printable){ self->mTimer = do_CreateInstance("@mozilla.org/timer;1"); - self->mTimer->Init(LoadNextURLCallback, self, self->mDelay); + self->mTimer->InitWithFuncCallback(LoadNextURLCallback, self, self->mDelay, + nsITimer::TYPE_ONE_SHOT); return; } } @@ -463,10 +464,12 @@ nsWebCrawler::OnStateChange(nsIWebProgress* aWebProgress, } if ((0 < mQueuedLoadURLs) || (0 < mPendingURLs.Count())) { - mTimer->Init(LoadNextURLCallback, this, mDelay); + mTimer->InitWithFuncCallback(LoadNextURLCallback, this, mDelay, + nsITimer::TYPE_ONE_SHOT); } else if (mPostExit) { - mTimer->Init(QueueExitCallback, this, mDelay); + mTimer->InitWithFuncCallback(QueueExitCallback, this, mDelay, + nsITimer::TYPE_ONE_SHOT); } } diff --git a/widget/src/cocoa/nsSound.cpp b/widget/src/cocoa/nsSound.cpp index ba9d276b6af..3c2ecbb9831 100644 --- a/widget/src/cocoa/nsSound.cpp +++ b/widget/src/cocoa/nsSound.cpp @@ -57,7 +57,6 @@ #include "nsIInternetConfigService.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include #include @@ -81,7 +80,7 @@ public: NS_DECL_ISUPPORTS // nsITimerCallback - NS_IMETHOD_(void) Notify(nsITimer *timer) = 0; // pure virtual + NS_DECL_NSITIMERCALLBACK virtual nsresult PlaySound() = 0; @@ -109,7 +108,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsITimerCallback - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK nsresult Init(nsISound* aSound, ConstStr255Param aSoundName); virtual nsresult PlaySound(); @@ -143,7 +142,7 @@ public: NS_DECL_NSISTREAMLOADEROBSERVER // nsITimerCallback - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK nsresult Init(nsISound* aSound, nsIURL *aURL); virtual nsresult PlaySound(); @@ -600,8 +599,8 @@ nsSystemSoundRequest::PlaySound() } const PRInt32 kSoundTimerInterval = 250; // 250 milliseconds - rv = mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kSoundTimerInterval, - PR_TRUE, NS_TYPE_REPEATING_PRECISE); + rv = mTimer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback*, this), kSoundTimerInterval, + nsITimer::TYPE_REPEATING_PRECISE); if (NS_FAILED(rv)) { Cleanup(); return rv; @@ -610,13 +609,14 @@ nsSystemSoundRequest::PlaySound() return NS_OK; } -NS_IMETHODIMP_(void) +NS_IMETHODIMP nsSystemSoundRequest::Notify(nsITimer *timer) { if (mSoundDone) { Cleanup(); } + return NS_OK; } @@ -804,8 +804,8 @@ nsMovieSoundRequest::PlaySound() } const PRInt32 kMovieTimerInterval = 250; // 250 milliseconds - rv = mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kMovieTimerInterval, - PR_TRUE, NS_TYPE_REPEATING_PRECISE); + rv = mTimer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback*, this), kMovieTimerInterval, + nsITimer::TYPE_REPEATING_PRECISE); if (NS_FAILED(rv)) { Cleanup(); return rv; @@ -849,13 +849,13 @@ nsMovieSoundRequest::PlaySound() return NS_OK; } -NS_IMETHODIMP_(void) +NS_IMETHODIMP nsMovieSoundRequest::Notify(nsITimer *timer) { if (!mMovie) { NS_ASSERTION(0, "nsMovieSoundRequest has no movie in timer callback"); - return; + return NS_OK;; } #ifdef SOUND_DEBUG @@ -870,6 +870,7 @@ nsMovieSoundRequest::Notify(nsITimer *timer) // so won't necessarily go away. if (moviesDone) Cleanup(); + return NS_OK; } OSErr diff --git a/widget/src/gtk/nsWidget.h b/widget/src/gtk/nsWidget.h index 46167652351..4b0f7d2ef38 100644 --- a/widget/src/gtk/nsWidget.h +++ b/widget/src/gtk/nsWidget.h @@ -54,8 +54,6 @@ class nsIToolkit; #include "gtkmozbox.h" #include "nsITimer.h" -#include "nsITimerCallback.h" - #define NSRECT_TO_GDKRECT(ns,gdk) \ PR_BEGIN_MACRO \ diff --git a/widget/src/gtk/nsWindow.cpp b/widget/src/gtk/nsWindow.cpp index cc072ab2d8a..6d54ed6d5f3 100644 --- a/widget/src/gtk/nsWindow.cpp +++ b/widget/src/gtk/nsWindow.cpp @@ -3293,7 +3293,8 @@ nsWindow::OnDragLeaveSignal (GtkWidget * aWidget, mDragLeaveTimer = do_CreateInstance("@mozilla.org/timer;1"); NS_ASSERTION(mDragLeaveTimer, "Failed to create drag leave timer!"); // fire this baby asafp - mDragLeaveTimer->Init(DragLeaveTimerCallback, this, 0); + mDragLeaveTimer->InitWithFuncCallback(DragLeaveTimerCallback, this, 0, + nsITimer::TYPE_ONE_SHOT); } /* static */ @@ -3693,7 +3694,8 @@ nsresult nsWindow::PrimeICSpotTimer () mICSpotTimer = do_CreateInstance("@mozilla.org/timer;1", &err); if (NS_FAILED(err)) return err; - mICSpotTimer->Init(ICSpotCallback, this, 1000); + mICSpotTimer->InitWithFuncCallback(ICSpotCallback, this, 1000, + nsITimer::TYPE_ONE_SHOT); return NS_OK; } diff --git a/widget/src/mac/nsSound.cpp b/widget/src/mac/nsSound.cpp index 47645bcee48..d9394a21b42 100644 --- a/widget/src/mac/nsSound.cpp +++ b/widget/src/mac/nsSound.cpp @@ -56,7 +56,6 @@ #include "nsIInternetConfigService.h" #include "nsITimer.h" -#include "nsITimerCallback.h" #include "nsCRT.h" #include @@ -81,7 +80,7 @@ public: NS_DECL_ISUPPORTS // nsITimerCallback - NS_IMETHOD_(void) Notify(nsITimer *timer) = 0; // pure virtual + NS_DECL_NSITIMERCALLBACK virtual nsresult PlaySound() = 0; @@ -109,7 +108,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsITimerCallback - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK nsresult Init(nsISound* aSound, ConstStr255Param aSoundName); virtual nsresult PlaySound(); @@ -143,7 +142,7 @@ public: NS_DECL_NSISTREAMLOADEROBSERVER // nsITimerCallback - NS_IMETHOD_(void) Notify(nsITimer *timer); + NS_DECL_NSITIMERCALLBACK nsresult Init(nsISound* aSound, nsIURL *aURL); virtual nsresult PlaySound(); @@ -598,8 +597,8 @@ nsSystemSoundRequest::PlaySound() } const PRInt32 kSoundTimerInterval = 250; // 250 milliseconds - rv = mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kSoundTimerInterval, - PR_TRUE, NS_TYPE_REPEATING_PRECISE); + rv = mTimer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback*, this), kSoundTimerInterval, + nsITimer::TYPE_REPEATING_PRECISE); if (NS_FAILED(rv)) { Cleanup(); return rv; @@ -608,13 +607,14 @@ nsSystemSoundRequest::PlaySound() return NS_OK; } -NS_IMETHODIMP_(void) +NS_IMETHODIMP nsSystemSoundRequest::Notify(nsITimer *timer) { if (mSoundDone) { Cleanup(); } + return NS_OK; } @@ -854,8 +854,8 @@ nsMovieSoundRequest::PlaySound() } const PRInt32 kMovieTimerInterval = 250; // 250 milliseconds - rv = mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kMovieTimerInterval, - PR_TRUE, NS_TYPE_REPEATING_PRECISE); + rv = mTimer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback*, this), kMovieTimerInterval, + nsITimer::TYPE_REPEATING_PRECISE); if (NS_FAILED(rv)) { Cleanup(); return rv; @@ -899,13 +899,13 @@ nsMovieSoundRequest::PlaySound() return NS_OK; } -NS_IMETHODIMP_(void) +NS_IMETHODIMP nsMovieSoundRequest::Notify(nsITimer *timer) { if (!mMovie) { NS_ASSERTION(0, "nsMovieSoundRequest has no movie in timer callback"); - return; + return NS_OK; } #ifdef SOUND_DEBUG @@ -920,6 +920,7 @@ nsMovieSoundRequest::Notify(nsITimer *timer) // so won't necessarily go away. if (moviesDone) Cleanup(); + return NS_OK; } OSErr diff --git a/xpcom/ds/nsRecyclingAllocator.cpp b/xpcom/ds/nsRecyclingAllocator.cpp index 4297a5f8b07..f6ff79e8b35 100644 --- a/xpcom/ds/nsRecyclingAllocator.cpp +++ b/xpcom/ds/nsRecyclingAllocator.cpp @@ -44,10 +44,10 @@ #include #include #include "nsRecyclingAllocator.h" -#include "nsITimer.h" #include "nsIMemory.h" #include "nsAutoLock.h" #include "prprf.h" +#include "nsITimer.h" #define NS_SEC_TO_MS(s) ((s) * 1000) @@ -189,9 +189,13 @@ nsRecyclingAllocator::Malloc(PRSize bytes, PRBool zeroit) // will try again to set the timer. if (mRecycleAfter && !mRecycleTimer) { - (void) NS_NewTimer(&mRecycleTimer, nsRecycleTimerCallback, this, - NS_SEC_TO_MS(mRecycleAfter), PR_TRUE, - NS_TYPE_REPEATING_SLACK); + // known only to stuff in xpcom. + extern nsresult NS_NewTimer(nsITimer* *aResult, nsTimerCallbackFunc aCallback, void *aClosure, + PRUint32 aDelay, PRUint32 aType); + + (void) NS_NewTimer(&mRecycleTimer, nsRecycleTimerCallback, this, + NS_SEC_TO_MS(mRecycleAfter), + nsITimer::TYPE_REPEATING_SLACK); NS_ASSERTION(mRecycleTimer, "nsRecyclingAllocator: Creating timer failed.\n"); } diff --git a/xpcom/macbuild/XPCOMIDL.xml b/xpcom/macbuild/XPCOMIDL.xml index fee9618b364..a744a28755d 100644 --- a/xpcom/macbuild/XPCOMIDL.xml +++ b/xpcom/macbuild/XPCOMIDL.xml @@ -971,7 +971,14 @@ Name - nsIScriptableTimer.idl + nsITimer.idl + MacOS + Text + + + + Name + nsITimerInternal.idl MacOS Text @@ -1465,7 +1472,12 @@ Name - nsIScriptableTimer.idl + nsITimer.idl + MacOS + + + Name + nsITimerInternal.idl MacOS @@ -2638,7 +2650,14 @@ Name - nsIScriptableTimer.idl + nsITimer.idl + MacOS + Text + + + + Name + nsITimerInternal.idl MacOS Text @@ -3132,7 +3151,12 @@ Name - nsIScriptableTimer.idl + nsITimer.idl + MacOS + + + Name + nsITimerInternal.idl MacOS @@ -3728,7 +3752,13 @@ headers Name - nsIScriptableTimer.idl + nsITimer.idl + MacOS + + + headers + Name + nsITimerInternal.idl MacOS diff --git a/xpcom/threads/MANIFEST b/xpcom/threads/MANIFEST index 81592b8a63f..5a213b1b856 100644 --- a/xpcom/threads/MANIFEST +++ b/xpcom/threads/MANIFEST @@ -1,5 +1,4 @@ nsAutoLock.h plevent.h nsProcess.h -nsITimer.h -nsITimerCallback.h + diff --git a/xpcom/threads/MANIFEST_IDL b/xpcom/threads/MANIFEST_IDL index f581e347643..e69de29bb2d 100644 --- a/xpcom/threads/MANIFEST_IDL +++ b/xpcom/threads/MANIFEST_IDL @@ -1,7 +0,0 @@ -nsIRunnable.idl -nsIThread.idl -nsIThreadPool.idl -nsITimerManager.idl -nsIEventQueue.idl -nsIEventQueueService.idl -nsIScriptableTimer.idl diff --git a/xpcom/threads/Makefile.in b/xpcom/threads/Makefile.in index 269a48224de..bcc8a1f5993 100644 --- a/xpcom/threads/Makefile.in +++ b/xpcom/threads/Makefile.in @@ -55,19 +55,18 @@ EXPORTS = \ nsAutoLock.h \ plevent.h \ nsProcess.h \ - nsITimer.h \ - nsITimerCallback.h \ $(NULL) XPIDLSRCS = \ nsIThread.idl \ nsIThreadPool.idl \ + nsITimer.idl \ + nsITimerInternal.idl \ nsITimerManager.idl \ nsIRunnable.idl \ nsIEventQueue.idl \ nsIEventQueueService.idl \ nsIProcess.idl \ - nsIScriptableTimer.idl \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/xpcom/threads/nsIScriptableTimer.idl b/xpcom/threads/nsIScriptableTimer.idl deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/xpcom/threads/nsITimer.h b/xpcom/threads/nsITimer.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/xpcom/threads/nsITimer.idl b/xpcom/threads/nsITimer.idl new file mode 100644 index 00000000000..0367a186e19 --- /dev/null +++ b/xpcom/threads/nsITimer.idl @@ -0,0 +1,178 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by the Initial Developer are + * Copyright (C) 2002 the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + */ + +#include "nsISupports.idl" + +interface nsIObserver; + +%{C++ +/** + * The signature of the timer callback function passed to initWithCallback. This + * is the function that will get called when the timer expires if the timer is + * initialized via initWithCallback. + * + * @param aTimer the timer which has expired + * @param aClosure opaque parameter passed to initWithCallback + * + * Implementers should return the following: + * + * @return NS_OK + * + */ +class nsITimer; +typedef void (*nsTimerCallbackFunc) (nsITimer *aTimer, void *aClosure); +%} + +native nsTimerCallbackFunc(nsTimerCallbackFunc); + +/** + * The callback interface for timers. + */ +interface nsITimer; + +[scriptable, uuid(a796816d-7d47-4348-9ab8-c7aeb3216a7d)] +interface nsITimerCallback : nsISupports +{ + /** + * @param aTimer the timer which has expired + */ + void notify(in nsITimer timer); +}; + + +[scriptable, uuid(29ee628e-a3ea-471f-965d-dc9f11d1c183)] +interface nsITimer : nsISupports +{ + /* Timer types */ + + /** + * Type of a timer that fires once only. + */ + const short TYPE_ONE_SHOT = 0; + + /** + * After firing, a TYPE_REPEATING_SLACK timer is stopped and not restarted + * until its callback completes. Specified timer period will be at least + * the time between when processing for last firing the callback completes + * and when the next firing occurs. + * + * This is the preferable repeating type for most situations. + */ + const short TYPE_REPEATING_SLACK = 1; + + /** + * An TYPE_REPEATING_PRECISE repeating timer aims to have constant period + * between firings. The processing time for each timer callback should not + * influence the timer period. However, if the processing for the last + * timer firing could not be completed until just before the next firing + * occurs, then you could have two timer notification routines being + * executed in quick succession. + */ + const short TYPE_REPEATING_PRECISE = 2; + + /** + * Initialize a timer that will fire after the said delay. + * A user must keep a reference to this timer till it is + * is no longer needed or has been cancelled. + * + * @param aObserver the callback object that observes the + * ``timer-callback'' topic with the subject being + * the timer itself when the timer fires: + * + * observe(nsISupports aSubject, => nsITimer + * string aTopic, => ``timer-callback'' + * wstring data => null + * + * @param aDelay delay in milliseconds for timer to fire + * @param aType timer type per TYPE* consts defined above + */ + void init(in nsIObserver aObserver, in unsigned long aDelay, + in unsigned long aType); + + + /** + * Initialize a timer to fire after the given millisecond interval. + * This version takes a function to call and a closure to pass to + * that function. + * + * @param aFunc The function to invoke + * @param aClosure An opaque pointer to pass to that function + * @param aDelay The millisecond interval + * @param aType Timer type per TYPE* consts defined above + */ + [noscript] void initWithFuncCallback(in nsTimerCallbackFunc aCallback, + in voidPtr aClosure, + in unsigned long aDelay, + in unsigned long aType); + + /** + * Initialize a timer to fire after the given millisecond interval. + * This version takes a function to call and a closure to pass to + * that function. + * + * @param aFunc nsITimerCallback interface to call when timer expires + * @param aDelay The millisecond interval + * @param aType Timer type per TYPE* consts defined above + */ + void initWithCallback(in nsITimerCallback aCallback, + in unsigned long aDelay, + in unsigned long aType); + + /** + * Cancellation of timers applies to repeating timers + * (i.e., init()ed with aType=TYPE_REPEATING*). + */ + void cancel(); + + /** + * The millisecond delay of the timeout + */ + attribute unsigned long delay; + + /** + * The timer type : one shot or repeating + */ + attribute unsigned long type; + + /** + * The opaque pointer pass to initWithCallback. + */ + [noscript] readonly attribute voidPtr closure; +}; + +%{C++ +#define NS_TIMER_CONTRACTID "@mozilla.org/timer;1" +#define NS_TIMER_CALLBACK_TOPIC "timer-callback" +%} + diff --git a/xpcom/threads/nsITimerCallback.h b/xpcom/threads/nsITimerCallback.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/xpcom/threads/nsITimerInternal.idl b/xpcom/threads/nsITimerInternal.idl new file mode 100644 index 00000000000..53f4a829f86 --- /dev/null +++ b/xpcom/threads/nsITimerInternal.idl @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by the Initial Developer are + * Copyright (C) 2002 the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + */ + +#include "nsISupports.idl" + + +[scriptable, uuid(6dd8f185-ceb8-4878-8e38-2d13edc2d079)] +interface nsITimerInternal : nsISupports +{ + attribute boolean idle; +}; + diff --git a/xpcom/threads/nsTimerImpl.cpp b/xpcom/threads/nsTimerImpl.cpp index 4cb465692b7..d739f98f752 100644 --- a/xpcom/threads/nsTimerImpl.cpp +++ b/xpcom/threads/nsTimerImpl.cpp @@ -76,7 +76,7 @@ myNS_MeanAndStdDev(double n, double sumOfValues, double sumOfSquaredValues, } #endif -NS_IMPL_THREADSAFE_QUERY_INTERFACE2(nsTimerImpl, nsITimer, nsIScriptableTimer) +NS_IMPL_THREADSAFE_QUERY_INTERFACE2(nsTimerImpl, nsITimer, nsITimerInternal) NS_IMPL_THREADSAFE_ADDREF(nsTimerImpl) NS_IMETHODIMP_(nsrefcnt) nsTimerImpl::Release(void) @@ -157,7 +157,8 @@ nsTimerImpl::nsTimerImpl() : mFiring(PR_FALSE), mArmed(PR_FALSE), mCanceled(PR_FALSE), - mTimeout(0) + mTimeout(0), + mIdle(PR_TRUE) { NS_INIT_REFCNT(); nsIThread::GetCurrent(getter_AddRefs(mCallingThread)); @@ -204,11 +205,10 @@ void nsTimerImpl::Shutdown() } -NS_IMETHODIMP nsTimerImpl::Init(nsTimerCallbackFunc aFunc, - void *aClosure, - PRUint32 aDelay, - PRBool aIdle, - PRUint32 aType) +NS_IMETHODIMP nsTimerImpl::InitWithFuncCallback(nsTimerCallbackFunc aFunc, + void *aClosure, + PRUint32 aDelay, + PRUint32 aType) { if (!gThread) return NS_ERROR_FAILURE; @@ -218,7 +218,6 @@ NS_IMETHODIMP nsTimerImpl::Init(nsTimerCallbackFunc aFunc, mClosure = aClosure; - mIdle = aIdle; mType = (PRUint8)aType; SetDelayInternal(aDelay); @@ -226,10 +225,9 @@ NS_IMETHODIMP nsTimerImpl::Init(nsTimerCallbackFunc aFunc, return gThread->AddTimer(this); } -NS_IMETHODIMP nsTimerImpl::Init(nsITimerCallback *aCallback, - PRUint32 aDelay, - PRBool aIdle, - PRUint32 aType) +NS_IMETHODIMP nsTimerImpl::InitWithCallback(nsITimerCallback *aCallback, + PRUint32 aDelay, + PRUint32 aType) { if (!gThread) return NS_ERROR_FAILURE; @@ -238,7 +236,6 @@ NS_IMETHODIMP nsTimerImpl::Init(nsITimerCallback *aCallback, NS_ADDREF(mCallback.i); mCallbackType = CALLBACK_TYPE_INTERFACE; - mIdle = aIdle; mType = (PRUint8)aType; SetDelayInternal(aDelay); @@ -248,7 +245,6 @@ NS_IMETHODIMP nsTimerImpl::Init(nsITimerCallback *aCallback, NS_IMETHODIMP nsTimerImpl::Init(nsIObserver *aObserver, PRUint32 aDelay, - PRBool aIdle, PRUint32 aType) { if (!gThread) @@ -260,7 +256,6 @@ NS_IMETHODIMP nsTimerImpl::Init(nsIObserver *aObserver, NS_ADDREF(mCallback.o); mCallbackType = CALLBACK_TYPE_OBSERVER; - mIdle = aIdle; mType = (PRUint8)aType; return gThread->AddTimer(this); @@ -276,25 +271,60 @@ NS_IMETHODIMP nsTimerImpl::Cancel() return NS_OK; } -NS_IMETHODIMP_(void) nsTimerImpl::SetDelay(PRUint32 aDelay) +NS_IMETHODIMP nsTimerImpl::SetDelay(PRUint32 aDelay) { // If we're already repeating precisely, update mTimeout now so that the // new delay takes effect in the future. - if (mTimeout != 0 && mType == NS_TYPE_REPEATING_PRECISE) + if (mTimeout != 0 && mType == TYPE_REPEATING_PRECISE) mTimeout = PR_IntervalNow(); SetDelayInternal(aDelay); if (!mFiring && gThread) gThread->TimerDelayChanged(this); + + return NS_OK; } -NS_IMETHODIMP_(void) nsTimerImpl::SetType(PRUint32 aType) +NS_IMETHODIMP nsTimerImpl::GetDelay(PRUint32* aDelay) +{ + *aDelay = mDelay; + return NS_OK; +} + +NS_IMETHODIMP nsTimerImpl::SetType(PRUint32 aType) { mType = (PRUint8)aType; // XXX if this is called, we should change the actual type.. this could effect // repeating timers. we need to ensure in Fire() that if mType has changed // during the callback that we don't end up with the timer in the queue twice. + return NS_OK; +} + +NS_IMETHODIMP nsTimerImpl::GetType(PRUint32* aType) +{ + *aType = mType; + return NS_OK; +} + + +NS_IMETHODIMP nsTimerImpl::GetClosure(void** aClosure) +{ + *aClosure = mClosure; + return NS_OK; +} + + +NS_IMETHODIMP nsTimerImpl::GetIdle(PRBool *aIdle) +{ + *aIdle = mIdle; + return NS_OK; +} + +NS_IMETHODIMP nsTimerImpl::SetIdle(PRBool aIdle) +{ + mIdle = aIdle; + return NS_OK; } void nsTimerImpl::Fire() @@ -323,7 +353,7 @@ void nsTimerImpl::Fire() #endif PRIntervalTime timeout = mTimeout; - if (mType == NS_TYPE_REPEATING_PRECISE) { + if (mType == TYPE_REPEATING_PRECISE) { // Precise repeating timers advance mTimeout by mDelay without fail before // calling Fire(). timeout -= PR_MillisecondsToInterval(mDelay); @@ -340,7 +370,7 @@ void nsTimerImpl::Fire() mCallback.i->Notify(this); break; case CALLBACK_TYPE_OBSERVER: - mCallback.o->Observe(NS_STATIC_CAST(nsIScriptableTimer *, this), + mCallback.o->Observe(NS_STATIC_CAST(nsITimer*,this), NS_TIMER_CALLBACK_TOPIC, nsnull); break; @@ -357,7 +387,7 @@ void nsTimerImpl::Fire() } #endif - if (mType == NS_TYPE_REPEATING_SLACK) { + if (mType == TYPE_REPEATING_SLACK) { SetDelayInternal(mDelay); // force mTimeout to be recomputed. if (gThread) gThread->AddTimer(this); @@ -386,7 +416,9 @@ void* handleTimerEvent(TimerEventType* event) #endif if (gFireOnIdle) { - if (NS_STATIC_CAST(nsTimerImpl*, event->e.owner)->IsIdle()) { + PRBool idle = PR_FALSE; + NS_STATIC_CAST(nsTimerImpl*, event->e.owner)->GetIdle(&idle); + if (idle) { NS_ASSERTION(gManager, "Global Thread Manager is null!"); if (gManager) gManager->AddIdleTimer(NS_STATIC_CAST(nsTimerImpl*, event->e.owner)); @@ -432,7 +464,7 @@ void nsTimerImpl::PostTimerEvent() // If this is a repeating precise timer, we need to calculate the time for // the next timer to fire before we make the callback. - if (mType == NS_TYPE_REPEATING_PRECISE) { + if (mType == TYPE_REPEATING_PRECISE) { SetDelayInternal(mDelay); if (gThread) gThread->AddTimer(this); @@ -459,7 +491,7 @@ void nsTimerImpl::SetDelayInternal(PRUint32 aDelay) mDelay = aDelay; PRIntervalTime now = PR_IntervalNow(); - if (mTimeout == 0 || mType != NS_TYPE_REPEATING_PRECISE) + if (mTimeout == 0 || mType != TYPE_REPEATING_PRECISE) mTimeout = now; mTimeout += delayInterval; @@ -474,26 +506,6 @@ void nsTimerImpl::SetDelayInternal(PRUint32 aDelay) #endif } -nsresult -NS_NewTimer(nsITimer* *aResult, nsTimerCallbackFunc aCallback, void *aClosure, - PRUint32 aDelay, PRBool aIdle, PRUint32 aType) -{ - nsTimerImpl* timer = new nsTimerImpl(); - if (timer == nsnull) - return NS_ERROR_OUT_OF_MEMORY; - NS_ADDREF(timer); - - nsresult rv = timer->Init(aCallback, aClosure, aDelay, aIdle, aType); - if (NS_FAILED(rv)) { - NS_RELEASE(timer); - return rv; - } - - *aResult = timer; - return NS_OK; -} - - /** * Timer Manager code */ @@ -580,3 +592,25 @@ NS_IMETHODIMP nsTimerManager::FireNextIdleTimer() return NS_OK; } + + +// NOT FOR PUBLIC CONSUMPTION! +nsresult +NS_NewTimer(nsITimer* *aResult, nsTimerCallbackFunc aCallback, void *aClosure, + PRUint32 aDelay, PRUint32 aType) +{ + nsTimerImpl* timer = new nsTimerImpl(); + if (timer == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(timer); + + nsresult rv = timer->InitWithFuncCallback(aCallback, aClosure, + aDelay, aType); + if (NS_FAILED(rv)) { + NS_RELEASE(timer); + return rv; + } + + *aResult = timer; + return NS_OK; +} diff --git a/xpcom/threads/nsTimerImpl.h b/xpcom/threads/nsTimerImpl.h index ac632be7565..2445ac7386d 100644 --- a/xpcom/threads/nsTimerImpl.h +++ b/xpcom/threads/nsTimerImpl.h @@ -36,15 +36,12 @@ #ifndef nsTimerImpl_h___ #define nsTimerImpl_h___ -#define NS_TIMER_CONTRACTID "@mozilla.org/timer;1" - //#define FORCE_PR_LOG /* Allow logging in the release build */ #include "nsITimer.h" -#include "nsITimerCallback.h" -#include "nsIScriptableTimer.h" #include "nsVoidArray.h" #include "nsIThread.h" +#include "nsITimerInternal.h" #include "nsCOMPtr.h" @@ -82,7 +79,7 @@ enum { // Is interval-time t less than u, even if t has wrapped PRIntervalTime? #define TIMER_LESS_THAN(t, u) ((t) - (u) > DELAY_INTERVAL_LIMIT) -class nsTimerImpl : public nsITimer, public nsIScriptableTimer +class nsTimerImpl : public nsITimer, public nsITimerInternal { public: @@ -97,29 +94,9 @@ public: void PostTimerEvent(); void SetDelayInternal(PRUint32 aDelay); - NS_IMETHOD Init(nsTimerCallbackFunc aFunc, - void *aClosure, - PRUint32 aDelay, - PRBool aIdle, - PRUint32 aType); - - NS_IMETHOD Init(nsITimerCallback *aCallback, - PRUint32 aDelay, - PRBool aIdle, - PRUint32 aType); - NS_DECL_ISUPPORTS - NS_DECL_NSISCRIPTABLETIMER - - NS_IMETHOD_(PRBool) IsIdle() const { return mIdle; } - - NS_IMETHOD_(PRUint32) GetDelay() const { return mDelay; } - NS_IMETHOD_(void) SetDelay(PRUint32 aDelay); - - NS_IMETHOD_(PRUint32) GetType() const { return (PRUint32)mType; } - NS_IMETHOD_(void) SetType(PRUint32 aType); - - NS_IMETHOD_(void*) GetClosure() const { return mClosure; } + NS_DECL_NSITIMER + NS_DECL_NSITIMERINTERNAL private: nsCOMPtr mCallingThread; diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index 02b97fbe86e..9af1842667f 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -1183,8 +1183,8 @@ nsWebShellWindow::SetPersistenceTimer(PRBool aSize, PRBool aPosition, PRBool aMo nsresult rv; mSPTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (NS_SUCCEEDED(rv)) { - mSPTimer->Init(FirePersistenceTimer, this, - SIZE_PERSISTENCE_TIMEOUT, NS_TYPE_ONE_SHOT); + mSPTimer->InitWithFuncCallback(FirePersistenceTimer, this, + SIZE_PERSISTENCE_TIMEOUT, nsITimer::TYPE_ONE_SHOT); mSPTimerSize = aSize; mSPTimerPosition = aPosition; mSPTimerMode = aMode; diff --git a/xpfe/browser/src/nsBrowserInstance.cpp b/xpfe/browser/src/nsBrowserInstance.cpp index 16bfe320985..ca114f0ebe3 100644 --- a/xpfe/browser/src/nsBrowserInstance.cpp +++ b/xpfe/browser/src/nsBrowserInstance.cpp @@ -338,7 +338,8 @@ public: mShutdownTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create timer for PageCycler..."); if (NS_SUCCEEDED(rv) && mShutdownTimer){ - mShutdownTimer->Init(TimesUp, (void *)this, mTimeoutValue*1000); + mShutdownTimer->InitWithFuncCallback(TimesUp, (void *)this, mTimeoutValue*1000, + nsITimer::TYPE_ONE_SHOT); } } return rv; diff --git a/xpfe/browser/src/nsBrowserStatusFilter.cpp b/xpfe/browser/src/nsBrowserStatusFilter.cpp index 65789ba6404..4b7301952cd 100644 --- a/xpfe/browser/src/nsBrowserStatusFilter.cpp +++ b/xpfe/browser/src/nsBrowserStatusFilter.cpp @@ -39,6 +39,7 @@ #include "nsIFileTransportService.h" #include "nsIChannel.h" #include "nsITimer.h" +#include "nsIServiceManager.h" #include "nsString.h" // XXX @@ -269,10 +270,9 @@ nsBrowserStatusFilter::StartDelayTimer() NS_ASSERTION(!DelayInEffect(), "delay should not be in effect"); - rv = NS_NewTimer(getter_AddRefs(mTimer), - TimeoutHandler, - this, 400, PR_TRUE, - NS_TYPE_ONE_SHOT); + mTimer = do_CreateInstance("@mozilla.org/timer;1"); + mTimer->InitWithFuncCallback(TimeoutHandler, this, 400, + nsITimer::TYPE_ONE_SHOT); if (NS_FAILED(rv)) return rv; return NS_OK; diff --git a/xpfe/components/bookmarks/src/nsBookmarksService.cpp b/xpfe/components/bookmarks/src/nsBookmarksService.cpp index 0b63688c274..59ae7ab1563 100644 --- a/xpfe/components/bookmarks/src/nsBookmarksService.cpp +++ b/xpfe/components/bookmarks/src/nsBookmarksService.cpp @@ -1818,7 +1818,8 @@ nsBookmarksService::Init() mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a timer"); if (NS_FAILED(rv)) return rv; - mTimer->Init(nsBookmarksService::FireTimer, this, BOOKMARK_TIMEOUT, PR_TRUE, NS_TYPE_REPEATING_SLACK); + mTimer->InitWithFuncCallback(nsBookmarksService::FireTimer, this, BOOKMARK_TIMEOUT, + nsITimer::TYPE_REPEATING_SLACK); // Note: don't addref "this" as we'll cancel the timer in the nsBookmarkService destructor } @@ -2138,7 +2139,8 @@ else } bmks->mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (NS_FAILED(rv) || (!bmks->mTimer)) return; - bmks->mTimer->Init(nsBookmarksService::FireTimer, bmks, BOOKMARK_TIMEOUT, PR_TRUE, NS_TYPE_REPEATING_SLACK); + bmks->mTimer->InitWithFuncCallback(nsBookmarksService::FireTimer, bmks, BOOKMARK_TIMEOUT, + nsITimer::TYPE_REPEATING_SLACK); // Note: don't addref "this" as we'll cancel the timer in the nsBookmarkService destructor #endif } diff --git a/xpfe/components/directory/nsDirectoryViewer.cpp b/xpfe/components/directory/nsDirectoryViewer.cpp index bb3d37088c9..b625ece5f0d 100644 --- a/xpfe/components/directory/nsDirectoryViewer.cpp +++ b/xpfe/components/directory/nsDirectoryViewer.cpp @@ -927,8 +927,8 @@ nsHTTPIndex::GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBo NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a timer"); if (NS_SUCCEEDED(rv)) { - mTimer->Init(nsHTTPIndex::FireTimer, this, 1, - PR_TRUE, NS_TYPE_ONE_SHOT); + mTimer->InitWithFuncCallback(nsHTTPIndex::FireTimer, this, 1, + nsITimer::TYPE_ONE_SHOT); // Note: don't addref "this" as we'll cancel the // timer in the httpIndex destructor } @@ -963,8 +963,8 @@ nsHTTPIndex::AddElement(nsIRDFResource *parent, nsIRDFResource *prop, nsIRDFNode NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a timer"); if (NS_FAILED(rv)) return(rv); - mTimer->Init(nsHTTPIndex::FireTimer, this, 1, - PR_TRUE, NS_TYPE_ONE_SHOT); + mTimer->InitWithFuncCallback(nsHTTPIndex::FireTimer, this, 1, + nsITimer::TYPE_ONE_SHOT); // Note: don't addref "this" as we'll cancel the // timer in the httpIndex destructor } @@ -1104,8 +1104,8 @@ nsHTTPIndex::FireTimer(nsITimer* aTimer, void* aClosure) httpIndex->mTimer = do_CreateInstance("@mozilla.org/timer;1"); if (httpIndex->mTimer) { - httpIndex->mTimer->Init(nsHTTPIndex::FireTimer, aClosure, 10, - PR_TRUE, NS_TYPE_ONE_SHOT); + httpIndex->mTimer->InitWithFuncCallback(nsHTTPIndex::FireTimer, aClosure, 10, + nsITimer::TYPE_ONE_SHOT); // Note: don't addref "this" as we'll cancel the // timer in the httpIndex destructor } diff --git a/xpfe/components/history/src/nsGlobalHistory.cpp b/xpfe/components/history/src/nsGlobalHistory.cpp index 69b7e100a80..b3b358cb9f9 100644 --- a/xpfe/components/history/src/nsGlobalHistory.cpp +++ b/xpfe/components/history/src/nsGlobalHistory.cpp @@ -1724,8 +1724,8 @@ nsGlobalHistory::SetDirty() if (NS_FAILED(rv)) return rv; mDirty = PR_TRUE; - mSyncTimer->Init(fireSyncTimer, this, HISTORY_SYNC_TIMEOUT, - PR_TRUE, NS_TYPE_ONE_SHOT); + mSyncTimer->InitWithFuncCallback(fireSyncTimer, this, HISTORY_SYNC_TIMEOUT, + nsITimer::TYPE_ONE_SHOT); return NS_OK; @@ -1743,8 +1743,8 @@ nsGlobalHistory::GetNow() mExpireNowTimer = do_CreateInstance("@mozilla.org/timer;1"); if (mExpireNowTimer) - mExpireNowTimer->Init(expireNowTimer, this, HISTORY_EXPIRE_NOW_TIMEOUT, - PR_TRUE, NS_TYPE_ONE_SHOT); + mExpireNowTimer->InitWithFuncCallback(expireNowTimer, this, HISTORY_EXPIRE_NOW_TIMEOUT, + nsITimer::TYPE_ONE_SHOT); } return mLastNow; diff --git a/xpfe/components/search/src/nsInternetSearchService.cpp b/xpfe/components/search/src/nsInternetSearchService.cpp index 5bc48035468..645709735f9 100755 --- a/xpfe/components/search/src/nsInternetSearchService.cpp +++ b/xpfe/components/search/src/nsInternetSearchService.cpp @@ -723,8 +723,8 @@ else search->mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (NS_FAILED(rv) || (!search->mTimer)) return; - search->mTimer->Init(InternetSearchDataSource::FireTimer, search, - SEARCH_UPDATE_TIMEOUT, PR_TRUE, NS_TYPE_REPEATING_SLACK); + search->mTimer->InitWithFuncCallback(InternetSearchDataSource::FireTimer, search, + SEARCH_UPDATE_TIMEOUT, nsITimer::TYPE_REPEATING_SLACK); // Note: don't addref "this" as we'll cancel the timer in the InternetSearchDataSource destructor #endif } @@ -926,8 +926,8 @@ InternetSearchDataSource::Init() mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); if (mTimer) { - mTimer->Init(InternetSearchDataSource::FireTimer, this, - SEARCH_UPDATE_TIMEOUT, PR_TRUE, NS_TYPE_REPEATING_SLACK); + mTimer->InitWithFuncCallback(InternetSearchDataSource::FireTimer, this, + SEARCH_UPDATE_TIMEOUT, nsITimer::TYPE_REPEATING_SLACK); // Note: don't addref "this" as we'll cancel the timer in the // InternetSearchDataSource destructor } diff --git a/xpfe/components/updates/src/nsUpdateNotifier.js b/xpfe/components/updates/src/nsUpdateNotifier.js index 5d74492acbf..5a97005436f 100644 --- a/xpfe/components/updates/src/nsUpdateNotifier.js +++ b/xpfe/components/updates/src/nsUpdateNotifier.js @@ -77,11 +77,11 @@ var nsUpdateNotifier = { try { - const kIScriptableTimer = Components.interfaces.nsIScriptableTimer; + const kITimer = Components.interfaces.nsITimer; mTimer = Components.classes["@mozilla.org/timer;1"]. - createInstance(kIScriptableTimer); - mTimer.init(this, kUpdateCheckDelay, true, - kIScriptableTimer.TYPE_ONE_SHOT); + createInstance(kITimer); + mTimer.init(this, kUpdateCheckDelay, + kITimer.TYPE_ONE_SHOT); // we are no longer interested in the ``domwindowopened'' topic var observerService = Components.