bug 115473 r=pavlov sr=brendan

Remove timer priorities
This commit is contained in:
cbiesinger%web.de 2002-06-11 20:47:04 +00:00
Родитель 5840ea523a
Коммит 6197948cc3
42 изменённых файлов: 69 добавлений и 348 удалений

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

@ -379,7 +379,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, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kScrollPosCheckWait, PR_TRUE, NS_TYPE_REPEATING_SLACK);
}
mScrollPositionChangedTicks = 1;
mLastScrolledPresShell = weakShell;

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

@ -1702,6 +1702,6 @@ void oeICalImpl::SetupAlarmManager() {
if( NS_FAILED( rv ) )
m_alarmtimer = nsnull;
else
m_alarmtimer->Init( AlarmTimerCallback, this, timediff*1000, NS_PRIORITY_NORMAL, NS_TYPE_ONE_SHOT );
m_alarmtimer->Init( AlarmTimerCallback, this, timediff*1000, PR_TRUE, NS_TYPE_ONE_SHOT );
}
}

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

@ -787,7 +787,7 @@ public:
if (NS_FAILED(result)) {
NS_WARNING("unable to start the timer");
} else {
mTimer->Init(this, aUseDelay?mDelay:0, NS_PRIORITY_NORMAL, NS_TYPE_ONE_SHOT);
mTimer->Init(this, aUseDelay?mDelay:0, PR_TRUE, NS_TYPE_ONE_SHOT);
}
return result;
}

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

@ -978,7 +978,7 @@ nsEventStateManager :: CreateClickHoldTimer ( nsIPresContext* inPresContext, nsG
mClickHoldTimer = do_CreateInstance("@mozilla.org/timer;1");
if ( mClickHoldTimer )
mClickHoldTimer->Init(sClickHoldCallback, this, kClickHoldDelay, NS_PRIORITY_HIGH);
mClickHoldTimer->Init(sClickHoldCallback, this, kClickHoldDelay, PR_TRUE);
mEventPoint = inMouseDownEvent->point;
mEventRefPoint = inMouseDownEvent->refPoint;

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

@ -4339,7 +4339,7 @@ GlobalWindowImpl::SetTimeoutOrInterval(PRBool aIsInterval, PRInt32 *aReturn)
}
err = timeout->timer->Init(TimerCallback, timeout, (PRInt32)interval,
NS_PRIORITY_LOWEST);
PR_FALSE);
if (NS_OK != err) {
DropTimeout(timeout);
return err;
@ -4577,7 +4577,7 @@ GlobalWindowImpl::RunTimeout(nsTimeoutImpl *aTimeout)
if (timeout->timer) {
rv = timeout->timer->Init(TimerCallback, timeout, delay32,
NS_PRIORITY_LOWEST);
PR_TRUE);
// Likewise, don't return early even if we fail to
// initialize the new OS timer.

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

@ -1627,7 +1627,7 @@ nsJSContext::FireGCTimer()
static PRBool first = PR_TRUE;
sGCTimer->Init(this, first ? NS_FIRST_GC_DELAY : NS_GC_DELAY,
NS_PRIORITY_LOWEST);
PR_TRUE);
first = PR_FALSE;
}

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

@ -1202,7 +1202,7 @@ ChromeTooltipListener::MouseMove(nsIDOMEvent* aMouseEvent)
if ( eventTarget )
mPossibleTooltipNode = do_QueryInterface(eventTarget);
if ( mPossibleTooltipNode ) {
nsresult rv = mTooltipTimer->Init(sTooltipCallback, this, kTooltipShowTime, NS_PRIORITY_HIGH);
nsresult rv = mTooltipTimer->Init(sTooltipCallback, this, kTooltipShowTime, PR_TRUE);
if (NS_FAILED(rv))
mPossibleTooltipNode = nsnull;
}
@ -1334,7 +1334,7 @@ ChromeTooltipListener :: CreateAutoHideTimer ( )
mAutoHideTimer = do_CreateInstance("@mozilla.org/timer;1");
if ( mAutoHideTimer )
mAutoHideTimer->Init(sAutoHideCallback, this, kTooltipAutoHideTime, NS_PRIORITY_HIGH);
mAutoHideTimer->Init(sAutoHideCallback, this, kTooltipAutoHideTime, PR_TRUE);
} // CreateAutoHideTimer

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

