Closed Bug 771967 Opened 13 years ago Closed 13 years ago

OS Idle API active to brief idle to active notification bug fix

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla16

People

(Reporter: bsurender, Assigned: bsurender)

Details

Attachments

(1 file, 1 obsolete file)

Bug fix for case below: When the user is active and then becomes idle, idle observers are notified. But if the user becomes active again before some or all idle observers are notified then active notifications need not be sent to those idle observers. Changeset uploaded to try at https://tbpl.mozilla.org/?tree=Try&rev=1924f96218bc Will request a review once the try results are correct.
Attachment #640123 - Flags: review?(jst)
Clean green for the most part. Oranges and purples were re-run and are now green. https://tbpl.mozilla.org/?tree=Try&rev=1924f96218bc
Summary: WIP OS Idle API active to brief idle to active notification bug fix → OS Idle API active to brief idle to active notification bug fix
Comment on attachment 640123 [details] [diff] [review] WIP active to active bug fix. waiting for try results. +nsGlobalWindow::NotifyIdleObserver(IdleObserverHolder* aIdleObserverHolder, bool aCallOnidle) { + MOZ_ASSERT(aIdleObserverHolder); + aIdleObserverHolder->mPrevNotificationIdle = aCallOnidle ? true : false; No need to check the boolean aCallOnidle here, just assign it directly. - In nsGlobalWindow::HandleIdleObserverCallback(): + IdleObserverHolder* idleObserver = + &(mIdleObservers.ElementAt(mIdleCallbackIndex)); + NotifyIdleObserver(idleObserver, true); Make idleObserver be a reference here and drop the extra parentheses. Pass the address of idleObserver to NotifyIdleObserver(). That way you don't take the address of a return value, which just looks a bit odd (it works, but using a reference here is IMO cleaner). Alternatively you could even make NotifyIdleObserver() take a reference instead of a pointer, assuming you always have an observer holder to pass in, which you must since you assert it's never null. - In nsGlobalWindow::HandleIdleActiveEvent() + IdleObserverHolder* idleObserver = &(iter.GetNext()); Same deal, use a reference, pass the address of the reference below. - In nsGlobalWindow::RegisterIdleObserver(nsI + IdleObserverHolder* idleObserver = + &(mIdleObservers.ElementAt(insertAtIndex)); Same here, Use a reference - In nsGlobalWindow.h: IdleObserverHolder(const IdleObserverHolder& aOtherIdleObserver) - : mIdleObserver(aOtherIdleObserver.mIdleObserver), mTimeInS(aOtherIdleObserver.mTimeInS) + : mIdleObserver(aOtherIdleObserver.mIdleObserver), mTimeInS(aOtherIdleObserver.mTimeInS), + mPrevNotificationIdle(aOtherIdleObserver.mPrevNotificationIdle) Maybe rename "aOtherIdleObserver" here to simply "aOther" (fairly common practice in copy constructors)? Saves on typing, makes this easier to read... r=jst with that!
Attachment #640123 - Flags: review?(jst) → review+
Attachment #640123 - Attachment is obsolete: true
Attachment #642106 - Flags: checkin?(jst)
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Attachment #642106 - Flags: checkin?(jst)
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: