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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_POWER_SAVE_BLOCKER_H_ 5 #ifndef CONTENT_BROWSER_POWER_SAVE_BLOCKER_H_
6 #define CONTENT_BROWSER_POWER_SAVE_BLOCKER_H_ 6 #define CONTENT_BROWSER_POWER_SAVE_BLOCKER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector>
10
9 #include "base/basictypes.h" 11 #include "base/basictypes.h"
10 12
11 // A RAII-style class to block the system from entering low-power (sleep) mode. 13 // A RAII-style class to block the system from entering low-power (sleep) mode.
12 class PowerSaveBlocker { 14 class PowerSaveBlocker {
13 public: 15 public:
14 explicit PowerSaveBlocker(bool enabled); 16 enum PowerSaveBlockerType {
17 kPowerSaveBlockPreventNone = -1,
18
19 // Prevent the system from going to sleep; allow display sleep.
20 kPowerSaveBlockPreventSystemSleep,
21
22 // Prevent the system or display from going to sleep.
23 kPowerSaveBlockPreventDisplaySleep
24 };
25
26 explicit PowerSaveBlocker(PowerSaveBlockerType type);
Mark Mentovai 2011/10/13 19:09:13 This should never accept kPowerSaveBlockPreventNon
15 ~PowerSaveBlocker(); 27 ~PowerSaveBlocker();
16 28
17 bool enabled() const { return enabled_; } 29 private:
30 enum {
31 kPowerSaveBlockPreventStateCount =
32 kPowerSaveBlockPreventDisplaySleep + 1
33 };
18 34
19 // Puts the sleep mode block into effect.
20 void Enable();
21 // Disables the sleep block.
22 void Disable();
23
24 private:
25 // Platform-specific function called when enable state is changed. 35 // Platform-specific function called when enable state is changed.
26 // Guaranteed to be called only from the UI thread. 36 // Guaranteed to be called only from the UI thread.
27 static void ApplyBlock(bool blocked); 37 static void ApplyBlock(PowerSaveBlockerType type);
28 38
29 // Called only from UI thread. 39 // Called only from UI thread.
30 static void AdjustBlockCount(int delta); 40 static void AdjustBlockCount(const std::vector<int>& deltas);
31 41
32 // Invokes AdjustBlockCount on the UI thread. 42 // Invokes AdjustBlockCount on the UI thread.
33 static void PostAdjustBlockCount(int delta); 43 static void PostAdjustBlockCount(const std::vector<int>& deltas);
34 44
35 bool enabled_; 45 // Returns the highest-severity block type in use.
46 static PowerSaveBlockerType HighestBlockType();
36 47
37 static int blocker_count_; 48 PowerSaveBlockerType type_;
49
50 static int blocker_count_[];
38 51
39 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker); 52 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker);
40 }; 53 };
41 54
42 #endif // CONTENT_BROWSER_POWER_SAVE_BLOCKER_H_ 55 #endif // CONTENT_BROWSER_POWER_SAVE_BLOCKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698