Index: trunk/src/libs/xpcom18a4/Config.kmk
===================================================================
--- trunk/src/libs/xpcom18a4/Config.kmk	(revision 101824)
+++ trunk/src/libs/xpcom18a4/Config.kmk	(revision 101825)
@@ -442,8 +442,5 @@
 	xpcom/threads/nsIRunnable.idl \
 	xpcom/threads/nsIThread.idl \
-	xpcom/threads/nsITimer.idl \
 	xpcom/threads/nsIEnvironment.idl \
-	xpcom/threads/nsITimerInternal.idl \
-	xpcom/threads/nsITimerManager.idl \
 	xpcom/threads/nsIProcess.idl \
 	xpcom/reflect/xptinfo/public/nsIInterfaceInfo.idl \
Index: trunk/src/libs/xpcom18a4/Makefile.kmk
===================================================================
--- trunk/src/libs/xpcom18a4/Makefile.kmk	(revision 101824)
+++ trunk/src/libs/xpcom18a4/Makefile.kmk	(revision 101825)
@@ -695,7 +695,5 @@
 	xpcom/threads/nsEventQueueService.cpp \
 	xpcom/threads/nsThread.cpp \
-	xpcom/threads/nsTimerImpl.cpp \
-	xpcom/threads/nsProcessCommon.cpp \
-	xpcom/threads/TimerThread.cpp
+	xpcom/threads/nsProcessCommon.cpp
 $(evalcall VBOX_XPCOM_X86,VBox-xpcom-threads)
 
@@ -1207,7 +1205,4 @@
 		nsICategoryManager.xpt \
 		nsIThread.xpt \
-		nsITimer.xpt \
-		nsITimerInternal.xpt \
-		nsITimerManager.xpt \
 		nsIRunnable.xpt \
 		nsIEventTarget.xpt \
Index: trunk/src/libs/xpcom18a4/xpcom/build/nsXPComInit.cpp
===================================================================
--- trunk/src/libs/xpcom18a4/xpcom/build/nsXPComInit.cpp	(revision 101824)
+++ trunk/src/libs/xpcom18a4/xpcom/build/nsXPComInit.cpp	(revision 101825)
@@ -80,7 +80,4 @@
 #include "nsIInterfaceInfoManager.h"
 
-#include "nsTimerImpl.h"
-#include "TimerThread.h"
-
 #include "nsThread.h"
 #include "nsProcess.h"
@@ -183,6 +180,4 @@
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAtomService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsExceptionService)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimerImpl)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimerManager)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinaryOutputStream)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinaryInputStream)
@@ -366,7 +361,4 @@
 #define NS_XPCOMPROXY_CID NS_PROXYEVENT_MANAGER_CID
     COMPONENT(XPCOMPROXY, nsProxyObjectManager::Create),
-
-    COMPONENT(TIMER, nsTimerImplConstructor),
-    COMPONENT(TIMERMANAGER, nsTimerManagerConstructor),
 
 #define COMPONENT_SUPPORTS(TYPE, Type)                                         \
@@ -516,8 +508,4 @@
     if (NS_FAILED(rv)) return rv;
 
-    // Set up the timer globals/timer thread
-    rv = nsTimerImpl::Startup();
-    NS_ENSURE_SUCCESS(rv, rv);
-
     // Startup the memory manager
     rv = nsMemoryImpl::Startup();
@@ -896,8 +884,4 @@
     NS_ShutdownNativeCharsetUtils();
 #endif
-
-    // Shutdown the timer thread and all timers that might still be alive before
-    // shutting down the component manager
-    nsTimerImpl::Shutdown();
 
     CallExitRoutines();
