1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_battery_BatteryManager_h
8 #define mozilla_dom_battery_BatteryManager_h
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "mozilla/HalBatteryInformation.h"
16 class BatteryInformation
;
19 namespace dom::battery
{
21 class BatteryManager
: public DOMEventTargetHelper
,
22 public hal::BatteryObserver
{
24 explicit BatteryManager(nsPIDOMWindowInner
* aWindow
);
30 void Notify(const hal::BatteryInformation
& aBatteryInfo
) override
;
36 nsPIDOMWindowInner
* GetParentObject() const { return GetOwner(); }
38 virtual JSObject
* WrapObject(JSContext
* aCx
,
39 JS::Handle
<JSObject
*> aGivenProto
) override
;
41 bool Charging() const;
43 double ChargingTime() const;
45 double DischargingTime() const;
49 IMPL_EVENT_HANDLER(chargingchange
)
50 IMPL_EVENT_HANDLER(chargingtimechange
)
51 IMPL_EVENT_HANDLER(dischargingtimechange
)
52 IMPL_EVENT_HANDLER(levelchange
)
56 * Update the battery information stored in the battery manager object using
57 * a battery information object.
59 void UpdateFromBatteryInfo(const hal::BatteryInformation
& aBatteryInfo
);
62 * Represents the battery level, ranging from 0.0 (dead or removed?)
63 * to 1.0 (fully charged)
68 * Represents the discharging time or the charging time, depending on the
69 * current battery status (charging or not).
71 double mRemainingTime
;
74 } // namespace dom::battery
75 } // namespace mozilla
77 #endif // mozilla_dom_battery_BatteryManager_h