Backed out changeset 86cd5f375c7d (Bug 762620)
authorGian-Carlo Pascutto <gpascutto@mozilla.com>
Wed, 13 Jun 2012 09:40:06 +0200
changeset 96558 3dbdfe9b75650d408dd444588a4c5a1c0f01da43
parent 96557 86cd5f375c7dddc89852b6da6f6d5f63bef7b553
child 96559 2ddb6278d1de06de58d9d182e2e0a701cc75747a
push id10596
push usergpascutto@mozilla.com
push dateWed, 13 Jun 2012 07:40:26 +0000
treeherdermozilla-inbound@3dbdfe9b7565 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs762620
milestone16.0a1
backs out86cd5f375c7dddc89852b6da6f6d5f63bef7b553
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 86cd5f375c7d (Bug 762620)
widget/xpwidgets/nsIdleService.cpp
--- a/widget/xpwidgets/nsIdleService.cpp
+++ b/widget/xpwidgets/nsIdleService.cpp
@@ -12,20 +12,16 @@
 #include "nsDebug.h"
 #include "nsCOMArray.h"
 #include "prinrval.h"
 #include "prlog.h"
 #include "mozilla/Services.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 
-#ifdef ANDROID
-#include <android/log.h>
-#endif
-
 using namespace mozilla;
 
 // observer topics used:
 #define OBSERVER_TOPIC_IDLE "idle"
 #define OBSERVER_TOPIC_BACK "back"
 #define OBSERVER_TOPIC_IDLE_DAILY "idle-daily"
 // interval in milliseconds between internal idle time requests.
 #define MIN_IDLE_POLL_INTERVAL_MSEC (5 * PR_MSEC_PER_SEC) /* 5 sec */
@@ -73,20 +69,16 @@ nsIdleServiceDaily::Observe(nsISupports 
     mShutdownInProgress = true;
   }
 
   if (mShutdownInProgress || strcmp(aTopic, OBSERVER_TOPIC_BACK) == 0) {
     return NS_OK;
   }
   MOZ_ASSERT(strcmp(aTopic, OBSERVER_TOPIC_IDLE) == 0);
 
-#ifdef ANDROID
-  __android_log_print(ANDROID_LOG_INFO, "IdleService", "Notifying idle-daily observers");
-#endif
-
   // Notify anyone who cares.
   nsCOMPtr<nsIObserverService> observerService =
     mozilla::services::GetObserverService();
   NS_ENSURE_STATE(observerService);
   (void)observerService->NotifyObservers(nsnull,
                                          OBSERVER_TOPIC_IDLE_DAILY,
                                          nsnull);
 
@@ -99,21 +91,16 @@ nsIdleServiceDaily::Observe(nsISupports 
   // Stop observing idle for today.
   (void)mIdleService->RemoveIdleObserver(this,
                                          DAILY_SIGNIFICANT_IDLE_SERVICE_SEC);
 
   // Set the last idle-daily time pref.
   PRInt32 nowSec = static_cast<PRInt32>(PR_Now() / PR_USEC_PER_SEC);
   Preferences::SetInt(PREF_LAST_DAILY, nowSec);
 
-#ifdef ANDROID
-  __android_log_print(ANDROID_LOG_INFO, "IdleService", "Storing last idle time as %d",
-                      nowSec);
-#endif
-
   // Start timer for the next check in one day.
   (void)mTimer->InitWithFuncCallback(DailyCallback,
                                      this,
                                      SECONDS_PER_DAY * PR_MSEC_PER_SEC,
                                      nsITimer::TYPE_ONE_SHOT);
 
   return NS_OK;
 }
@@ -135,26 +122,20 @@ nsIdleServiceDaily::Init()
   PRInt32 lastDaily = Preferences::GetInt(PREF_LAST_DAILY, 0);
   if (lastDaily < 0 || lastDaily > nowSec) {
     // The time is bogus, use default.
     lastDaily = 0;
   }
 
   // Check if it has been a day since the last notification.
   if (nowSec - lastDaily > SECONDS_PER_DAY) {
-#ifdef ANDROID
-    __android_log_print(ANDROID_LOG_INFO, "IdleService", "DailyCallback started");
-#endif
     // Wait for the user to become idle, so we can do todays idle tasks.
     DailyCallback(nsnull, this);
   }
   else {
-#ifdef ANDROID
-    __android_log_print(ANDROID_LOG_INFO, "IdleService", "Setting timer a day from now");
-#endif
     // Start timer for the next check in one day.
     (void)mTimer->InitWithFuncCallback(DailyCallback,
                                        this,
                                        SECONDS_PER_DAY * PR_MSEC_PER_SEC,
                                        nsITimer::TYPE_ONE_SHOT);
   }
 
   // Register for when we should terminate/pause
