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

Unified Diff: content/browser/power_save_blocker.h

Issue 8251008: Add screen power save block level. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: base::Bind Created 9 years, 2 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
diff --git a/content/browser/power_save_blocker.h b/content/browser/power_save_blocker.h
index 7d04e6ebbdd5f31c8c7ef16a184424e11acd6d6f..2b4c2170fc1c33eb8ba09ad4d9b28ece927cf3f5 100644
--- a/content/browser/power_save_blocker.h
+++ b/content/browser/power_save_blocker.h
@@ -6,35 +6,48 @@
#define CONTENT_BROWSER_POWER_SAVE_BLOCKER_H_
#pragma once
+#include <vector>
+
#include "base/basictypes.h"
// A RAII-style class to block the system from entering low-power (sleep) mode.
class PowerSaveBlocker {
public:
- explicit PowerSaveBlocker(bool enabled);
- ~PowerSaveBlocker();
+ enum PowerSaveBlockerType {
+ kPowerSaveBlockPreventNone = -1,
+
+ // Prevent the system from going to sleep; allow display sleep.
+ kPowerSaveBlockPreventSystemSleep,
- bool enabled() const { return enabled_; }
+ // Prevent the system or display from going to sleep.
+ kPowerSaveBlockPreventDisplaySleep
+ };
- // Puts the sleep mode block into effect.
- void Enable();
- // Disables the sleep block.
- void Disable();
+ explicit PowerSaveBlocker(PowerSaveBlockerType type);
Mark Mentovai 2011/10/13 19:09:13 This should never accept kPowerSaveBlockPreventNon
+ ~PowerSaveBlocker();
private:
+ enum {
+ kPowerSaveBlockPreventStateCount =
+ kPowerSaveBlockPreventDisplaySleep + 1
+ };
+
// Platform-specific function called when enable state is changed.
// Guaranteed to be called only from the UI thread.
- static void ApplyBlock(bool blocked);
+ static void ApplyBlock(PowerSaveBlockerType type);
// Called only from UI thread.
- static void AdjustBlockCount(int delta);
+ static void AdjustBlockCount(const std::vector<int>& deltas);
// Invokes AdjustBlockCount on the UI thread.
- static void PostAdjustBlockCount(int delta);
+ static void PostAdjustBlockCount(const std::vector<int>& deltas);
+
+ // Returns the highest-severity block type in use.
+ static PowerSaveBlockerType HighestBlockType();
- bool enabled_;
+ PowerSaveBlockerType type_;
- static int blocker_count_;
+ static int blocker_count_[];
DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker);
};

Powered by Google App Engine
This is Rietveld 408576698