@ -59,7 +59,7 @@ inSearchLoop::~inSearchLoop()
nsresult
inSearchLoop::Start()
{
mTimer->Init(inSearchLoop::TimerCallback, (void*)this, 0, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
mTimer->Init(inSearchLoop::TimerCallback, (void*)this, 0, PR_TRUE, NS_TYPE_REPEATING_SLACK);
return NS_OK;
}

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

@ -379,7 +379,7 @@ nsresult nsAutoConfig::downloadAutoConfig()
mTimer = do_CreateInstance("@mozilla.org/timer;1",&rv);
if (NS_FAILED(rv))
return rv;
rv = mTimer->Init(this, minutes * 60 * 1000, NS_PRIORITY_NORMAL,
rv = mTimer->Init(this, minutes * 60 * 1000, PR_TRUE,
NS_TYPE_REPEATING_SLACK);
if (NS_FAILED(rv))
return rv;

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

@ -467,7 +467,7 @@ nsresult nsCaret::PrimeTimer()
if (NS_FAILED(err))
return err;
mBlinkTimer->Init(CaretBlinkCallback, this, mBlinkRate, NS_PRIORITY_HIGH, NS_TYPE_REPEATING_PRECISE);
mBlinkTimer->Init(CaretBlinkCallback, this, mBlinkRate, PR_TRUE, NS_TYPE_REPEATING_PRECISE);
}
return NS_OK;

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

@ -787,7 +787,7 @@ public:
if (NS_FAILED(result)) {
NS_WARNING("unable to start the timer");
} else {
mTimer->Init(this, aUseDelay?mDelay:0, NS_PRIORITY_NORMAL, NS_TYPE_ONE_SHOT);
mTimer->Init(this, aUseDelay?mDelay:0, PR_TRUE, NS_TYPE_ONE_SHOT);
}
return result;
}

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

@ -2914,7 +2914,7 @@ 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, NS_PRIORITY_HIGHEST);
mPaintSuppressionTimer->Init(sPaintSuppressionCallback, this, delay, PR_FALSE);
}
}
@ -3051,7 +3051,7 @@ PresShell::CreateResizeEventTimer ()
mResizeEventTimer = do_CreateInstance("@mozilla.org/timer;1");
if (mResizeEventTimer) {
mResizeEventTimer->Init(sResizeEventCallback, this, RESIZE_EVENT_DELAY, NS_PRIORITY_HIGH);
mResizeEventTimer->Init(sResizeEventCallback, this, RESIZE_EVENT_DELAY, PR_TRUE);
}
}

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

@ -467,7 +467,7 @@ nsresult nsCaret::PrimeTimer()
if (NS_FAILED(err))
return err;
mBlinkTimer->Init(CaretBlinkCallback, this, mBlinkRate, NS_PRIORITY_HIGH, NS_TYPE_REPEATING_PRECISE);
mBlinkTimer->Init(CaretBlinkCallback, this, mBlinkRate, PR_TRUE, NS_TYPE_REPEATING_PRECISE);
}
return NS_OK;

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

@ -3791,7 +3791,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, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
rv = mPluginTimer->Init(this, 1020 / 60, PR_TRUE, NS_TYPE_REPEATING_SLACK);
#endif
}
}

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

@ -275,7 +275,7 @@ void nsBlinkTimer::Start()
nsresult rv;
mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
if (NS_OK == rv) {
mTimer->Init(this, 750, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_PRECISE);
mTimer->Init(this, 750, PR_TRUE, NS_TYPE_REPEATING_PRECISE);
}
}

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

@ -3791,7 +3791,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, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
rv = mPluginTimer->Init(this, 1020 / 60, PR_TRUE, NS_TYPE_REPEATING_SLACK);
#endif
}
}

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

