Bumping manifests a=b2g-bump
[gecko.git] / dom / power / PowerManagerService.h
blob566345ff73a7da9f15ca9f0f0e4aa965aba62a8a
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_dom_power_PowerManagerService_h
6 #define mozilla_dom_power_PowerManagerService_h
8 #include "nsCOMPtr.h"
9 #include "nsDataHashtable.h"
10 #include "nsHashKeys.h"
11 #include "nsTArray.h"
12 #include "nsIPowerManagerService.h"
13 #include "mozilla/Observer.h"
14 #include "Types.h"
15 #include "mozilla/StaticPtr.h"
16 #include "mozilla/dom/WakeLock.h"
18 namespace mozilla {
19 namespace dom {
21 class ContentParent;
23 namespace power {
25 class PowerManagerService
26 : public nsIPowerManagerService
27 , public WakeLockObserver
29 public:
30 NS_DECL_ISUPPORTS
31 NS_DECL_NSIPOWERMANAGERSERVICE
33 static already_AddRefed<PowerManagerService> GetInstance();
35 void Init();
37 // Implement WakeLockObserver
38 void Notify(const hal::WakeLockInformation& aWakeLockInfo) MOZ_OVERRIDE;
40 /**
41 * Acquire a wake lock on behalf of a given process (aContentParent).
43 * This method stands in contrast to nsIPowerManagerService::NewWakeLock,
44 * which acquires a wake lock on behalf of the /current/ process.
46 * NewWakeLockOnBehalfOfProcess is different from NewWakeLock in that
48 * - The wake lock unlocks itself if the /given/ process dies, and
49 * - The /given/ process shows up in WakeLockInfo::lockingProcesses.
52 already_AddRefed<WakeLock>
53 NewWakeLockOnBehalfOfProcess(const nsAString& aTopic,
54 ContentParent* aContentParent);
56 already_AddRefed<WakeLock>
57 NewWakeLock(const nsAString& aTopic, nsIDOMWindow* aWindow,
58 mozilla::ErrorResult& aRv);
60 private:
62 ~PowerManagerService();
64 void ComputeWakeLockState(const hal::WakeLockInformation& aWakeLockInfo,
65 nsAString &aState);
67 void SyncProfile();
69 static StaticRefPtr<PowerManagerService> sSingleton;
71 nsTArray<nsCOMPtr<nsIDOMMozWakeLockListener> > mWakeLockListeners;
73 int32_t mWatchdogTimeoutSecs;
76 } // namespace power
77 } // namespace dom
78 } // namespace mozilla
80 #endif // mozilla_dom_power_PowerManagerService_h