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.
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.
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 requestWakeLock ("DOM_Fullscree n").
tells you absolutely nothing; any webpage could hold that wake lock by doing
navigator.
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( WakeLockListene r, nsIDOMMozWakeLo ckListener) nsIPowerManager Service> sPowerManagerSe rvice = nullptr; nsIDOMMozWakeLo ckListener> sWakeLockListener = nullptr;
>+nsCOMPtr<
>+nsCOMPtr<
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.