@@ -281,20 +262,16 @@ nsIdleService::~nsIdleService()
 }
 
 NS_IMETHODIMP
 nsIdleService::AddIdleObserver(nsIObserver* aObserver, PRUint32 aIdleTimeInS)
 {
   PR_LOG(sLog, PR_LOG_DEBUG,
          ("idleService: Register idle observer %x for %d seconds",
           aObserver, aIdleTimeInS));
-#ifdef ANDROID
-  __android_log_print(ANDROID_LOG_INFO, "IdleService", "Register idle observer %x for %d seconds",
-                      aObserver, aIdleTimeInS);
-#endif
 
   NS_ENSURE_ARG_POINTER(aObserver);
   // We don't accept idle time at 0, and we can't handle idle time that are too
   // high either - no more than ~136 years.
   NS_ENSURE_ARG_RANGE(aIdleTimeInS, 1, (PR_UINT32_MAX / 10) - 1);
 
   // Put the time + observer in a struct we can keep:
   IdleListener listener(aObserver, aIdleTimeInS);
@@ -313,22 +290,16 @@ nsIdleService::AddIdleObserver(nsIObserv
   // Check if the newly added observer has a smaller wait time than what we
   // are waiting for now.
   if (mDeltaToNextIdleSwitchInS > aIdleTimeInS) {
     // If it is, then this is the next to move to idle (at this point we
     // don't care if it should have switched already).
     PR_LOG(sLog, PR_LOG_DEBUG,
           ("idleService: Register: adjusting next switch from %d to %d seconds",
            mDeltaToNextIdleSwitchInS, aIdleTimeInS));
-#ifdef ANDROID
-    __android_log_print(ANDROID_LOG_INFO, "IdleService",
-                        "Register: adjusting next switch from %d to %d seconds",
-                        mDeltaToNextIdleSwitchInS, aIdleTimeInS);
-#endif
-
     mDeltaToNextIdleSwitchInS = aIdleTimeInS;
   }
 
   // Ensure timer is running.
   ReconfigureTimer();
 
   return NS_OK;
 }
@@ -344,33 +315,23 @@ nsIdleService::RemoveIdleObserver(nsIObs
   // Find the entry and remove it, if it was the last entry, we just let the
   // existing timer run to completion (there might be a new registration in a
   // little while.
   IdleListenerComparator c;
   if (mArrayListeners.RemoveElement(listener, c)) {
     PR_LOG(sLog, PR_LOG_DEBUG,
            ("idleService: Remove idle observer %x (%d seconds)",
             aObserver, aTimeInS));
-#ifdef ANDROID
-    __android_log_print(ANDROID_LOG_INFO, "IdleService",
-                        "Remove idle observer %x (%d seconds)",
-                        aObserver, aTimeInS);
-#endif
     return NS_OK;
   }
 
   // If we get here, we haven't removed anything:
   PR_LOG(sLog, PR_LOG_WARNING, 
          ("idleService: Failed to remove idle observer %x (%d seconds)",
           aObserver, aTimeInS));
-#ifdef ANDROID
-  __android_log_print(ANDROID_LOG_INFO, "IdleService",
-                      "Failed to remove idle observer %x (%d seconds)",
-                      aObserver, aTimeInS);
-#endif
   return NS_ERROR_FAILURE;
 }
 
 void
 nsIdleService::ResetIdleTimeOut(PRUint32 idleDeltaInMS)
 {
   PR_LOG(sLog, PR_LOG_DEBUG,
          ("idleService: Reset idle timeout (last interaction %u msec)",
@@ -429,21 +390,16 @@ nsIdleService::ResetIdleTimeOut(PRUint32
 
   timeStr.AppendInt((PRInt32)(idleDeltaInMS / PR_MSEC_PER_SEC));
 
   // Send the "non-idle" events.
   while (numberOfPendingNotifications--) {
     PR_LOG(sLog, PR_LOG_DEBUG,
            ("idleService: Reset idle timeout: tell observer %x user is back",
             notifyList[numberOfPendingNotifications]));
-#ifdef ANDROID
-    __android_log_print(ANDROID_LOG_INFO, "IdleService",
-                        "Reset idle timeout: tell observer %x user is back",
-                        notifyList[numberOfPendingNotifications]);
-#endif
     notifyList[numberOfPendingNotifications]->Observe(this,
                                                       OBSERVER_TOPIC_BACK,
                                                       timeStr.get());
   }
 
 }
 
 NS_IMETHODIMP
@@ -465,21 +421,16 @@ nsIdleService::GetIdleTime(PRUint32* idl
   
   // timeSinceReset is in milliseconds.
   PRUint32 timeSinceResetInMS = (PR_Now() - mLastUserInteractionInPR) /
                                 PR_USEC_PER_MSEC;
 
   PR_LOG(sLog, PR_LOG_DEBUG,
          ("idleService: Get idle time: time since reset %u msec",
           timeSinceResetInMS));
-#ifdef ANDROID
-  __android_log_print(ANDROID_LOG_INFO, "IdleService",
-                      "Get idle time: time since reset %u msec",
-                      timeSinceResetInMS);
-#endif
 
   // If we did't get pulled data, return the time since last idle reset.
   if (!polledIdleTimeIsValid) {
     // We need to convert to ms before returning the time.
     *idleTime = timeSinceResetInMS;
     return NS_OK;
   }
 
@@ -517,31 +468,22 @@ nsIdleService::IdleTimerCallback(void)
   mCurrentlySetToTimeoutAtInPR = 0;
 
   // Get the current idle time.
   PRUint32 currentIdleTimeInMS;
 
   if (NS_FAILED(GetIdleTime(&currentIdleTimeInMS))) {
     PR_LOG(sLog, PR_LOG_ALWAYS,
            ("idleService: Idle timer callback: failed to get idle time"));
-#ifdef ANDROID
-    __android_log_print(ANDROID_LOG_INFO, "IdleService",
-                        "Idle timer callback: failed to get idle time");
-#endif
     return;
   }
 
   PR_LOG(sLog, PR_LOG_DEBUG,
          ("idleService: Idle timer callback: current idle time %u msec",
           currentIdleTimeInMS));
-#ifdef ANDROID
-  __android_log_print(ANDROID_LOG_INFO, "IdleService",
-                      "Idle timer callback: current idle time %u msec",
-                      currentIdleTimeInMS);
-#endif
 
   // Check if we have had some user interaction we didn't handle previously
   // we do the calculation in ms to lessen the chance for rounding errors to
   // trigger wrong results, it is also very important that we call PR_Now AFTER
   // the call to GetIdleTime().
   if (((PR_Now() - mLastUserInteractionInPR) / PR_USEC_PER_MSEC) >
       currentIdleTimeInMS)
   {
@@ -611,38 +553,28 @@ nsIdleService::IdleTimerCallback(void)
   nsAutoString timeStr;
   timeStr.AppendInt(currentIdleTimeInS);
 
   // Notify all listeners that just timed out.
   while (numberOfPendingNotifications--) {
     PR_LOG(sLog, PR_LOG_DEBUG,
            ("idleService: Idle timer callback: tell observer %x user is idle",
             notifyList[numberOfPendingNotifications]));
-#ifdef ANDROID
-  __android_log_print(ANDROID_LOG_INFO, "IdleService",
-                      "Idle timer callback: tell observer %x user is idle",
-                      notifyList[numberOfPendingNotifications]);
-#endif
     notifyList[numberOfPendingNotifications]->Observe(this,
                                                       OBSERVER_TOPIC_IDLE,
                                                       timeStr.get());
   }
 }
 
 void
 nsIdleService::SetTimerExpiryIfBefore(PRTime aNextTimeoutInPR)
 {
   PR_LOG(sLog, PR_LOG_DEBUG,
          ("idleService: SetTimerExpiryIfBefore: next timeout %lld usec",
           aNextTimeoutInPR));
-#ifdef ANDROID
-  __android_log_print(ANDROID_LOG_INFO, "IdleService",
-                      "SetTimerExpiryIfBefore: next timeout %lld usec",
-                      aNextTimeoutInPR);
-#endif
 
   // Bail if we don't have a timer service.
   if (!mTimer) {
     return;
   }
 
   // If the new timeout is before the old one or we don't have a timer running,
   // then restart the timer.
@@ -665,21 +597,16 @@ nsIdleService::SetTimerExpiryIfBefore(PR
     }
 
     // Add 10 ms to ensure we don't undershoot, and never get a "0" timer.
     mCurrentlySetToTimeoutAtInPR += 10 * PR_USEC_PER_MSEC;
 
     PR_LOG(sLog, PR_LOG_DEBUG,
            ("idleService: reset timer expiry from %lld usec to %lld usec",
             oldTimeout, mCurrentlySetToTimeoutAtInPR));
-#ifdef ANDROID
-  __android_log_print(ANDROID_LOG_INFO, "IdleService",
-                      "reset timer expiry from %lld usec to %lld usec",
-                      oldTimeout, mCurrentlySetToTimeoutAtInPR);
-#endif
 
     // Start the timer
     mTimer->InitWithFuncCallback(StaticIdleTimerCallback,
                                  this,
                                  (mCurrentlySetToTimeoutAtInPR -
                                   currentTimeInPR) / PR_USEC_PER_MSEC,
                                  nsITimer::TYPE_ONE_SHOT);
 
@@ -691,20 +618,16 @@ void
 nsIdleService::ReconfigureTimer(void)
 {
   // Check if either someone is idle, or someone will become idle.
   if (!mAnyObserverIdle && PR_UINT32_MAX == mDeltaToNextIdleSwitchInS) {
     // If not, just let any existing timers run to completion
     // And bail out.
     PR_LOG(sLog, PR_LOG_DEBUG,
            ("idleService: ReconfigureTimer: no idle or waiting observers"));
-#ifdef ANDROID
-  __android_log_print(ANDROID_LOG_INFO, "IdleService",
-                      "ReconfigureTimer: no idle or waiting observers");
-#endif
     return;
   }
 
   // Find the next timeout value, assuming we are not polling.
 
   // We need to store the current time, so we don't get artifacts from the time
   // ticking while we are processing.
   PRTime curTimeInPR = PR_Now();
@@ -712,35 +635,24 @@ nsIdleService::ReconfigureTimer(void)
   PRTime nextTimeoutAtInPR = mLastUserInteractionInPR +
                              (((PRTime)mDeltaToNextIdleSwitchInS) *
                               PR_USEC_PER_SEC);
 
   PR_LOG(sLog, PR_LOG_DEBUG,
          ("idleService: next timeout %lld usec (%u msec from now)",
           nextTimeoutAtInPR,
           (PRUint32)((nextTimeoutAtInPR - curTimeInPR) / PR_USEC_PER_MSEC)));
-#ifdef ANDROID
-  __android_log_print(ANDROID_LOG_INFO, "IdleService",
-                      "next timeout %lld usec (%lld msec from now)",
-                      nextTimeoutAtInPR,
-                      ((nextTimeoutAtInPR - curTimeInPR) / PR_USEC_PER_MSEC));
-#endif
   // Check if we should correct the timeout time because we should poll before.
   if (mAnyObserverIdle && UsePollMode()) {
     PRTime pollTimeout = curTimeInPR +
                          MIN_IDLE_POLL_INTERVAL_MSEC * PR_USEC_PER_MSEC;
 
     if (nextTimeoutAtInPR > pollTimeout) {
       PR_LOG(sLog, PR_LOG_DEBUG,
            ("idleService: idle observers, reducing timeout to %u msec from now",
             MIN_IDLE_POLL_INTERVAL_MSEC));
-#ifdef ANDROID
-      __android_log_print(ANDROID_LOG_INFO, "IdleService",
-                          "idle observers, reducing timeout to %u msec from now",
-                          MIN_IDLE_POLL_INTERVAL_MSEC);
-#endif
       nextTimeoutAtInPR = pollTimeout;
     }
   }
 
   SetTimerExpiryIfBefore(nextTimeoutAtInPR);
 }