Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | #ifndef mozilla_dom_power_PowerManagerService_h |
michael@0 | 6 | #define mozilla_dom_power_PowerManagerService_h |
michael@0 | 7 | |
michael@0 | 8 | #include "nsCOMPtr.h" |
michael@0 | 9 | #include "nsDataHashtable.h" |
michael@0 | 10 | #include "nsHashKeys.h" |
michael@0 | 11 | #include "nsTArray.h" |
michael@0 | 12 | #include "nsIPowerManagerService.h" |
michael@0 | 13 | #include "mozilla/Observer.h" |
michael@0 | 14 | #include "Types.h" |
michael@0 | 15 | #include "mozilla/StaticPtr.h" |
michael@0 | 16 | #include "mozilla/dom/WakeLock.h" |
michael@0 | 17 | |
michael@0 | 18 | namespace mozilla { |
michael@0 | 19 | namespace dom { |
michael@0 | 20 | |
michael@0 | 21 | class ContentParent; |
michael@0 | 22 | |
michael@0 | 23 | namespace power { |
michael@0 | 24 | |
michael@0 | 25 | class PowerManagerService |
michael@0 | 26 | : public nsIPowerManagerService |
michael@0 | 27 | , public WakeLockObserver |
michael@0 | 28 | { |
michael@0 | 29 | public: |
michael@0 | 30 | NS_DECL_ISUPPORTS |
michael@0 | 31 | NS_DECL_NSIPOWERMANAGERSERVICE |
michael@0 | 32 | |
michael@0 | 33 | static already_AddRefed<PowerManagerService> GetInstance(); |
michael@0 | 34 | |
michael@0 | 35 | void Init(); |
michael@0 | 36 | |
michael@0 | 37 | // Implement WakeLockObserver |
michael@0 | 38 | void Notify(const hal::WakeLockInformation& aWakeLockInfo); |
michael@0 | 39 | |
michael@0 | 40 | /** |
michael@0 | 41 | * Acquire a wake lock on behalf of a given process (aContentParent). |
michael@0 | 42 | * |
michael@0 | 43 | * This method stands in contrast to nsIPowerManagerService::NewWakeLock, |
michael@0 | 44 | * which acquires a wake lock on behalf of the /current/ process. |
michael@0 | 45 | * |
michael@0 | 46 | * NewWakeLockOnBehalfOfProcess is different from NewWakeLock in that |
michael@0 | 47 | * |
michael@0 | 48 | * - The wake lock unlocks itself if the /given/ process dies, and |
michael@0 | 49 | * - The /given/ process shows up in WakeLockInfo::lockingProcesses. |
michael@0 | 50 | * |
michael@0 | 51 | */ |
michael@0 | 52 | already_AddRefed<WakeLock> |
michael@0 | 53 | NewWakeLockOnBehalfOfProcess(const nsAString& aTopic, |
michael@0 | 54 | ContentParent* aContentParent); |
michael@0 | 55 | |
michael@0 | 56 | already_AddRefed<WakeLock> |
michael@0 | 57 | NewWakeLock(const nsAString& aTopic, nsIDOMWindow* aWindow, |
michael@0 | 58 | mozilla::ErrorResult& aRv); |
michael@0 | 59 | |
michael@0 | 60 | private: |
michael@0 | 61 | |
michael@0 | 62 | ~PowerManagerService(); |
michael@0 | 63 | |
michael@0 | 64 | void ComputeWakeLockState(const hal::WakeLockInformation& aWakeLockInfo, |
michael@0 | 65 | nsAString &aState); |
michael@0 | 66 | |
michael@0 | 67 | void SyncProfile(); |
michael@0 | 68 | |
michael@0 | 69 | static StaticRefPtr<PowerManagerService> sSingleton; |
michael@0 | 70 | |
michael@0 | 71 | nsTArray<nsCOMPtr<nsIDOMMozWakeLockListener> > mWakeLockListeners; |
michael@0 | 72 | |
michael@0 | 73 | int32_t mWatchdogTimeoutSecs; |
michael@0 | 74 | }; |
michael@0 | 75 | |
michael@0 | 76 | } // namespace power |
michael@0 | 77 | } // namespace dom |
michael@0 | 78 | } // namespace mozilla |
michael@0 | 79 | |
michael@0 | 80 | #endif // mozilla_dom_power_PowerManagerService_h |