mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-23 02:47:07 +00:00
Bug 598966 - Idle service should invoke components registered in a idle-daily category. r=roc a=joe
This commit is contained in:
parent
a691409558
commit
f65bc1dc4f
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user