This commit is contained in:
dougt%netscape.com 2002-09-07 05:38:16 +00:00
Родитель f53d10d32e
Коммит d94b37c68a
100 изменённых файлов: 678 добавлений и 442 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);
}
}
}

Просмотреть файл

@ -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<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
nsCOMPtr<nsIURI> 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;
}
//*****************************************************************************

Просмотреть файл

@ -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<nsIDocShell> mDocShell;

Просмотреть файл

@ -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.

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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();

Просмотреть файл

@ -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

Просмотреть файл

@ -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
*/

Просмотреть файл

@ -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

Просмотреть файл

@ -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
*/

Просмотреть файл

@ -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

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -39,6 +39,7 @@
#ifndef __inSearchLoop_h__
#define __inSearchLoop_h__
#include "nsCOMPtr.h"
#include "nsITimer.h"
#include "inISearchProcess.h"

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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();

Просмотреть файл

@ -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);
}
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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

Просмотреть файл

@ -60,7 +60,6 @@
#ifdef IMPLEMENT_TIMER_STUFF
#include "nsITimer.h"
#include "nsITimerCallback.h"
#endif // IMPLEMENT_TIMER_STUFF
// {ED132C20-EED1-11d2-BAA4-00805F8A5DD7}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<nsIPref> prefs(do_GetService(kPrefServiceCID));
if (prefs)
prefs->GetIntPref("nglayout.initialpaint.delay", &delay);
mPaintSuppressionTimer->Init(sPaintSuppressionCallback, this, delay, PR_FALSE);
nsCOMPtr<nsITimerInternal> 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);
}
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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()

Просмотреть файл

@ -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
}
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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
}
}

Просмотреть файл

@ -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<nsIPref> prefs(do_GetService(kPrefServiceCID));
if (prefs)
prefs->GetIntPref("nglayout.initialpaint.delay", &delay);
mPaintSuppressionTimer->Init(sPaintSuppressionCallback, this, delay, PR_FALSE);
nsCOMPtr<nsITimerInternal> 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);
}
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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()

Просмотреть файл

@ -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

Просмотреть файл

@ -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);

Просмотреть файл

@ -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

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsMenuListener.h"
#include "nsMenuBarFrame.h"
#include "nsIServiceManager.h"
#include "nsIContent.h"
#include "prtypes.h"
#include "nsIAtom.h"

Просмотреть файл

@ -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<nsITimerInternal> 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

Просмотреть файл

@ -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,

Просмотреть файл

@ -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<nsITimerInternal> 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

Просмотреть файл

@ -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);

Просмотреть файл

@ -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) ;

Просмотреть файл

@ -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)

Просмотреть файл

@ -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();

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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; }

Просмотреть файл

@ -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)

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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<nsITimerInternal> 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<nsITimerInternal> 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 {

Просмотреть файл

@ -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);
}
}

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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"

Просмотреть файл

@ -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()

Просмотреть файл

@ -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

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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 <tor@cs.brown.edu>
*/
#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<gfxIImageFrame> 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<nsITimer> mTimer;
PRPackedBool mResumeNeeded; // display_resume call needed?
PRPackedBool mFrozen; // animation frozen?
PRPackedBool mErrorPending; // decode error to report?
};
#endif

Просмотреть файл

@ -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<imgIContainerObserver> 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<gfxIImageFrame> 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

Просмотреть файл

@ -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();

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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();

Просмотреть файл

@ -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);

Просмотреть файл

@ -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)

Просмотреть файл

@ -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);

Просмотреть файл

@ -37,7 +37,7 @@
#ifndef nsViewManager_h___
#define nsViewManager_h___
#include "nsCOMPtr.h"
#include "nsIViewManager.h"
#include "nsCRT.h"
#include "nsIPresContext.h"

Просмотреть файл

@ -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++)

Просмотреть файл

@ -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);
}
}

Просмотреть файл

@ -57,7 +57,6 @@
#include "nsIInternetConfigService.h"
#include "nsITimer.h"
#include "nsITimerCallback.h"
#include <Gestalt.h>
#include <Sound.h>
@ -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

Просмотреть файл

@ -54,8 +54,6 @@ class nsIToolkit;
#include "gtkmozbox.h"
#include "nsITimer.h"
#include "nsITimerCallback.h"
#define NSRECT_TO_GDKRECT(ns,gdk) \
PR_BEGIN_MACRO \

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -56,7 +56,6 @@
#include "nsIInternetConfigService.h"
#include "nsITimer.h"
#include "nsITimerCallback.h"
#include "nsCRT.h"
#include <Gestalt.h>
@ -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

Просмотреть файл

@ -44,10 +44,10 @@
#include <string.h>
#include <stdio.h>
#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");
}

Просмотреть файл

@ -971,7 +971,14 @@
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIScriptableTimer.idl</PATH>
<PATH>nsITimer.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsITimerInternal.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
@ -1465,7 +1472,12 @@
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIScriptableTimer.idl</PATH>
<PATH>nsITimer.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsITimerInternal.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
@ -2638,7 +2650,14 @@
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIScriptableTimer.idl</PATH>
<PATH>nsITimer.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsITimerInternal.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
@ -3132,7 +3151,12 @@
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIScriptableTimer.idl</PATH>
<PATH>nsITimer.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsITimerInternal.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
@ -3728,7 +3752,13 @@
<FILEREF>
<TARGETNAME>headers</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIScriptableTimer.idl</PATH>
<PATH>nsITimer.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>headers</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsITimerInternal.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>

Просмотреть файл

@ -1,5 +1,4 @@
nsAutoLock.h
plevent.h
nsProcess.h
nsITimer.h
nsITimerCallback.h

Просмотреть файл

@ -1,7 +0,0 @@
nsIRunnable.idl
nsIThread.idl
nsIThreadPool.idl
nsITimerManager.idl
nsIEventQueue.idl
nsIEventQueueService.idl
nsIScriptableTimer.idl

Просмотреть файл

@ -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))

Просмотреть файл

Просмотреть файл

178
xpcom/threads/nsITimer.idl Normal file
Просмотреть файл

@ -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"
%}

Просмотреть файл

Просмотреть файл

@ -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;
};

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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<nsIThread> mCallingThread;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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
}

Просмотреть файл

@ -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
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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
}

Просмотреть файл

@ -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.