dom/power/PowerManagerService.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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
    28 {
    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);
    40   /**
    41    * Acquire a wake lock on behalf of a given process (aContentParent).
    42    *
    43    * This method stands in contrast to nsIPowerManagerService::NewWakeLock,
    44    * which acquires a wake lock on behalf of the /current/ process.
    45    *
    46    * NewWakeLockOnBehalfOfProcess is different from NewWakeLock in that
    47    *
    48    *  - The wake lock unlocks itself if the /given/ process dies, and
    49    *  - The /given/ process shows up in WakeLockInfo::lockingProcesses.
    50    *
    51    */
    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;
    74 };
    76 } // namespace power
    77 } // namespace dom
    78 } // namespace mozilla
    80 #endif // mozilla_dom_power_PowerManagerService_h

mercurial