OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_POWER_SAVE_BLOCKER2_H_ |
| 6 #define CONTENT_BROWSER_POWER_SAVE_BLOCKER2_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "content/common/content_export.h" |
| 14 |
| 15 // A RAII-style class to block the system from entering low-power (sleep) mode. |
| 16 class CONTENT_EXPORT PowerSaveBlocker2 { |
| 17 public: |
| 18 enum PowerSaveBlockerType { |
| 19 // Prevent the application from being suspended. On some platforms, apps may |
| 20 // be suspended when they are not visible to the user. This type of block |
| 21 // requests that the app continue to run in that case, and on all platforms |
| 22 // prevents the system from sleeping. |
| 23 // Example use cases: downloading a file, playing audio. |
| 24 kPowerSaveBlockPreventAppSuspension, |
| 25 |
| 26 // Prevent the display from going to sleep. This also has the side effect of |
| 27 // preventing the system from sleeping, but does not necessarily prevent the |
| 28 // app from being suspended on some platforms if the user hides it. |
| 29 // Example use case: playing video. |
| 30 kPowerSaveBlockPreventDisplaySleep, |
| 31 }; |
| 32 |
| 33 // Pass in the type of power save blocking desired. If multiple types of |
| 34 // blocking are desired, instantiate one PowerSaveBlocker for each type. |
| 35 // |reason| may be provided to the underlying system APIs on some platforms. |
| 36 PowerSaveBlocker2(PowerSaveBlockerType type, const std::string& reason); |
| 37 ~PowerSaveBlocker2(); |
| 38 |
| 39 private: |
| 40 class Delegate; |
| 41 |
| 42 // Implementations of this class may need a second object with different |
| 43 // lifetime than the RAII container, or additional storage. This member is |
| 44 // here for that purpose. If not used, just define the class as an empty |
| 45 // RefCounted like so to make it compile: |
| 46 // class PowerSaveBlocker2::Delegate |
| 47 // : public RefCounted<PowerSaveBlocker2::Delegate> { |
| 48 // }; |
| 49 scoped_refptr<PowerSaveBlockerDelegate> delegate; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker2); |
| 52 }; |
| 53 |
| 54 #endif // CONTENT_BROWSER_POWER_SAVE_BLOCKER2_H_ |
OLD | NEW |