@ -2914,7 +2914,7 @@ 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, NS_PRIORITY_HIGHEST);
mPaintSuppressionTimer->Init(sPaintSuppressionCallback, this, delay, PR_FALSE);
}
}
@ -3051,7 +3051,7 @@ PresShell::CreateResizeEventTimer ()
mResizeEventTimer = do_CreateInstance("@mozilla.org/timer;1");
if (mResizeEventTimer) {
mResizeEventTimer->Init(sResizeEventCallback, this, RESIZE_EVENT_DELAY, NS_PRIORITY_HIGH);
mResizeEventTimer->Init(sResizeEventCallback, this, RESIZE_EVENT_DELAY, PR_TRUE);
}
}

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

@ -275,7 +275,7 @@ void nsBlinkTimer::Start()
nsresult rv;
mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
if (NS_OK == rv) {
mTimer->Init(this, 750, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_PRECISE);
mTimer->Init(this, 750, PR_TRUE, NS_TYPE_REPEATING_PRECISE);
}
}

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

@ -535,7 +535,7 @@ 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, NS_PRIORITY_HIGHEST);
mOpenTimer->Init(this, menuDelay, PR_FALSE);
}
}

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

@ -1496,7 +1496,7 @@ NS_IMETHODIMP nsMenuPopupFrame::SetCurrentMenuItem(nsIMenuFrame* aMenuItem)
// Kick off the timer.
mCloseTimer = do_CreateInstance("@mozilla.org/timer;1");
mCloseTimer->Init(this, menuDelay, NS_PRIORITY_HIGHEST);
mCloseTimer->Init(this, menuDelay, PR_FALSE);
mTimerMenu = mCurrentMenu;
}
}

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

@ -195,7 +195,7 @@ nsXULTooltipListener::MouseMove(nsIDOMEvent* aMouseEvent)
mTargetNode = targetContent;
}
if (mTargetNode) {
nsresult rv = mTooltipTimer->Init(sTooltipCallback, this, kTooltipShowTime, NS_PRIORITY_HIGH);
nsresult rv = mTooltipTimer->Init(sTooltipCallback, this, kTooltipShowTime, PR_TRUE);
if (NS_FAILED(rv))
mTargetNode = nsnull;
}
@ -650,7 +650,7 @@ nsXULTooltipListener::CreateAutoHideTimer()
mAutoHideTimer = do_CreateInstance("@mozilla.org/timer;1");
if ( mAutoHideTimer )
mAutoHideTimer->Init(sAutoHideCallback, this, kTooltipAutoHideTime, NS_PRIORITY_HIGH);
mAutoHideTimer->Init(sAutoHideCallback, this, kTooltipAutoHideTime, PR_TRUE);
}
void

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

@ -3508,7 +3508,7 @@ nsTreeBodyFrame::OnDragOver(nsIDOMEvent* aEvent)
if (!isOpen) {
// this node isn't expanded - set a timer to expand it
mOpenTimer = do_CreateInstance("@mozilla.org/timer;1");
mOpenTimer->Init(this, 1000, NS_PRIORITY_HIGHEST);
mOpenTimer->Init(this, 1000, PR_FALSE);
}
}
}

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

@ -317,7 +317,7 @@ NS_IMETHODIMP nsTreeSelection::TimedSelect(PRInt32 aIndex, PRInt32 aMsec)
mSelectTimer->Cancel();
mSelectTimer = do_CreateInstance("@mozilla.org/timer;1");
mSelectTimer->Init(SelectCallback, this, aMsec, NS_PRIORITY_HIGH);
mSelectTimer->Init(SelectCallback, this, aMsec, PR_TRUE);
}
}

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

@ -527,7 +527,7 @@ nsresult nsMsgSearchSession::StartTimer()
PRBool done;
m_backgroundTimer = do_CreateInstance("@mozilla.org/timer;1", &err);
m_backgroundTimer->Init(TimerCallback, (void *) this, 0, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
m_backgroundTimer->Init(TimerCallback, (void *) this, 0, PR_TRUE, NS_TYPE_REPEATING_SLACK);
// ### start meteors?
return TimeSlice(&done);
}

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

