Bug 598966 - Idle service should invoke components registered in a idle-daily category. r=roc a=joe

This commit is contained in:
Marco Bonardo 2010-10-08 12:20:50 +02:00
parent a691409558
commit f65bc1dc4f
2 changed files with 14 additions and 0 deletions

View File

@ -91,6 +91,13 @@ nsIdleServiceDaily::Observe(nsISupports *,
(void)observerService->NotifyObservers(nsnull,
OBSERVER_TOPIC_IDLE_DAILY,
nsnull);
// Notify the category observers.
const nsCOMArray<nsIObserver> &entries = mCategoryObservers.GetEntries();
for (PRInt32 i = 0; i < entries.Count(); ++i) {
(void)entries[i]->Observe(nsnull, OBSERVER_TOPIC_IDLE_DAILY, nsnull);
}
// Stop observing idle for today.
if (NS_SUCCEEDED(mIdleService->RemoveIdleObserver(this, MAX_IDLE_POLL_INTERVAL))) {
mObservesIdle = false;
@ -114,6 +121,7 @@ nsIdleServiceDaily::nsIdleServiceDaily(nsIdleService* aIdleService)
: mIdleService(aIdleService)
, mObservesIdle(false)
, mTimer(do_CreateInstance(NS_TIMER_CONTRACTID))
, mCategoryObservers(OBSERVER_TOPIC_IDLE_DAILY)
{
// Check time of the last idle-daily notification. If it was more than 24
// hours ago listen for idle, otherwise set a timer for 24 hours from now.

View File

@ -48,6 +48,7 @@
#include "nsTArray.h"
#include "nsIObserver.h"
#include "nsIIdleService.h"
#include "nsCategoryCache.h"
/**
* Class we can use to store an observer with its associated idle time
@ -106,6 +107,11 @@ private:
* Function that is called back once a day.
*/
static void DailyCallback(nsITimer* aTimer, void* aClosure);
/**
* Cache of observers for the "idle-daily" category.
*/
nsCategoryCache<nsIObserver> mCategoryObservers;
};
class nsIdleService : public nsIIdleService