Comment 70 for bug 434476

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

Comment on attachment 693331
v2

You got the wake lock API totally right except for one key point: Wake locks
are not trusted. Any content can ask for a wake lock on anything.

As currently designed, the fact that the "DOM_Fullscreen" wake lock is held
tells you absolutely nothing; any webpage could hold that wake lock by doing
navigator.requestWakeLock("DOM_Fullscreen").

I see that this mistake is all over the place. :( I'll try to get a handle on
the bustage and file bugs.

>+NS_IMPL_ISUPPORTS1(WakeLockListener, nsIDOMMozWakeLockListener)
>+nsCOMPtr<nsIPowerManagerService> sPowerManagerService = nullptr;
>+nsCOMPtr<nsIDOMMozWakeLockListener> sWakeLockListener = nullptr;

A much more minor point: static nsCOMPtr/nsRefPtr/nsAutoPtr is an anti-pattern.
It creates a static constructor, which slows startup.

You can use |static StaticRefPtr|, but it's probably better to use members on nsAppShell.

But more specifically, I don't think you need either of these refs. The power
manager service will keep a strong ref to the wake lock listener, so you can
just register the listener and be done with it.