Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(805)

Unified Diff: content/browser/power_save_blocker.h

Issue 10542089: Power save blocker: switch to new implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/power_save_blocker.h
===================================================================
--- content/browser/power_save_blocker.h (revision 141311)
+++ content/browser/power_save_blocker.h (working copy)
@@ -13,55 +13,11 @@
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
-// A RAII-style class to block the system from entering low-power (sleep) mode.
-class CONTENT_EXPORT PowerSaveBlocker {
- public:
- enum PowerSaveBlockerType {
- kPowerSaveBlockPreventNone = -1,
-
- // Prevent the system from going to sleep; allow display sleep.
- kPowerSaveBlockPreventSystemSleep,
-
- // Prevent the system or display from going to sleep.
- kPowerSaveBlockPreventDisplaySleep,
-
- // Count of the values; not valid as a parameter.
- kPowerSaveBlockPreventStateCount
- };
-
- // Pass in the level of sleep prevention desired. kPowerSaveBlockPreventNone
- // is not a valid option.
- explicit PowerSaveBlocker(PowerSaveBlockerType type);
- ~PowerSaveBlocker();
-
- private:
- // Platform-specific function called when enable state is changed.
- // Guaranteed to be called only from the UI thread.
- static void ApplyBlock(PowerSaveBlockerType type);
-
- // Called only from UI thread.
- static void AdjustBlockCount(const std::vector<int>& deltas);
-
- // Invokes AdjustBlockCount on the UI thread.
- static void PostAdjustBlockCount(const std::vector<int>& deltas);
-
- // Returns the highest-severity block type in use.
- static PowerSaveBlockerType HighestBlockType();
-
- PowerSaveBlockerType type_;
-
- static int blocker_count_[];
-
- DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker);
-};
-
namespace content {
-// NOT READY YET. PowerSaveBlocker above is soon to be replaced by this class,
-// but it's not done yet so client code should use the one above for now.
// A RAII-style class to block the system from entering low-power (sleep) mode.
// This class is thread-safe; it may be constructed and deleted on any thread.
-class CONTENT_EXPORT PowerSaveBlocker2 {
+class CONTENT_EXPORT PowerSaveBlocker {
public:
enum PowerSaveBlockerType {
// Prevent the application from being suspended. On some platforms, apps may
@@ -81,8 +37,8 @@
// Pass in the type of power save blocking desired. If multiple types of
// blocking are desired, instantiate one PowerSaveBlocker for each type.
// |reason| may be provided to the underlying system APIs on some platforms.
- PowerSaveBlocker2(PowerSaveBlockerType type, const std::string& reason);
- ~PowerSaveBlocker2();
+ PowerSaveBlocker(PowerSaveBlockerType type, const std::string& reason);
+ ~PowerSaveBlocker();
private:
class Delegate;
@@ -91,15 +47,15 @@
// lifetime than the RAII container, or additional storage. This member is
// here for that purpose. If not used, just define the class as an empty
// RefCounted (or RefCountedThreadSafe) like so to make it compile:
- // class PowerSaveBlocker2::Delegate
- // : public base::RefCounted<PowerSaveBlocker2::Delegate> {
+ // class PowerSaveBlocker::Delegate
+ // : public base::RefCounted<PowerSaveBlocker::Delegate> {
// private:
// friend class base::RefCounted<Delegate>;
// ~Delegate() {}
// };
scoped_refptr<Delegate> delegate_;
- DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker2);
+ DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker);
};
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698