Index: trunk/src/libs/xpcom18a4/xpcom/threads/TimerThread.cpp
===================================================================
--- trunk/src/libs/xpcom18a4/xpcom/threads/TimerThread.cpp	(revision 101824)
+++ 	(revision )
@@ -1,462 +1,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * ***** 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) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Stuart Parmenter <pavlov@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of 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 "nsTimerImpl.h"
-#include "TimerThread.h"
-
-#include "nsAutoLock.h"
-#include "pratom.h"
-
-#include "nsIObserverService.h"
-#include "nsIServiceManager.h"
-
-NS_IMPL_THREADSAFE_ISUPPORTS3(TimerThread, nsIRunnable, nsISupportsWeakReference, nsIObserver)
-
-TimerThread::TimerThread() :
-  mInitInProgress(0),
-  mInitialized(PR_FALSE),
-  mLock(nsnull),
-  mCondVar(nsnull),
-  mShutdown(PR_FALSE),
-  mWaiting(PR_FALSE),
-  mSleeping(PR_FALSE),
-  mDelayLineCounter(0),
-  mMinTimerPeriod(0),
-  mTimeoutAdjustment(0)
-{
-}
-
-TimerThread::~TimerThread()
-{
-  if (mCondVar)
-    PR_DestroyCondVar(mCondVar);
-  if (mLock)
-    PR_DestroyLock(mLock);
-
-  mThread = nsnull;
-
-  PRInt32 n = mTimers.Count();
-  while (--n >= 0) {
-    nsTimerImpl *timer = NS_STATIC_CAST(nsTimerImpl *, mTimers[n]);
-    NS_RELEASE(timer);
-  }
-
-  nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
-  if (observerService) {
-    observerService->RemoveObserver(this, "sleep_notification");
-    observerService->RemoveObserver(this, "wake_notification");
-  }
-
-}
-
-nsresult
-TimerThread::InitLocks()
-{
-  NS_ASSERTION(!mLock, "InitLocks called twice?");
-  mLock = PR_NewLock();
-  if (!mLock)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  mCondVar = PR_NewCondVar(mLock);
-  if (!mCondVar)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  return NS_OK;
-}
-
-nsresult TimerThread::Init()
-{
-  if (mInitialized) {
-    if (!mThread)
-      return NS_ERROR_FAILURE;
-
-    return NS_OK;
-  }
-
-  if (PR_AtomicSet(&mInitInProgress, 1) == 0) {
-    nsresult rv;
-
-    mEventQueueService = do_GetService("@mozilla.org/event-queue-service;1", &rv);
-    if (NS_SUCCEEDED(rv)) {
-      nsCOMPtr<nsIObserverService> observerService
-        (do_GetService("@mozilla.org/observer-service;1", &rv));
-
-      if (NS_SUCCEEDED(rv)) {
-        // We hold on to mThread to keep the thread alive.
-        rv = NS_NewThread(getter_AddRefs(mThread),
-                          NS_STATIC_CAST(nsIRunnable*, this),
-                          0,
-                          PR_JOINABLE_THREAD,
-                          PR_PRIORITY_NORMAL,
-                          PR_GLOBAL_THREAD);
-
-        if (NS_FAILED(rv)) {
-          mThread = nsnull;
-        }
-        else {
-          observerService->AddObserver(this, "sleep_notification", PR_TRUE);
-          observerService->AddObserver(this, "wake_notification", PR_TRUE);
-        }
-      }
-    }
-
-    PR_Lock(mLock);
-    mInitialized = PR_TRUE;
-    PR_NotifyAllCondVar(mCondVar);
-    PR_Unlock(mLock);
-  }
-  else {
-    PR_Lock(mLock);
-    while (!mInitialized) {
-      PR_WaitCondVar(mCondVar, PR_INTERVAL_NO_TIMEOUT);
-    }
-    PR_Unlock(mLock);
-  }
-
-  if (!mThread)
-    return NS_ERROR_FAILURE;
-
-  return NS_OK;
-}
-
-nsresult TimerThread::Shutdown()
-{
-  if (!mThread)
-    return NS_ERROR_NOT_INITIALIZED;
-
-  {   // lock scope
-    nsAutoLock lock(mLock);
-
-    mShutdown = PR_TRUE;
-
-    // notify the cond var so that Run() can return
-    if (mCondVar && mWaiting)
-      PR_NotifyCondVar(mCondVar);
-
-    nsTimerImpl *timer;
-    for (PRInt32 i = mTimers.Count() - 1; i >= 0; i--) {
-      timer = NS_STATIC_CAST(nsTimerImpl*, mTimers[i]);
-      RemoveTimerInternal(timer);
-    }
-  }
-
-  mThread->Join();    // wait for the thread to die
-  return NS_OK;
-}
-
-// Keep track of how early (positive slack) or late (negative slack) timers
-// are running, and use the filtered slack number to adaptively estimate how
-// early timers should fire to be "on time".
-void TimerThread::UpdateFilter(PRUint32 aDelay, PRIntervalTime aTimeout,
-                               PRIntervalTime aNow)
-{
-  PRInt32 slack = (PRInt32) (aTimeout - aNow);
-  double smoothSlack = 0;
-  PRUint32 i, filterLength;
-  static PRIntervalTime kFilterFeedbackMaxTicks =
-    PR_MillisecondsToInterval(FILTER_FEEDBACK_MAX);
-
-  if (slack > 0) {
-    if (slack > (PRInt32)kFilterFeedbackMaxTicks)
-      slack = kFilterFeedbackMaxTicks;
-  } else {
-    if (slack < -(PRInt32)kFilterFeedbackMaxTicks)
-      slack = -(PRInt32)kFilterFeedbackMaxTicks;
-  }
-  mDelayLine[mDelayLineCounter & DELAY_LINE_LENGTH_MASK] = slack;
-  if (++mDelayLineCounter < DELAY_LINE_LENGTH) {
-    // Startup mode: accumulate a full delay line before filtering.
-    PR_ASSERT(mTimeoutAdjustment == 0);
-    filterLength = 0;
-  } else {
-    // Past startup: compute number of filter taps based on mMinTimerPeriod.
-    if (mMinTimerPeriod == 0) {
-      mMinTimerPeriod = (aDelay != 0) ? aDelay : 1;
-    } else if (aDelay != 0 && aDelay < mMinTimerPeriod) {
-      mMinTimerPeriod = aDelay;
-    }
-
-    filterLength = (PRUint32) (FILTER_DURATION / mMinTimerPeriod);
-    if (filterLength > DELAY_LINE_LENGTH)
-      filterLength = DELAY_LINE_LENGTH;
-    else if (filterLength < 4)
-      filterLength = 4;
-
-    for (i = 1; i <= filterLength; i++)
-      smoothSlack += mDelayLine[(mDelayLineCounter-i) & DELAY_LINE_LENGTH_MASK];
-    smoothSlack /= filterLength;
-
-    // XXXbe do we need amplification?  hacking a fudge factor, need testing...
-    mTimeoutAdjustment = (PRInt32) (smoothSlack * 1.5);
-  }
-
-#ifdef DEBUG_TIMERS
-  if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
-    PR_LOG(gTimerLog, PR_LOG_DEBUG,
-           ("UpdateFilter: smoothSlack = %g, filterLength = %u\n",
-            smoothSlack, filterLength));
-  }
-#endif
-}
-
-/* void Run(); */
-NS_IMETHODIMP TimerThread::Run()
-{
-  nsAutoLock lock(mLock);
-
-  while (!mShutdown) {
-    PRIntervalTime waitFor;
-
-    if (mSleeping) {
-      // Sleep for 0.1 seconds while not firing timers.
-      waitFor = PR_MillisecondsToInterval(100);
-    } else {
-      waitFor = PR_INTERVAL_NO_TIMEOUT;
-      PRIntervalTime now = PR_IntervalNow();
-      nsTimerImpl *timer = nsnull;
-
-      if (mTimers.Count() > 0) {
-        timer = NS_STATIC_CAST(nsTimerImpl*, mTimers[0]);
-
-        if (!TIMER_LESS_THAN(now, timer->mTimeout + mTimeoutAdjustment)) {
-    next:
-          // NB: AddRef before the Release under RemoveTimerInternal to avoid
-          // mRefCnt passing through zero, in case all other refs than the one
-          // from mTimers have gone away (the last non-mTimers[i]-ref's Release
-          // must be racing with us, blocked in gThread->RemoveTimer waiting
-          // for TimerThread::mLock, under nsTimerImpl::Release.
-
-          NS_ADDREF(timer);
-          RemoveTimerInternal(timer);
-
-          // We release mLock around the Fire call to avoid deadlock.
-          lock.unlock();
-
-#ifdef DEBUG_TIMERS
-          if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
-            PR_LOG(gTimerLog, PR_LOG_DEBUG,
-                   ("Timer thread woke up %dms from when it was supposed to\n",
-                    (now >= timer->mTimeout)
-                    ? PR_IntervalToMilliseconds(now - timer->mTimeout)
-                    : -(PRInt32)PR_IntervalToMilliseconds(timer->mTimeout-now))
-                  );
-          }
-#endif
-
-          // We are going to let the call to PostTimerEvent here handle the
-          // release of the timer so that we don't end up releasing the timer
-          // on the TimerThread instead of on the thread it targets.
-          timer->PostTimerEvent();
-          timer = nsnull;
-
-          lock.lock();
-          if (mShutdown)
-            break;
-
-          // Update now, as PostTimerEvent plus the locking may have taken a
-          // tick or two, and we may goto next below.
-          now = PR_IntervalNow();
-        }
-      }
-
-      if (mTimers.Count() > 0) {
-        timer = NS_STATIC_CAST(nsTimerImpl *, mTimers[0]);
-
-        PRIntervalTime timeout = timer->mTimeout + mTimeoutAdjustment;
-
-        // Don't wait at all (even for PR_INTERVAL_NO_WAIT) if the next timer
-        // is due now or overdue.
-        if (!TIMER_LESS_THAN(now, timeout))
-          goto next;
-        waitFor = timeout - now;
-      }
-
-#ifdef DEBUG_TIMERS
-      if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
-        if (waitFor == PR_INTERVAL_NO_TIMEOUT)
-          PR_LOG(gTimerLog, PR_LOG_DEBUG,
-                 ("waiting for PR_INTERVAL_NO_TIMEOUT\n"));
-        else
-          PR_LOG(gTimerLog, PR_LOG_DEBUG,
-                 ("waiting for %u\n", PR_IntervalToMilliseconds(waitFor)));
-      }
-#endif
-    }
-
-    mWaiting = PR_TRUE;
-    PR_WaitCondVar(mCondVar, waitFor);
-    mWaiting = PR_FALSE;
-  }
-
-  return NS_OK;
-}
-
-nsresult TimerThread::AddTimer(nsTimerImpl *aTimer)
-{
-  nsAutoLock lock(mLock);
-
-  // Add the timer to our list.
-  PRInt32 i = AddTimerInternal(aTimer);
-  if (i < 0)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  // Awaken the timer thread.
-  if (mCondVar && mWaiting && i == 0)
-    PR_NotifyCondVar(mCondVar);
-
-  return NS_OK;
-}
-
-nsresult TimerThread::TimerDelayChanged(nsTimerImpl *aTimer)
-{
-  nsAutoLock lock(mLock);
-
-  // Our caller has a strong ref to aTimer, so it can't go away here under
-  // ReleaseTimerInternal.
-  RemoveTimerInternal(aTimer);
-
-  PRInt32 i = AddTimerInternal(aTimer);
-  if (i < 0)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  // Awaken the timer thread.
-  if (mCondVar && mWaiting && i == 0)
-    PR_NotifyCondVar(mCondVar);
-
-  return NS_OK;
-}
-
-nsresult TimerThread::RemoveTimer(nsTimerImpl *aTimer)
-{
-  nsAutoLock lock(mLock);
-
-  // Remove the timer from our array.  Tell callers that aTimer was not found
-  // by returning NS_ERROR_NOT_AVAILABLE.  Unlike the TimerDelayChanged case
-  // immediately above, our caller may be passing a (now-)weak ref in via the
-  // aTimer param, specifically when nsTimerImpl::Release loses a race with
-  // TimerThread::Run, must wait for the mLock auto-lock here, and during the
-  // wait Run drops the only remaining ref to aTimer via RemoveTimerInternal.
-
-  if (!RemoveTimerInternal(aTimer))
-    return NS_ERROR_NOT_AVAILABLE;
-
-  // Awaken the timer thread.
-  if (mCondVar && mWaiting)
-    PR_NotifyCondVar(mCondVar);
-
-  return NS_OK;
-}
-
-// This function must be called from within a lock
-PRInt32 TimerThread::AddTimerInternal(nsTimerImpl *aTimer)
-{
-  PRIntervalTime now = PR_IntervalNow();
-  PRInt32 count = mTimers.Count();
-  PRInt32 i = 0;
-  for (; i < count; i++) {
-    nsTimerImpl *timer = NS_STATIC_CAST(nsTimerImpl *, mTimers[i]);
-
-    // Don't break till we have skipped any overdue timers.  Do not include
-    // mTimeoutAdjustment here, because we are really trying to avoid calling
-    // TIMER_LESS_THAN(t, u), where the t is now + DELAY_INTERVAL_MAX, u is
-    // now - overdue, and DELAY_INTERVAL_MAX + overdue > DELAY_INTERVAL_LIMIT.
-    // In other words, we want to use now-based time, now adjusted time, even
-    // though "overdue" ultimately depends on adjusted time.
-
-    // XXX does this hold for TYPE_REPEATING_PRECISE?  /be
-
-    if (TIMER_LESS_THAN(now, timer->mTimeout) &&
-        TIMER_LESS_THAN(aTimer->mTimeout, timer->mTimeout)) {
-      break;
-    }
-  }
-
-  if (!mTimers.InsertElementAt(aTimer, i))
-    return -1;
-
-  aTimer->mArmed = PR_TRUE;
-  NS_ADDREF(aTimer);
-  return i;
-}
-
-PRBool TimerThread::RemoveTimerInternal(nsTimerImpl *aTimer)
-{
-  if (!mTimers.RemoveElement(aTimer))
-    return PR_FALSE;
-
-  // Order is crucial here -- see nsTimerImpl::Release.
-  aTimer->mArmed = PR_FALSE;
-  NS_RELEASE(aTimer);
-  return PR_TRUE;
-}
-
-void TimerThread::DoBeforeSleep()
-{
-  mSleeping = PR_TRUE;
-}
-
-void TimerThread::DoAfterSleep()
-{
-  for (PRInt32 i = 0; i < mTimers.Count(); i ++) {
-    nsTimerImpl *timer = NS_STATIC_CAST(nsTimerImpl*, mTimers[i]);
-    // get and set the delay to cause its timeout to be recomputed
-    PRUint32 delay;
-    timer->GetDelay(&delay);
-    timer->SetDelay(delay);
-  }
-
-  // nuke the stored adjustments, so they get recalibrated
-  mTimeoutAdjustment = 0;
-  mDelayLineCounter = 0;
-  mSleeping = PR_FALSE;
-}
-
-
-/* void observe (in nsISupports aSubject, in string aTopic, in wstring aData); */
-NS_IMETHODIMP
-TimerThread::Observe(nsISupports* /* aSubject */, const char *aTopic, const PRUnichar* /* aData */)
-{
-  if (strcmp(aTopic, "sleep_notification") == 0)
-    DoBeforeSleep();
-  else if (strcmp(aTopic, "wake_notification") == 0)
-    DoAfterSleep();
-
-  return NS_OK;
-}
Index: trunk/src/libs/xpcom18a4/xpcom/threads/TimerThread.h
===================================================================
--- trunk/src/libs/xpcom18a4/xpcom/threads/TimerThread.h	(revision 101824)
+++ 	(revision )
@@ -1,122 +1,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * ***** 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) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Stuart Parmenter <pavlov@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of 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 ***** */
-
-#ifndef TimerThread_h___
-#define TimerThread_h___
-
-#include "nsWeakReference.h"
-
-#include "nsIEventQueueService.h"
-#include "nsIObserver.h"
-#include "nsIRunnable.h"
-#include "nsIThread.h"
-
-#include "nsTimerImpl.h"
-
-#include "nsVoidArray.h"
-
-#include "prcvar.h"
-#include "prinrval.h"
-#include "prlock.h"
-
-class TimerThread : public nsSupportsWeakReference,
-                    public nsIRunnable,
-                    public nsIObserver
-{
-public:
-  TimerThread();
-  NS_HIDDEN_(nsresult) InitLocks();
-
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIRUNNABLE
-  NS_DECL_NSIOBSERVER
-  
-  NS_HIDDEN_(nsresult) Init();
-  NS_HIDDEN_(nsresult) Shutdown();
-
-  nsresult AddTimer(nsTimerImpl *aTimer);
-  nsresult TimerDelayChanged(nsTimerImpl *aTimer);
-  nsresult RemoveTimer(nsTimerImpl *aTimer);
-
-#define FILTER_DURATION         1e3     /* one second */
-#define FILTER_FEEDBACK_MAX     100     /* 1/10th of a second */
-
-  void UpdateFilter(PRUint32 aDelay, PRIntervalTime aTimeout,
-                    PRIntervalTime aNow);
-
-  // For use by nsTimerImpl::Fire()
-  nsCOMPtr<nsIEventQueueService> mEventQueueService;
-
-  void DoBeforeSleep();
-  void DoAfterSleep();
-
-private:
-  ~TimerThread();
-
-  PRInt32 mInitInProgress;
-  PRBool  mInitialized;
-
-  // These two internal helper methods must be called while mLock is held.
-  // AddTimerInternal returns the position where the timer was added in the
-  // list, or -1 if it failed.
-  PRInt32 AddTimerInternal(nsTimerImpl *aTimer);
-  PRBool  RemoveTimerInternal(nsTimerImpl *aTimer);
-
-  nsCOMPtr<nsIThread> mThread;
-  PRLock *mLock;
-  PRCondVar *mCondVar;
-
-  PRPackedBool mShutdown;
-  PRPackedBool mWaiting;
-  PRPackedBool mSleeping;
-  
-  nsVoidArray mTimers;
-
-#define DELAY_LINE_LENGTH_LOG2  5
-#define DELAY_LINE_LENGTH_MASK  PR_BITMASK(DELAY_LINE_LENGTH_LOG2)
-#define DELAY_LINE_LENGTH       PR_BIT(DELAY_LINE_LENGTH_LOG2)
-
-  PRInt32  mDelayLine[DELAY_LINE_LENGTH];
-  PRUint32 mDelayLineCounter;
-  PRUint32 mMinTimerPeriod;     // milliseconds
-  PRInt32  mTimeoutAdjustment;
-};
-
-#endif /* TimerThread_h___ */
Index: trunk/src/libs/xpcom18a4/xpcom/threads/nsITimer.idl
===================================================================
--- trunk/src/libs/xpcom18a4/xpcom/threads/nsITimer.idl	(revision 101824)
+++ 	(revision )
@@ -1,191 +1,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * ***** 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):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of 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"
-
-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);
-};
-
-
-/**
- * nsITimer instances must be initialized by calling one of the "init" methods
- * documented below.  You may also re-initialize an existing instance with new
- * delay to avoid the overhead of destroying and creating a timer.  It is not
- * necessary to cancel the timer in that case.
- */
-[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);
-
-  /**
-   * Cancel the timer.  This method works on all types, not just on repeating
-   * timers -- you might want to cancel a TYPE_ONE_SHOT timer, and even reuse
-   * it by re-initializing it (to avoid object destruction and creation costs
-   * by conserving one timer instance).
-   */
-  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"
-%}
-
Index: trunk/src/libs/xpcom18a4/xpcom/threads/nsITimerInternal.idl
===================================================================
--- trunk/src/libs/xpcom18a4/xpcom/threads/nsITimerInternal.idl	(revision 101824)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * ***** 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):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of 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"
-
-
-[scriptable, uuid(6dd8f185-ceb8-4878-8e38-2d13edc2d079)]
-interface nsITimerInternal : nsISupports
-{
-  attribute boolean idle;
-};
-
Index: trunk/src/libs/xpcom18a4/xpcom/threads/nsITimerManager.idl
===================================================================
--- trunk/src/libs/xpcom18a4/xpcom/threads/nsITimerManager.idl	(revision 101824)
+++ 	(revision )
@@ -1,61 +1,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * ***** 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):
- *   Stuart Parmenter <pavlov@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of 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"
-
-[scriptable, uuid(8fce8c6a-1dd2-11b2-8352-8cdd2b965efc)]
-interface nsITimerManager : nsISupports
-{
-  /**
-   * A flag that turns on the use of idle timers on the main thread.
-   * this should only be called once.
-   *
-   * By default, idle timers are off.
-   *
-   * One this is set to TRUE, you are expected to call hasIdleTimers/fireNextIdleTimer
-   * when you have time in your main loop.
-   */
-  attribute boolean useIdleTimers;
-
-  boolean hasIdleTimers();
-
-  // Fire next idle timers waiting on the current thread
-  void fireNextIdleTimer();
-};
Index: trunk/src/libs/xpcom18a4/xpcom/threads/nsTimerImpl.cpp
===================================================================
--- trunk/src/libs/xpcom18a4/xpcom/threads/nsTimerImpl.cpp	(revision 101824)
+++ 	(revision )
@@ -1,642 +1,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * ***** 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) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Stuart Parmenter <pavlov@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of 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 "nsTimerImpl.h"
-#include "TimerThread.h"
-#include "nsAutoLock.h"
-
-#include "nsVoidArray.h"
-
-#include "nsIEventQueue.h"
-
-#include "prmem.h"
-
-static PRInt32          gGenerator = 0;
-static TimerThread*     gThread = nsnull;
-static PRBool           gFireOnIdle = PR_FALSE;
-static nsTimerManager*  gManager = nsnull;
-
-#ifdef DEBUG_TIMERS
-#include <math.h>
-
-double nsTimerImpl::sDeltaSumSquared = 0;
-double nsTimerImpl::sDeltaSum = 0;
-double nsTimerImpl::sDeltaNum = 0;
-
-static void
-myNS_MeanAndStdDev(double n, double sumOfValues, double sumOfSquaredValues,
-                   double *meanResult, double *stdDevResult)
-{
-  double mean = 0.0, var = 0.0, stdDev = 0.0;
-  if (n > 0.0 && sumOfValues >= 0) {
-    mean = sumOfValues / n;
-    double temp = (n * sumOfSquaredValues) - (sumOfValues * sumOfValues);
-    if (temp < 0.0 || n <= 1)
-      var = 0.0;
-    else
-      var = temp / (n * (n - 1));
-    // for some reason, Windows says sqrt(0.0) is "-1.#J" (?!) so do this:
-    stdDev = var != 0.0 ? sqrt(var) : 0.0;
-  }
-  *meanResult = mean;
-  *stdDevResult = stdDev;
-}
-#endif
-
-NS_IMPL_THREADSAFE_QUERY_INTERFACE2(nsTimerImpl, nsITimer, nsITimerInternal)
-NS_IMPL_THREADSAFE_ADDREF(nsTimerImpl)
-
-NS_IMETHODIMP_(nsrefcnt) nsTimerImpl::Release(void)
-{
-  nsrefcnt count;
-
-  NS_PRECONDITION(0 != mRefCnt, "dup release");
-  count = PR_AtomicDecrement((PRInt32 *)&mRefCnt);
-  NS_LOG_RELEASE(this, count, "nsTimerImpl");
-  if (count == 0) {
-    mRefCnt = 1; /* stabilize */
-
-    /* enable this to find non-threadsafe destructors: */
-    /* NS_ASSERT_OWNINGTHREAD(nsTimerImpl); */
-    NS_DELETEXPCOM(this);
-    return 0;
-  }
-
-  // If only one reference remains, and mArmed is set, then the ref must be
-  // from the TimerThread::mTimers array, so we Cancel this timer to remove
-  // the mTimers element, and return 0 if Cancel in fact disarmed the timer.
-  //
-  // We use an inlined version of nsTimerImpl::Cancel here to check for the
-  // NS_ERROR_NOT_AVAILABLE code returned by gThread->RemoveTimer when this
-  // timer is not found in the mTimers array -- i.e., when the timer was not
-  // in fact armed once we acquired TimerThread::mLock, in spite of mArmed
-  // being true here.  That can happen if the armed timer is being fired by
-  // TimerThread::Run as we race and test mArmed just before it is cleared by
-  // the timer thread.  If the RemoveTimer call below doesn't find this timer
-  // in the mTimers array, then the last ref to this timer is held manually
-  // and temporarily by the TimerThread, so we should fall through to the
-  // final return and return 1, not 0.
-  //
-  // The original version of this thread-based timer code kept weak refs from
-  // TimerThread::mTimers, removing this timer's weak ref in the destructor,
-  // but that leads to double-destructions in the race described above, and
-  // adding mArmed doesn't help, because destructors can't be deferred, once
-  // begun.  But by combining reference-counting and a specialized Release
-  // method with "is this timer still in the mTimers array once we acquire
-  // the TimerThread's lock" testing, we defer destruction until we're sure
-  // that only one thread has its hot little hands on this timer.
-  //
-  // Note that both approaches preclude a timer creator, and everyone else
-  // except the TimerThread who might have a strong ref, from dropping all
-  // their strong refs without implicitly canceling the timer.  Timers need
-  // non-mTimers-element strong refs to stay alive.
-
-  if (count == 1 && mArmed) {
-    mCanceled = PR_TRUE;
-
-    if (NS_SUCCEEDED(gThread->RemoveTimer(this)))
-      return 0;
-  }
-
-  return count;
-}
-
-nsTimerImpl::nsTimerImpl() :
-  mClosure(nsnull),
-  mCallbackType(CALLBACK_TYPE_UNKNOWN),
-  mIdle(PR_TRUE),
-  mFiring(PR_FALSE),
-  mArmed(PR_FALSE),
-  mCanceled(PR_FALSE),
-  mGeneration(0),
-  mDelay(0),
-  mTimeout(0)
-{
-  // XXXbsmedberg: shouldn't this be in Init()?
-  nsIThread::GetCurrent(getter_AddRefs(mCallingThread));
-
-  mCallback.c = nsnull;
-
-#ifdef DEBUG_TIMERS
-  mStart = 0;
-  mStart2 = 0;
-#endif
-}
-
-nsTimerImpl::~nsTimerImpl()
-{
-  ReleaseCallback();
-}
-
-//static
-nsresult
-nsTimerImpl::Startup()
-{
-  nsresult rv;
-
-  gThread = new TimerThread();
-  if (!gThread) return NS_ERROR_OUT_OF_MEMORY;
-
-  NS_ADDREF(gThread);
-  rv = gThread->InitLocks();
-
-  if (NS_FAILED(rv)) {
-    NS_RELEASE(gThread);
-  }
-
-  return rv;
-}
-
-void nsTimerImpl::Shutdown()
-{
-#ifdef DEBUG_TIMERS
-  if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
-    double mean = 0, stddev = 0;
-    myNS_MeanAndStdDev(sDeltaNum, sDeltaSum, sDeltaSumSquared, &mean, &stddev);
-
-    PR_LOG(gTimerLog, PR_LOG_DEBUG, ("sDeltaNum = %f, sDeltaSum = %f, sDeltaSumSquared = %f\n", sDeltaNum, sDeltaSum, sDeltaSumSquared));
-    PR_LOG(gTimerLog, PR_LOG_DEBUG, ("mean: %fms, stddev: %fms\n", mean, stddev));
-  }
-#endif
-
-  if (!gThread)
-    return;
-
-  gThread->Shutdown();
-  NS_RELEASE(gThread);
-
-  gFireOnIdle = PR_FALSE;
-}
-
-
-nsresult nsTimerImpl::InitCommon(PRUint32 aType, PRUint32 aDelay)
-{
-  nsresult rv;
-
-  NS_ENSURE_TRUE(gThread, NS_ERROR_NOT_INITIALIZED);
-
-  rv = gThread->Init();
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  /**
-   * In case of re-Init, both with and without a preceding Cancel, clear the
-   * mCanceled flag and assign a new mGeneration.  But first, remove any armed
-   * timer from the timer thread's list.
-   *
-   * If we are racing with the timer thread to remove this timer and we lose,
-   * the RemoveTimer call made here will fail to find this timer in the timer
-   * thread's list, and will return false harmlessly.  We test mArmed here to
-   * avoid the small overhead in RemoveTimer of locking the timer thread and
-   * checking its list for this timer.  It's safe to test mArmed even though
-   * it might be cleared on another thread in the next cycle (or even already
-   * be cleared by another CPU whose store hasn't reached our CPU's cache),
-   * because RemoveTimer is idempotent.
-   */
-  if (mArmed)
-    gThread->RemoveTimer(this);
-  mCanceled = PR_FALSE;
-  mGeneration = PR_AtomicIncrement(&gGenerator);
-
-  mType = (PRUint8)aType;
-  SetDelayInternal(aDelay);
-
-  return gThread->AddTimer(this);
-}
-
-NS_IMETHODIMP nsTimerImpl::InitWithFuncCallback(nsTimerCallbackFunc aFunc,
-                                                void *aClosure,
-                                                PRUint32 aDelay,
-                                                PRUint32 aType)
-{
-  ReleaseCallback();
-  mCallbackType = CALLBACK_TYPE_FUNC;
-  mCallback.c = aFunc;
-  mClosure = aClosure;
-
-  return InitCommon(aType, aDelay);
-}
-
-NS_IMETHODIMP nsTimerImpl::InitWithCallback(nsITimerCallback *aCallback,
-                                            PRUint32 aDelay,
-                                            PRUint32 aType)
-{
-  ReleaseCallback();
-  mCallbackType = CALLBACK_TYPE_INTERFACE;
-  mCallback.i = aCallback;
-  NS_ADDREF(mCallback.i);
-
-  return InitCommon(aType, aDelay);
-}
-
-NS_IMETHODIMP nsTimerImpl::Init(nsIObserver *aObserver,
-                                PRUint32 aDelay,
-                                PRUint32 aType)
-{
-  ReleaseCallback();
-  mCallbackType = CALLBACK_TYPE_OBSERVER;
-  mCallback.o = aObserver;
-  NS_ADDREF(mCallback.o);
-
-  return InitCommon(aType, aDelay);
-}
-
-NS_IMETHODIMP nsTimerImpl::Cancel()
-{
-  mCanceled = PR_TRUE;
-
-  if (gThread)
-    gThread->RemoveTimer(this);
-
-  return NS_OK;
-}
-
-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 == TYPE_REPEATING_PRECISE)
-    mTimeout = PR_IntervalNow();
-
-  SetDelayInternal(aDelay);
-
-  if (!mFiring && gThread)
-    gThread->TimerDelayChanged(this);
-
-  return NS_OK;
-}
-
-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()
-{
-  if (mCanceled)
-    return;
-
-  PRIntervalTime now = PR_IntervalNow();
-#ifdef DEBUG_TIMERS
-  if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
-    PRIntervalTime a = now - mStart; // actual delay in intervals
-    PRUint32       b = PR_MillisecondsToInterval(mDelay); // expected delay in intervals
-    PRUint32       d = PR_IntervalToMilliseconds((a > b) ? a - b : b - a); // delta in ms
-    sDeltaSum += d;
-    sDeltaSumSquared += double(d) * double(d);
-    sDeltaNum++;
-
-    PR_LOG(gTimerLog, PR_LOG_DEBUG, ("[this=%p] expected delay time %4dms\n", this, mDelay));
-    PR_LOG(gTimerLog, PR_LOG_DEBUG, ("[this=%p] actual delay time   %4dms\n", this, PR_IntervalToMilliseconds(a)));
-    PR_LOG(gTimerLog, PR_LOG_DEBUG, ("[this=%p] (mType is %d)       -------\n", this, mType));
-    PR_LOG(gTimerLog, PR_LOG_DEBUG, ("[this=%p]     delta           %4dms\n", this, (a > b) ? (PRInt32)d : -(PRInt32)d));
-
-    mStart = mStart2;
-    mStart2 = 0;
-  }
-#endif
-
-  PRIntervalTime timeout = mTimeout;
-  if (mType == TYPE_REPEATING_PRECISE) {
-    // Precise repeating timers advance mTimeout by mDelay without fail before
-    // calling Fire().
-    timeout -= PR_MillisecondsToInterval(mDelay);
-  }
-  gThread->UpdateFilter(mDelay, timeout, now);
-
-  mFiring = PR_TRUE;
-
-  switch (mCallbackType) {
-    case CALLBACK_TYPE_FUNC:
-      mCallback.c(this, mClosure);
-      break;
-    case CALLBACK_TYPE_INTERFACE:
-      mCallback.i->Notify(this);
-      break;
-    case CALLBACK_TYPE_OBSERVER:
-      mCallback.o->Observe(NS_STATIC_CAST(nsITimer*,this),
-                           NS_TIMER_CALLBACK_TOPIC,
-                           nsnull);
-      break;
-    default:;
-  }
-
-  mFiring = PR_FALSE;
-
-#ifdef DEBUG_TIMERS
-  if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
-    PR_LOG(gTimerLog, PR_LOG_DEBUG,
-           ("[this=%p] Took %dms to fire timer callback\n",
-            this, PR_IntervalToMilliseconds(PR_IntervalNow() - now)));
-  }
-#endif
-
-  if (mType == TYPE_REPEATING_SLACK) {
-    SetDelayInternal(mDelay); // force mTimeout to be recomputed.
-    if (gThread)
-      gThread->AddTimer(this);
-  }
-}
-
-
-struct TimerEventType : public PLEvent {
-  PRInt32        mGeneration;
-#ifdef DEBUG_TIMERS
-  PRIntervalTime mInitTime;
-#endif
-};
-
-
-void* handleTimerEvent(TimerEventType* event)
-{
-  nsTimerImpl* timer = NS_STATIC_CAST(nsTimerImpl*, event->owner);
-  if (event->mGeneration != timer->GetGeneration())
-    return nsnull;
-
-#ifdef DEBUG_TIMERS
-  if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
-    PRIntervalTime now = PR_IntervalNow();
-    PR_LOG(gTimerLog, PR_LOG_DEBUG,
-           ("[this=%p] time between PostTimerEvent() and Fire(): %dms\n",
-            event->owner, PR_IntervalToMilliseconds(now - event->mInitTime)));
-  }
-#endif
-
-  if (gFireOnIdle) {
-    PRBool idle = PR_FALSE;
-    timer->GetIdle(&idle);
-    if (idle) {
-      NS_ASSERTION(gManager, "Global Thread Manager is null!");
-      if (gManager)
-        gManager->AddIdleTimer(timer);
-      return nsnull;
-    }
-  }
-
-  timer->Fire();
-
-  return nsnull;
-}
-
-void destroyTimerEvent(TimerEventType* event)
-{
-  nsTimerImpl *timer = NS_STATIC_CAST(nsTimerImpl*, event->owner);
-  NS_RELEASE(timer);
-  PR_DELETE(event);
-}
-
-
-void nsTimerImpl::PostTimerEvent()
-{
-  // XXX we may want to reuse the PLEvent in the case of repeating timers.
-  TimerEventType* event;
-
-  // construct
-  event = PR_NEW(TimerEventType);
-  if (!event)
-    return;
-
-  // initialize
-  PL_InitEvent((PLEvent*)event, this,
-               (PLHandleEventProc)handleTimerEvent,
-               (PLDestroyEventProc)destroyTimerEvent);
-
-  // Since TimerThread addref'd 'this' for us, we don't need to addref here.
-  // We will release in destroyMyEvent.  We do need to copy the generation
-  // number from this timer into the event, so we can avoid firing a timer
-  // that was re-initialized after being canceled.
-  event->mGeneration = mGeneration;
-
-#ifdef DEBUG_TIMERS
-  if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
-    event->mInitTime = PR_IntervalNow();
-  }
-#endif
-
-  // 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 == TYPE_REPEATING_PRECISE) {
-    SetDelayInternal(mDelay);
-    if (gThread)
-      gThread->AddTimer(this);
-  }
-
-  PRThread *thread;
-  nsresult rv = mCallingThread->GetPRThread(&thread);
-  if (NS_FAILED(rv)) {
-    NS_WARNING("Dropping timer event because thread is dead");
-    return;
-  }
-
-  nsCOMPtr<nsIEventQueue> queue;
-  if (gThread)
-    gThread->mEventQueueService->GetThreadEventQueue(thread, getter_AddRefs(queue));
-  if (queue)
-    queue->PostEvent(event);
-}
-
-void nsTimerImpl::SetDelayInternal(PRUint32 aDelay)
-{
-  PRIntervalTime delayInterval = PR_MillisecondsToInterval(aDelay);
-  if (delayInterval > DELAY_INTERVAL_MAX) {
-    delayInterval = DELAY_INTERVAL_MAX;
-    aDelay = PR_IntervalToMilliseconds(delayInterval);
-  }
-
-  mDelay = aDelay;
-
-  PRIntervalTime now = PR_IntervalNow();
-  if (mTimeout == 0 || mType != TYPE_REPEATING_PRECISE)
-    mTimeout = now;
-
-  mTimeout += delayInterval;
-
-#ifdef DEBUG_TIMERS
-  if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
-    if (mStart == 0)
-      mStart = now;
-    else
-      mStart2 = now;
-  }
-#endif
-}
-
-/**
- * Timer Manager code
- */
-
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsTimerManager, nsITimerManager)
-
-nsTimerManager::nsTimerManager()
-{
-  mLock = PR_NewLock();
-  gManager = this;
-}
-
-nsTimerManager::~nsTimerManager()
-{
-  gManager = nsnull;
-  PR_DestroyLock(mLock);
-
-  nsTimerImpl *theTimer;
-  PRInt32 count = mIdleTimers.Count();
-
-  for (PRInt32 i = 0; i < count; i++) {
-    theTimer = NS_STATIC_CAST(nsTimerImpl*, mIdleTimers[i]);
-    NS_IF_RELEASE(theTimer);
-  }
-}
-
-NS_IMETHODIMP nsTimerManager::SetUseIdleTimers(PRBool aUseIdleTimers)
-{
-  if (aUseIdleTimers == PR_FALSE && gFireOnIdle == PR_TRUE)
-    return NS_ERROR_FAILURE;
-
-  gFireOnIdle = aUseIdleTimers;
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsTimerManager::GetUseIdleTimers(PRBool *aUseIdleTimers)
-{
-  *aUseIdleTimers = gFireOnIdle;
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsTimerManager::HasIdleTimers(PRBool *aHasTimers)
-{
-  nsAutoLock lock (mLock);
-  PRUint32 count = mIdleTimers.Count();
-  *aHasTimers = (count != 0);
-  return NS_OK;
-}
-
-nsresult nsTimerManager::AddIdleTimer(nsITimer* timer)
-{
-  if (!timer)
-    return NS_ERROR_FAILURE;
-  nsAutoLock lock(mLock);
-  mIdleTimers.AppendElement(timer);
-  NS_ADDREF(timer);
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsTimerManager::FireNextIdleTimer()
-{
-  if (!gFireOnIdle || !nsIThread::IsMainThread()) {
-    return NS_OK;
-  }
-
-  nsTimerImpl *theTimer = nsnull;
-
-  {
-    nsAutoLock lock (mLock);
-    PRUint32 count = mIdleTimers.Count();
-    
-    if (count == 0) 
-      return NS_OK;
-    
-    theTimer = NS_STATIC_CAST(nsTimerImpl*, mIdleTimers[0]);
-    mIdleTimers.RemoveElement(theTimer);
-  }
-
-  theTimer->Fire();
-
-  NS_RELEASE(theTimer);
-
-  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;
-}
Index: trunk/src/libs/xpcom18a4/xpcom/threads/nsTimerImpl.h
===================================================================
--- trunk/src/libs/xpcom18a4/xpcom/threads/nsTimerImpl.h	(revision 101824)
+++ 	(revision )
@@ -1,195 +1,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * ***** 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) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Stuart Parmenter <pavlov@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of 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 ***** */
-
-#ifndef nsTimerImpl_h___
-#define nsTimerImpl_h___
-
-//#define FORCE_PR_LOG /* Allow logging in the release build */
-
-#include "nsITimer.h"
-#include "nsVoidArray.h"
-#include "nsIThread.h"
-#include "nsITimerInternal.h"
-#include "nsIObserver.h"
-
-#include "nsCOMPtr.h"
-
-#include "prlog.h"
-
-#if defined(PR_LOGGING)
-static PRLogModuleInfo *gTimerLog = PR_NewLogModule("nsTimerImpl");
-#define DEBUG_TIMERS 1
-#else
-#undef DEBUG_TIMERS
-#endif
-
-#define NS_TIMER_CLASSNAME "Timer"
-#define NS_TIMER_CID \
-{ /* 5ff24248-1dd2-11b2-8427-fbab44f29bc8 */         \
-     0x5ff24248,                                     \
-     0x1dd2,                                         \
-     0x11b2,                                         \
-    {0x84, 0x27, 0xfb, 0xab, 0x44, 0xf2, 0x9b, 0xc8} \
-}
-
-enum {
-  CALLBACK_TYPE_UNKNOWN   = 0,
-  CALLBACK_TYPE_INTERFACE = 1,
-  CALLBACK_TYPE_FUNC      = 2,
-  CALLBACK_TYPE_OBSERVER  = 3
-};
-
-// Two timer deadlines must differ by less than half the PRIntervalTime domain.
-#define DELAY_INTERVAL_LIMIT    PR_BIT(8 * sizeof(PRIntervalTime) - 1)
-
-// Maximum possible delay (XXX rework to use ms rather than interval ticks).
-#define DELAY_INTERVAL_MAX      (DELAY_INTERVAL_LIMIT - 1)
-
-// 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 nsITimerInternal
-{
-public:
-
-  nsTimerImpl();
-
-  static NS_HIDDEN_(nsresult) Startup();
-  static NS_HIDDEN_(void) Shutdown();
-
-  friend class TimerThread;
-
-  void Fire();
-  void PostTimerEvent();
-  void SetDelayInternal(PRUint32 aDelay);
-
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSITIMER
-  NS_DECL_NSITIMERINTERNAL
-
-  PRInt32 GetGeneration() { return mGeneration; }
-
-private:
-  ~nsTimerImpl();
-
-  nsresult InitCommon(PRUint32 aType, PRUint32 aDelay);
-
-  void ReleaseCallback()
-  {
-    if (mCallbackType == CALLBACK_TYPE_INTERFACE)
-      NS_RELEASE(mCallback.i);
-    else if (mCallbackType == CALLBACK_TYPE_OBSERVER)
-      NS_RELEASE(mCallback.o);
-  }
-
-  nsCOMPtr<nsIThread>   mCallingThread;
-
-  void *                mClosure;
-
-  union {
-    nsTimerCallbackFunc c;
-    nsITimerCallback *  i;
-    nsIObserver *       o;
-  } mCallback;
-
-  // These members are set by Init (called from NS_NewTimer) and never reset.
-  PRUint8               mCallbackType;
-  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.
-  PRUint8               mType;
-  PRPackedBool          mFiring;
-
-
-  // Use a PRBool (int) here to isolate loads and stores of these two members
-  // done on various threads under the protection of TimerThread::mLock, from
-  // loads and stores done on the initiating/type-changing/timer-firing thread
-  // to the above PRUint8/PRPackedBool members.
-  PRBool                mArmed;
-  PRBool                mCanceled;
-
-  // The generation number of this timer, re-generated each time the timer is
-  // initialized so one-shot timers can be canceled and re-initialized by the
-  // arming thread without any bad race conditions.
-  PRInt32               mGeneration;
-
-  PRUint32              mDelay;
-  PRIntervalTime        mTimeout;
-
-#ifdef DEBUG_TIMERS
-  PRIntervalTime        mStart, mStart2;
-  static double         sDeltaSum;
-  static double         sDeltaSumSquared;
-  static double         sDeltaNum;
-#endif
-
-};
-
-#define NS_TIMERMANAGER_CONTRACTID "@mozilla.org/timer/manager;1"
-#define NS_TIMERMANAGER_CLASSNAME "Timer Manager"
-#define NS_TIMERMANAGER_CID \
-{ /* 4fe206fa-1dd2-11b2-8a0a-88bacbecc7d2 */         \
-     0x4fe206fa,                                     \
-     0x1dd2,                                         \
-     0x11b2,                                         \
-    {0x8a, 0x0a, 0x88, 0xba, 0xcb, 0xec, 0xc7, 0xd2} \
-}
-
-#include "nsITimerManager.h"
-
-class nsTimerManager : nsITimerManager
-{
-public:
-  nsTimerManager();
-
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSITIMERMANAGER
-
-  nsresult AddIdleTimer(nsITimer* timer);
-private:
-  ~nsTimerManager();
-
-  PRLock *mLock;
-  nsVoidArray mIdleTimers;
-};
-
-
-#endif /* nsTimerImpl_h___ */
