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) if (!QuotaManager::kRunningXPCShellTests)
#endif #endif
{ {
// In order to give the correct battery level, hal must have registered
// battery observers.
RegisterBatteryObserver(this);
GetCurrentBatteryInformation(&batteryInfo); GetCurrentBatteryInformation(&batteryInfo);
UnregisterBatteryObserver(this);
} }
// If we're running XPCShell because we always want to be able to test 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; 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 NS_IMETHODIMP
AbortOperationsRunnable::Run() AbortOperationsRunnable::Run()
{ {

View File

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