Bug 1320275 - QuotaManager must be registered as battery observer before calling hal:GetCurrentBatteryInformation, r=janv

This commit is contained in:
Andrea Marchesini 2016-11-28 22:22:51 +01:00
parent 880566d51c
commit 3eb6049ec1
2 changed files with 22 additions and 0 deletions

View File

@ -441,7 +441,11 @@ QuotaManagerService::PerformIdleMaintenance()
if (!QuotaManager::kRunningXPCShellTests)
#endif
{
// In order to give the correct battery level, hal must have registered
// battery observers.
RegisterBatteryObserver(this);
GetCurrentBatteryInformation(&batteryInfo);
UnregisterBatteryObserver(this);
}
// If we're running XPCShell because we always want to be able to test this
@ -707,6 +711,13 @@ QuotaManagerService::Observe(nsISupports* aSubject,
return NS_OK;
}
void
QuotaManagerService::Notify(const hal::BatteryInformation& aBatteryInfo)
{
// This notification is received when battery data changes. We don't need to
// deal with this notification.
}
NS_IMETHODIMP
AbortOperationsRunnable::Run()
{

View File

@ -8,6 +8,8 @@
#define mozilla_dom_quota_QuotaManagerService_h
#include "mozilla/dom/ipc/IdType.h"
#include "mozilla/dom/battery/Types.h"
#include "mozilla/Observer.h"
#include "nsAutoPtr.h"
#include "nsIObserver.h"
#include "nsIQuotaManagerService.h"
@ -22,6 +24,10 @@ class PBackgroundChild;
} // namespace ipc
namespace hal {
class BatteryInformation;
}
namespace dom {
namespace quota {
@ -31,6 +37,7 @@ class QuotaManager;
class QuotaManagerService final
: public nsIQuotaManagerService
, public nsIObserver
, public BatteryObserver
{
typedef mozilla::ipc::PBackgroundChild PBackgroundChild;
@ -104,6 +111,10 @@ private:
NS_DECL_ISUPPORTS
NS_DECL_NSIQUOTAMANAGERSERVICE
NS_DECL_NSIOBSERVER
// BatteryObserver override
void
Notify(const hal::BatteryInformation& aBatteryInfo) override;
};
} // namespace quota