@ -1161,7 +1161,7 @@ nsMessengerWinIntegration::SetupUnreadCountUpdateTimer()
}
mUnreadCountUpdateTimer = do_CreateInstance("@mozilla.org/timer;1");
mUnreadCountUpdateTimer->Init(OnUnreadCountUpdateTimer, (void*)this, timeInMSUint32, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
mUnreadCountUpdateTimer->Init(OnUnreadCountUpdateTimer, (void*)this, timeInMSUint32, PR_TRUE, NS_TYPE_REPEATING_SLACK);
return NS_OK;
}

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

@ -302,7 +302,7 @@ nsresult nsNntpIncomingServer::SetupNewsrcSaveTimer()
mNewsrcSaveTimer->Cancel();
}
mNewsrcSaveTimer = do_CreateInstance("@mozilla.org/timer;1");
mNewsrcSaveTimer->Init(OnNewsrcSaveTimer, (void*)this, timeInMSUint32, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
mNewsrcSaveTimer->Init(OnNewsrcSaveTimer, (void*)this, timeInMSUint32, PR_TRUE, NS_TYPE_REPEATING_SLACK);
return NS_OK;
}

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

@ -199,7 +199,7 @@ NS_IMETHODIMP imgContainer::AppendFrame(gfxIImageFrame *item)
// 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, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
timeout, PR_TRUE, NS_TYPE_REPEATING_SLACK);
}
}
}
@ -322,7 +322,7 @@ NS_IMETHODIMP imgContainer::StartAnimation()
if (!mTimer) mTimer = do_CreateInstance("@mozilla.org/timer;1");
mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this),
timeout, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
timeout, PR_TRUE, NS_TYPE_REPEATING_SLACK);
}
} else {
// XXX hack.. the timer notify code will do the right thing, so just get that started
@ -330,7 +330,7 @@ NS_IMETHODIMP imgContainer::StartAnimation()
if (!mTimer) mTimer = do_CreateInstance("@mozilla.org/timer;1");
mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this),
100, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
100, PR_TRUE, NS_TYPE_REPEATING_SLACK);
}
}

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

