mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1320275
- QuotaManager must be registered as battery observer before calling hal:GetCurrentBatteryInformation, r=janv
This commit is contained in:
parent
880566d51c
commit
3eb6049ec1
@ -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()
|
||||||
{
|
{
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user