0
Files
src/content/browser/power_save_blocker.h
avi@chromium.org b48a93fae2 Add screen power save block level.
BUG=100054
TEST=no change

Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=105401

Reverted: http://src.chromium.org/viewvc/chrome?view=rev&revision=105415

Review URL: http://codereview.chromium.org/8251008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105507 0039d316-1c4b-4281-b951-d872f2087c98
2011-10-14 17:09:54 +00:00

56 lines
1.6 KiB
C++

// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_POWER_SAVE_BLOCKER_H_
#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:
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);
};
#endif // CONTENT_BROWSER_POWER_SAVE_BLOCKER_H_