@ -319,7 +319,7 @@ nsFtpProtocolHandler::InsertConnection(nsIURI *aKey, nsISupports *aConn)
rv = timer->Init(nsFtpProtocolHandler::Timeout,
ts,
mIdleTimeout*1000,
NS_PRIORITY_LOW);
PR_TRUE);
if (NS_FAILED(rv)) {
delete ts;
return rv;

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

@ -270,7 +270,7 @@ nsHttpHandler::Init()
// may not be cleaned up as aggressively.
if (mTimer)
mTimer->Init(DeadConnectionCleanupCB, this, 15*1000, // 15 seconds
NS_PRIORITY_NORMAL,
PR_TRUE,
NS_TYPE_REPEATING_SLACK);
return NS_OK;

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

@ -364,7 +364,7 @@ nsThrobber::LoadThrobberImages(const nsString& aFileNameMask, PRInt32 aNumImages
if (NS_OK != rv) {
return rv;
}
mTimer->Init(ThrobTimerCallback, this, 33, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
mTimer->Init(ThrobTimerCallback, this, 33, PR_TRUE, NS_TYPE_REPEATING_SLACK);
char * mask = ToNewCString(aFileNameMask);
for (PRInt32 cnt = 0; cnt < mNumImages; cnt++)

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

@ -601,7 +601,7 @@ nsSystemSoundRequest::PlaySound()
const PRInt32 kSoundTimerInterval = 250; // 250 milliseconds
rv = mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kSoundTimerInterval,
NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_PRECISE);
PR_TRUE, NS_TYPE_REPEATING_PRECISE);
if (NS_FAILED(rv)) {
Cleanup();
return rv;
@ -805,7 +805,7 @@ nsMovieSoundRequest::PlaySound()
const PRInt32 kMovieTimerInterval = 250; // 250 milliseconds
rv = mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kMovieTimerInterval,
NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_PRECISE);
PR_TRUE, NS_TYPE_REPEATING_PRECISE);
if (NS_FAILED(rv)) {
Cleanup();
return rv;

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

@ -599,7 +599,7 @@ nsSystemSoundRequest::PlaySound()
const PRInt32 kSoundTimerInterval = 250; // 250 milliseconds
rv = mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kSoundTimerInterval,
NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_PRECISE);
PR_TRUE, NS_TYPE_REPEATING_PRECISE);
if (NS_FAILED(rv)) {
Cleanup();
return rv;
@ -855,7 +855,7 @@ nsMovieSoundRequest::PlaySound()
const PRInt32 kMovieTimerInterval = 250; // 250 milliseconds
rv = mTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kMovieTimerInterval,
NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_PRECISE);
PR_TRUE, NS_TYPE_REPEATING_PRECISE);
if (NS_FAILED(rv)) {
Cleanup();
return rv;

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

@ -236,7 +236,7 @@ nsRecyclingAllocator::Malloc(PRUint32 bytes, PRBool zeroit)
if (mNAllocations && !mRecycleTimer)
{
(void) NS_NewTimer(&mRecycleTimer, nsRecycleTimerCallback, this,
NS_SEC_TO_MS(mRecycleAfter), NS_PRIORITY_LOWEST,
NS_SEC_TO_MS(mRecycleAfter), PR_TRUE,
NS_TYPE_REPEATING_SLACK);
}
return ptr;

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

@ -1,101 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* 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):
* Samir Gehani <sgehani@netscape.com>
*
* 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.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIObserver.idl"
/* -----
* NOTE:
* -----
*
* This interface is a temporary measure till nsITimer is converted
* to IDL. The hope is that nsITimer will be converted by mozilla1.0.
* See: <http://bugzilla.mozilla.org/show_bug.cgi?id=120201#c18>
*/
[scriptable,uuid(84271f22-c023-4b01-8050-d71c0c6a6235)]
interface nsIScriptableTimer : nsISupports
{
/* Timer priorities */
const short PRIORITY_HIGHEST = 10;
const short PRIORITY_HIGH = 8;
const short PRIORITY_NORMAL = 5;
const short PRIORITY_LOW = 2;
const short PRIORITY_LOWEST = 0;
/* Timer types */
const short TYPE_ONE_SHOT = 0;
const short TYPE_REPEATING_SLACK = 1;
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, => nsIScriptableTimer
* string aTopic, => ``timer-callback''
* wstring data => null
*
* @param aDelay delay in milliseconds for timer to fire
* @param aPriority timer priority per PRIORITY* consts defined above
* @param aType timer type per TYPE* consts defined above
*/
void init(in nsIObserver aObserver, in unsigned long aDelay,
in unsigned long aPriority, in unsigned long aType);
/**
* Cancellation of timers applies to repeating timers
* (i.e., init()ed with aType=TYPE_REPEATING*).
*/
void cancel();
};
%{C++
#ifndef NS_TIMER_CONTRACTID
#define NS_TIMER_CONTRACTID "@mozilla.org/timer;1"
#endif
#define NS_TIMER_CALLBACK_TOPIC "timer-callback"
%}

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

