Comment 120 for bug 604635

Revision history for this message
In , Justin-lebar+bug (justin-lebar+bug) wrote :

Comment on attachment 596637
Part 2, Implement wakelock interfaces

One crucial thing which is missing here, leaving aside the IPC discussion above, is how we automatically cancel wake locks.

I think all wake locks a document acquires should be void when the document is unloaded (as in, onunload). Some wake locks should probably be canceled earlier than that -- for example, the screen wake lock should probably be canceled if the document which requested the lock becomes invisible (e.g., I switch away from that tab). We can deal with these special cases later, but we should deal with the general case here.

A lot of this code is going to change with the changes to part 1, so I'm not doing a full review here. But skimming this patch, one thing to note is that we don't follow the C convention of declaring all our variables at the start of a block. Instead, we declare immediately before use.

For example, this

+ PRUint32 lock;
+ bool isHeld;
+
+ isHeld = mLockHashtable.Get(aTopic, &lock);

becomes

+ PRUint32 lock;
+ bool isHeld = mLockHashtable.Get(aTopic, &lock);