Bug 1890793: Assert CallArgs::newTarget is not gray. r=spidermonkey-reviewers,sfink...
[gecko.git] / dom / power / PowerManagerService.h
blob1522342201496897d5eff08c681817a638a9b6a0
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/. */
6 #ifndef mozilla_dom_power_PowerManagerService_h
7 #define mozilla_dom_power_PowerManagerService_h
9 #include "nsCOMPtr.h"
10 #include "nsHashKeys.h"
11 #include "nsTArray.h"
12 #include "nsIDOMWakeLockListener.h"
13 #include "nsIPowerManagerService.h"
14 #include "mozilla/HalWakeLockInformation.h"
15 #include "mozilla/StaticPtr.h"
16 #include "mozilla/dom/WakeLock.h"
18 namespace mozilla::dom {
20 class ContentParent;
22 namespace power {
24 class PowerManagerService : public nsIPowerManagerService,
25 public hal::WakeLockObserver {
26 public:
27 NS_DECL_ISUPPORTS
28 NS_DECL_NSIPOWERMANAGERSERVICE
30 PowerManagerService() = default;
32 static already_AddRefed<PowerManagerService> GetInstance();
34 void Init();
36 // Implement WakeLockObserver
37 void Notify(const hal::WakeLockInformation& aWakeLockInfo) override;
39 already_AddRefed<WakeLock> NewWakeLock(const nsAString& aTopic,
40 nsPIDOMWindowInner* aWindow,
41 mozilla::ErrorResult& aRv);
43 private:
44 ~PowerManagerService();
46 void ComputeWakeLockState(const hal::WakeLockInformation& aWakeLockInfo,
47 nsAString& aState);
49 static StaticRefPtr<PowerManagerService> sSingleton;
51 nsTArray<nsCOMPtr<nsIDOMMozWakeLockListener>> mWakeLockListeners;
54 } // namespace power
55 } // namespace mozilla::dom
57 #endif // mozilla_dom_power_PowerManagerService_h