@ -1,172 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
* Michael Lowe <michael.lowe@bigfoot.com>
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsITimer_h___
#define nsITimer_h___
#include "nscore.h"
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsIComponentManager.h"
class nsITimer;
class nsITimerCallback;
/**
* Implementations of nsITimer should be written such that there are no
* limitations on what can be called by the TimerCallbackFunc. On platforms
* such as the Macintosh this means that callback functions must be called
* from the main event loop, NOT from an interrupt.
*/
// See nsITimerScriptable.idl for access to timer functionality from scripts.
// Signature of timer callback function
typedef void
(*nsTimerCallbackFunc) (nsITimer *aTimer, void *aClosure);
// Interface IID for nsITimer
#define NS_ITIMER_IID \
{ 0x497eed20, 0xb740, 0x11d1, \
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
// --- Timer priorities ---
// These are going away, so just use NORMAL for now. See bug 115473
#define NS_PRIORITY_HIGHEST 10
#define NS_PRIORITY_HIGH 8
#define NS_PRIORITY_NORMAL 5
#define NS_PRIORITY_LOW 2
#define NS_PRIORITY_LOWEST 0
// --- Timer types ---
enum nsTimerType {
/**
* Type of a timer that fires once only.
*/
NS_TYPE_ONE_SHOT = 0,
/**
* After firing, a NS_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.
*/
NS_TYPE_REPEATING_SLACK = 1,
/**
* An NS_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.
*/
NS_TYPE_REPEATING_PRECISE = 2
};
#define REPEATING_TIMERS 1
/**
* Timer class, used to invoke a function or method after a fixed
* millisecond interval.
*/
class nsITimer : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITIMER_IID)
/**
* 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 aPriority - The timer priority
* @param aType - The timer type : one shot or repeating
* @result - NS_OK if this operation was successful
*/
NS_IMETHOD Init(nsTimerCallbackFunc aFunc,
void *aClosure,
PRUint32 aDelay,
PRUint32 aPriority = NS_PRIORITY_NORMAL,
PRUint32 aType = NS_TYPE_ONE_SHOT) = 0;
/**
* Initialize a timer to fire after the given millisecond interval.
* This version takes an interface of type <code>nsITimerCallback</code>.
* The <code>Notify</code> method of this method is invoked.
*
* @param aCallback - The interface to notify
* @param aDelay - The millisecond interval
* @param aPriority - The timer priority
* @param aType - The timer type : one shot or repeating
* @result - NS_OK if this operation was successful
*/
NS_IMETHOD Init(nsITimerCallback *aCallback,
PRUint32 aDelay,
PRUint32 aPriority = NS_PRIORITY_NORMAL,
PRUint32 aType = NS_TYPE_ONE_SHOT) = 0;
/// Cancels the timeout
NS_IMETHOD Cancel() = 0;
/// @return the millisecond delay of the timeout
NS_IMETHOD_(PRUint32) GetDelay() = 0;
/// Change the millisecond interval for the timeout
NS_IMETHOD_(void) SetDelay(PRUint32 aDelay) = 0;
NS_IMETHOD_(PRUint32) GetPriority() = 0;
NS_IMETHOD_(void) SetPriority(PRUint32 aPriority) = 0;
NS_IMETHOD_(PRUint32) GetType() = 0;
NS_IMETHOD_(void) SetType(PRUint32 aType) = 0;
/// @return the opaque pointer
NS_IMETHOD_(void*) GetClosure() = 0;
};
extern NS_COM nsresult
NS_NewTimer(nsITimer* *aResult, nsTimerCallbackFunc aCallback, void *aClosure,
PRUint32 aDelay, PRUint32 aPriority, PRUint32 aType);
#endif // nsITimer_h___

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

