Comment 56 for bug 604635

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

>> There should be two DOM APIs, right?
> But how do we separate the two APIs?

I'd probably make them two separate interfaces. navigator.mozPower is accessible only from Gaia "chrome", and navigator.requestWakeLock() is callable from content.

>> The first API needs to have a function so that the power manager can tell
>> whether any wake locks are currently held for a given topic.
>
> A bit confusing here. When we talked about the power manager, do we mean the DOM object or the one
> will be in Gaia?

By "power manager", I mean the object in Gaia which uses navigator.mozPower.

> Who will monitor the idle time and manage the power state of each peripherals? I thought it was a
> object living in Gaia "chrome" and listening to the idle event.

Yes, that's right.

But how is PowerManager.lock() called in your example? Logically, that function needs to be called from content, right? But content cannot get a reference to the PowerManager object in Gaia. So instead, I was thinking that content calls

  navigator.requestWakeLock(aTopic)

and the PowerManager object has:

  * a way to tell whether a wake lock is held for a given topic. For example, it could be navigator.mozPower.wakeLockIsHeld(aTopic)

  * a way to be notified when all wake locks are taken or released for a topic. For example, it could be

  navigator.mozPower.addWakeLockAcquiredListener(function(aTopic) {
    alert("Wake lock on " + aTopic + " is acquired.");
    assert(navigator.mozPower.wakeLockIsHeld(aTopic));
  });

  navigator.mozPower.addWakeLockReleasedListener(function(aTopic) {
    assert(!navigator.mozPower.wakeLockIsHeld(aTopic));
  });