@ -209,7 +209,7 @@ void nsTimerImpl::Shutdown()
NS_IMETHODIMP nsTimerImpl::Init(nsTimerCallbackFunc aFunc,
void *aClosure,
PRUint32 aDelay,
PRUint32 aPriority,
PRBool aIdle,
PRUint32 aType)
{
if (!gThread)
@ -220,7 +220,7 @@ NS_IMETHODIMP nsTimerImpl::Init(nsTimerCallbackFunc aFunc,
mClosure = aClosure;
mPriority = (PRUint8)aPriority;
mIdle = aIdle;
mType = (PRUint8)aType;
SetDelayInternal(aDelay);
@ -230,7 +230,7 @@ NS_IMETHODIMP nsTimerImpl::Init(nsTimerCallbackFunc aFunc,
NS_IMETHODIMP nsTimerImpl::Init(nsITimerCallback *aCallback,
PRUint32 aDelay,
PRUint32 aPriority,
PRBool aIdle,
PRUint32 aType)
{
if (!gThread)
@ -240,7 +240,7 @@ NS_IMETHODIMP nsTimerImpl::Init(nsITimerCallback *aCallback,
NS_ADDREF(mCallback.i);
mCallbackType = CALLBACK_TYPE_INTERFACE;
mPriority = (PRUint8)aPriority;
mIdle = aIdle;
mType = (PRUint8)aType;
SetDelayInternal(aDelay);
@ -250,7 +250,7 @@ NS_IMETHODIMP nsTimerImpl::Init(nsITimerCallback *aCallback,
NS_IMETHODIMP nsTimerImpl::Init(nsIObserver *aObserver,
PRUint32 aDelay,
PRUint32 aPriority,
PRBool aIdle,
PRUint32 aType)
{
if (!gThread)
@ -262,7 +262,7 @@ NS_IMETHODIMP nsTimerImpl::Init(nsIObserver *aObserver,
NS_ADDREF(mCallback.o);
mCallbackType = CALLBACK_TYPE_OBSERVER;
mPriority = (PRUint8)aPriority;
mIdle = aIdle;
mType = (PRUint8)aType;
return gThread->AddTimer(this);
@ -291,11 +291,6 @@ NS_IMETHODIMP_(void) nsTimerImpl::SetDelay(PRUint32 aDelay)
gThread->TimerDelayChanged(this);
}
NS_IMETHODIMP_(void) nsTimerImpl::SetPriority(PRUint32 aPriority)
{
mPriority = (PRUint8)aPriority;
}
NS_IMETHODIMP_(void) nsTimerImpl::SetType(PRUint32 aType)
{
mType = (PRUint8)aType;
@ -393,7 +388,7 @@ void* handleTimerEvent(TimerEventType* event)
#endif
if (gFireOnIdle) {
if (NS_STATIC_CAST(nsTimerImpl*, event->e.owner)->GetPriority() < NS_PRIORITY_HIGHEST) {
if (NS_STATIC_CAST(nsTimerImpl*, event->e.owner)->IsIdle()) {
nsCOMPtr<nsIThread> currentThread, mainThread;
nsIThread::GetCurrent(getter_AddRefs(currentThread));
nsIThread::GetMainThread(getter_AddRefs(mainThread));
@ -487,14 +482,14 @@ void nsTimerImpl::SetDelayInternal(PRUint32 aDelay)
nsresult
NS_NewTimer(nsITimer* *aResult, nsTimerCallbackFunc aCallback, void *aClosure,
PRUint32 aDelay, PRUint32 aPriority, PRUint32 aType)
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, aPriority, aType);
nsresult rv = timer->Init(aCallback, aClosure, aDelay, aIdle, aType);
if (NS_FAILED(rv)) {
NS_RELEASE(timer);
return rv;

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

@ -100,27 +100,26 @@ public:
NS_IMETHOD Init(nsTimerCallbackFunc aFunc,
void *aClosure,
PRUint32 aDelay,
PRUint32 aPriority,
PRBool aIdle,
PRUint32 aType);
NS_IMETHOD Init(nsITimerCallback *aCallback,
PRUint32 aDelay,
PRUint32 aPriority,
PRBool aIdle,
PRUint32 aType);
NS_DECL_ISUPPORTS
NS_DECL_NSISCRIPTABLETIMER
NS_IMETHOD_(PRUint32) GetDelay() { return mDelay; }
NS_IMETHOD_(PRBool) IsIdle() const { return mIdle; }
NS_IMETHOD_(PRUint32) GetDelay() const { return mDelay; }
NS_IMETHOD_(void) SetDelay(PRUint32 aDelay);
NS_IMETHOD_(PRUint32) GetPriority() { return mPriority; }
NS_IMETHOD_(void) SetPriority(PRUint32 aPriority);
NS_IMETHOD_(PRUint32) GetType() { return (PRUint32)mType; }
NS_IMETHOD_(PRUint32) GetType() const { return (PRUint32)mType; }
NS_IMETHOD_(void) SetType(PRUint32 aType);
NS_IMETHOD_(void*) GetClosure() { return mClosure; }
NS_IMETHOD_(void*) GetClosure() const { return mClosure; }
private:
nsCOMPtr<nsIThread> mCallingThread;
@ -135,7 +134,7 @@ private:
// These members are set by Init (called from NS_NewTimer) and never reset.
PRUint8 mCallbackType;
PRUint8 mPriority;
PRPackedBool mIdle;
// These members are set by the initiating thread, when the timer's type is
// changed and during the period where it fires on that thread.

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

@ -1817,7 +1817,7 @@ 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, NS_PRIORITY_LOWEST, NS_TYPE_REPEATING_SLACK);
mTimer->Init(nsBookmarksService::FireTimer, this, BOOKMARK_TIMEOUT, PR_TRUE, NS_TYPE_REPEATING_SLACK);
// Note: don't addref "this" as we'll cancel the timer in the nsBookmarkService destructor
}
@ -2137,7 +2137,7 @@ 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, NS_PRIORITY_LOWEST, NS_TYPE_REPEATING_SLACK);
bmks->mTimer->Init(nsBookmarksService::FireTimer, bmks, BOOKMARK_TIMEOUT, PR_TRUE, NS_TYPE_REPEATING_SLACK);
// Note: don't addref "this" as we'll cancel the timer in the nsBookmarkService destructor
#endif
}

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

@ -928,7 +928,7 @@ nsHTTPIndex::GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBo
if (NS_SUCCEEDED(rv))
{
mTimer->Init(nsHTTPIndex::FireTimer, this, 1,
NS_PRIORITY_LOWEST, NS_TYPE_ONE_SHOT);
PR_TRUE, NS_TYPE_ONE_SHOT);
// Note: don't addref "this" as we'll cancel the
// timer in the httpIndex destructor
}
@ -964,7 +964,7 @@ nsHTTPIndex::AddElement(nsIRDFResource *parent, nsIRDFResource *prop, nsIRDFNode
if (NS_FAILED(rv)) return(rv);
mTimer->Init(nsHTTPIndex::FireTimer, this, 1,
NS_PRIORITY_LOWEST, NS_TYPE_ONE_SHOT);
PR_TRUE, NS_TYPE_ONE_SHOT);
// Note: don't addref "this" as we'll cancel the
// timer in the httpIndex destructor
}
@ -1105,7 +1105,7 @@ nsHTTPIndex::FireTimer(nsITimer* aTimer, void* aClosure)
if (httpIndex->mTimer)
{
httpIndex->mTimer->Init(nsHTTPIndex::FireTimer, aClosure, 10,
NS_PRIORITY_LOWEST, NS_TYPE_ONE_SHOT);
PR_TRUE, NS_TYPE_ONE_SHOT);
// Note: don't addref "this" as we'll cancel the
// timer in the httpIndex destructor
}

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

@ -1728,7 +1728,7 @@ nsGlobalHistory::SetDirty()
mDirty = PR_TRUE;
mSyncTimer->Init(fireSyncTimer, this, HISTORY_SYNC_TIMEOUT,
NS_PRIORITY_LOWEST, NS_TYPE_ONE_SHOT);
PR_TRUE, NS_TYPE_ONE_SHOT);
return NS_OK;
@ -1747,7 +1747,7 @@ nsGlobalHistory::GetNow()
if (mExpireNowTimer)
mExpireNowTimer->Init(expireNowTimer, this, HISTORY_EXPIRE_NOW_TIMEOUT,
NS_PRIORITY_LOWEST, NS_TYPE_ONE_SHOT);
PR_TRUE, NS_TYPE_ONE_SHOT);
}
return mLastNow;

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

@ -721,7 +721,7 @@ 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, NS_PRIORITY_LOWEST, NS_TYPE_REPEATING_SLACK);
SEARCH_UPDATE_TIMEOUT, PR_TRUE, NS_TYPE_REPEATING_SLACK);
// Note: don't addref "this" as we'll cancel the timer in the InternetSearchDataSource destructor
#endif
}
@ -924,7 +924,7 @@ InternetSearchDataSource::Init()
if (mTimer)
{
mTimer->Init(InternetSearchDataSource::FireTimer, this,
SEARCH_UPDATE_TIMEOUT, NS_PRIORITY_LOWEST, NS_TYPE_REPEATING_SLACK);
SEARCH_UPDATE_TIMEOUT, PR_TRUE, NS_TYPE_REPEATING_SLACK);
// Note: don't addref "this" as we'll cancel the timer in the
// InternetSearchDataSource destructor
}

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

@ -80,7 +80,7 @@ var nsUpdateNotifier =
const kIScriptableTimer = Components.interfaces.nsIScriptableTimer;
mTimer = Components.classes["@mozilla.org/timer;1"].
createInstance(kIScriptableTimer);
mTimer.init(this, kUpdateCheckDelay, kIScriptableTimer.PRIORITY_NORMAL,
mTimer.init(this, kUpdateCheckDelay, true,
kIScriptableTimer.TYPE_ONE_SHOT);
// we are no longer interested in the ``domwindowopened'' topic